本文整理汇总了Java中com.intellij.AppTopics类的典型用法代码示例。如果您正苦于以下问题:Java AppTopics类的具体用法?Java AppTopics怎么用?Java AppTopics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AppTopics类属于com.intellij包,在下文中一共展示了AppTopics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SwaggerUiUrlProvider
import com.intellij.AppTopics; //导入依赖的package包/类
private SwaggerUiUrlProvider(final FileDetector fileDetector) {
this.fileDetector = fileDetector;
ApplicationManager.getApplication().getMessageBus().connect().subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void beforeDocumentSaving(@NotNull final Document document) {
SwaggerFileService swaggerFileService = ServiceManager.getService(SwaggerFileService.class);
final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
if (openProjects.length > 0) {
final PsiFile psiFile = PsiDocumentManager.getInstance(openProjects[0]).getPsiFile(document);
if (psiFile != null && swaggerFileService.swaggerContentExistsFor(psiFile)) {
final boolean swaggerFile = fileDetector.isMainSwaggerFile(psiFile) || fileDetector.isMainOpenApiFile(psiFile);
if (swaggerFile) {
swaggerFileService.convertSwaggerToHtml(psiFile);
}
}
}
}
});
}
示例2: activate
import com.intellij.AppTopics; //导入依赖的package包/类
public void activate() {
if (myConnection == null) {
myListenerDisposable = Disposer.newDisposable();
Disposer.register(myProject, myListenerDisposable);
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(myListener, myListenerDisposable);
myConnection = ApplicationManager.getApplication().getMessageBus().connect(myProject);
myConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void beforeAllDocumentsSaving() {
myDocumentSavingInProgress = true;
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
myDocumentSavingInProgress = false;
}
}, ModalityState.any());
}
});
}
}
示例3: testSaveDocument_DoNotSaveIfModStampEqualsToFile
import com.intellij.AppTopics; //导入依赖的package包/类
public void testSaveDocument_DoNotSaveIfModStampEqualsToFile() throws Exception {
final VirtualFile file = createFile();
final DocumentEx document = (DocumentEx)myDocumentManager.getDocument(file);
assertNotNull(file.toString(), document);
WriteCommandAction.runWriteCommandAction(myProject, new Runnable() {
@Override
public void run() {
document.insertString(0, "zzz");
document.setModificationStamp(file.getModificationStamp());
}
});
getProject().getMessageBus().connect(getTestRootDisposable()).subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void beforeDocumentSaving(@NotNull Document documentToSave) {
assertNotSame(document, documentToSave);
}
});
myDocumentManager.saveDocument(document);
}
示例4: PsiVFSListener
import com.intellij.AppTopics; //导入依赖的package包/类
public PsiVFSListener(Project project) {
myProject = project;
myFileTypeManager = FileTypeManager.getInstance();
myProjectRootManager = ProjectRootManager.getInstance(project);
myManager = (PsiManagerImpl) PsiManager.getInstance(project);
myFileManager = (FileManagerImpl) myManager.getFileManager();
myConnection = project.getMessageBus().connect(project);
StartupManager.getInstance(project).registerPreStartupActivity(new Runnable() {
@Override
public void run() {
myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyModuleRootListener());
myConnection.subscribe(FileTypeManager.TOPIC, new FileTypeListener.Adapter() {
@Override
public void fileTypesChanged(@NotNull FileTypeEvent e) {
myFileManager.processFileTypesChanged();
}
});
myConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new MyFileDocumentManagerAdapter());
myFileManager.markInitialized();
}
});
}
示例5: JavaFileManagerImpl
import com.intellij.AppTopics; //导入依赖的package包/类
public JavaFileManagerImpl(final PsiManagerEx manager, final ProjectRootManager projectRootManager, MessageBus bus,
final StartupManager startupManager) {
super(manager, projectRootManager, bus);
myConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void fileWithNoDocumentChanged(@NotNull final VirtualFile file) {
clearNonRepositoryMaps();
}
});
startupManager.registerStartupActivity(
new Runnable() {
@Override
public void run() {
initialize();
}
}
);
}
示例6: setupEventListeners
import com.intellij.AppTopics; //导入依赖的package包/类
private void setupEventListeners() {
ApplicationManager.getApplication().invokeLater(new Runnable(){
public void run() {
// save file
MessageBus bus = ApplicationManager.getApplication().getMessageBus();
connection = bus.connect();
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new CustomSaveListener());
// edit document
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new CustomDocumentListener());
// mouse press
EditorFactory.getInstance().getEventMulticaster().addEditorMouseListener(new CustomEditorMouseListener());
// scroll document
EditorFactory.getInstance().getEventMulticaster().addVisibleAreaListener(new CustomVisibleAreaListener());
}
});
}
示例7: testSaveDocument_DoNotSaveIfModStampEqualsToFile
import com.intellij.AppTopics; //导入依赖的package包/类
public void testSaveDocument_DoNotSaveIfModStampEqualsToFile() throws Exception {
final VirtualFile file = createFile();
final DocumentEx document = (DocumentEx)myDocumentManager.getDocument(file);
assertNotNull(file.toString(), document);
WriteCommandAction.runWriteCommandAction(myProject, new Runnable() {
@Override
public void run() {
document.insertString(0, "zzz");
document.setModificationStamp(file.getModificationStamp());
}
});
getProject().getMessageBus().connect(getTestRootDisposable()).subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void beforeDocumentSaving(@Nonnull Document documentToSave) {
assertNotSame(document, documentToSave);
}
});
myDocumentManager.saveDocument(document);
}
示例8: PsiVFSListener
import com.intellij.AppTopics; //导入依赖的package包/类
public PsiVFSListener(Project project) {
installGlobalListener();
myProject = project;
myFileTypeManager = FileTypeManager.getInstance();
myProjectRootManager = ProjectRootManager.getInstance(project);
myManager = (PsiManagerImpl)PsiManager.getInstance(project);
myFileManager = (FileManagerImpl)myManager.getFileManager();
StartupManager.getInstance(project).registerPreStartupActivity(() -> {
MessageBusConnection connection = project.getMessageBus().connect(project);
connection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyModuleRootListener());
connection.subscribe(FileTypeManager.TOPIC, new FileTypeListener() {
@Override
public void fileTypesChanged(@Nonnull FileTypeEvent e) {
myFileManager.processFileTypesChanged();
}
});
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new MyFileDocumentManagerAdapter());
});
}
示例9: initComponent
import com.intellij.AppTopics; //导入依赖的package包/类
@Override
public void initComponent() {
Boolean reasonReformatOnSave = Boolean.valueOf(System.getProperty("reasonReformatOnSave"));
if (reasonReformatOnSave) {
Notifications.Bus.notify(new RmlNotification("Refmt", "reformat on save is enabled", NotificationType.INFORMATION));
ReformatOnSave handler = new ReformatOnSave();
ApplicationManager.getApplication().getMessageBus().connect().subscribe(AppTopics.FILE_DOCUMENT_SYNC, handler);
}
}
示例10: initComponent
import com.intellij.AppTopics; //导入依赖的package包/类
public void initComponent() {
LOGGER.debug("phpfmt welcome!", String.format("Debug mode is: %s", settings.isDebug()? "On": "Off"));
toEventLog(settings.isDebug(), "phpfmt updating phpfmt...", String.format("engine: %s, version: %s.", settings.getEngineChannel(), settings.getEngineVersion()));
selfUpdate();
final MessageBus bus = ApplicationManager.getApplication().getMessageBus();
final MessageBusConnection connection = bus.connect();
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileListener());
}
示例11: install
import com.intellij.AppTopics; //导入依赖的package包/类
@Override
public void install(@NotNull StatusBar statusBar) {
super.install(statusBar);
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(this);
connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void fileContentReloaded(@NotNull VirtualFile file, @NotNull Document document) {
update();
}
});
}
示例12: testReplaceDocumentTextWithTheSameText
import com.intellij.AppTopics; //导入依赖的package包/类
public void testReplaceDocumentTextWithTheSameText() throws Exception {
final VirtualFile file = createFile();
final DocumentEx document = (DocumentEx)myDocumentManager.getDocument(file);
final String newText = "test text";
assertNotNull(file.toString(), document);
WriteCommandAction.runWriteCommandAction(myProject, new Runnable() {
@Override
public void run() {
document.replaceString(0, document.getTextLength(), newText);
assertTrue(myDocumentManager.isDocumentUnsaved(document));
myDocumentManager.saveDocument(document);
getProject().getMessageBus().connect(getTestRootDisposable())
.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void beforeDocumentSaving(@NotNull Document documentToSave) {
assertNotSame(document, documentToSave);
}
});
final long modificationStamp = document.getModificationStamp();
document.replaceString(0, document.getTextLength(), newText);
if (myDocumentManager.isDocumentUnsaved(document)) {
assertTrue(document.getModificationStamp() > modificationStamp);
}
else {
assertEquals(modificationStamp, document.getModificationStamp());
}
}
});
}
示例13: initComponent
import com.intellij.AppTopics; //导入依赖的package包/类
public void initComponent() {
ApplicationManager.getApplication().getMessageBus().connect().subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void beforeAllDocumentsSaving() {
Map<Document, Project> documentsToWarn = getDocumentsBeingCommitted();
if (!documentsToWarn.isEmpty()) {
boolean allowSave = showAllowSaveDialog(documentsToWarn);
updateSaveability(documentsToWarn, allowSave);
}
}
});
}
示例14: install
import com.intellij.AppTopics; //导入依赖的package包/类
public void install() {
class Listener extends FileDocumentManagerAdapter implements ProjectEx.ProjectSaved {
@Override
public void beforeDocumentSaving(@NotNull Document document) {
if (document == myConsole.getEditorDocument()) {
saveHistory();
}
}
@Override
public void saved(@NotNull Project project) {
saveHistory();
}
}
Listener listener = new Listener();
ApplicationManager.getApplication().getMessageBus().connect(myConsole).subscribe(ProjectEx.ProjectSaved.TOPIC, listener);
myConsole.getProject().getMessageBus().connect(myConsole).subscribe(AppTopics.FILE_DOCUMENT_SYNC, listener);
myConsole.getVirtualFile().putUserData(CONTROLLER_KEY, this);
Disposer.register(myConsole, new Disposable() {
@Override
public void dispose() {
myConsole.getVirtualFile().putUserData(CONTROLLER_KEY, null);
saveHistory();
}
});
if (myHelper.getModel().getHistorySize() == 0) {
loadHistory(myHelper.getId());
}
configureActions();
myLastSaveStamp = getCurrentTimeStamp();
}
示例15: PsiDocumentManagerImpl
import com.intellij.AppTopics; //导入依赖的package包/类
public PsiDocumentManagerImpl(@NotNull final Project project,
@NotNull PsiManager psiManager,
@NotNull EditorFactory editorFactory,
@NotNull MessageBus bus,
@NonNls @NotNull final DocumentCommitThread documentCommitThread) {
super(project, psiManager, bus, documentCommitThread);
myDocumentCommitThread = documentCommitThread;
editorFactory.getEventMulticaster().addDocumentListener(this, project);
MessageBusConnection busConnection = bus.connect();
busConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() {
@Override
public void fileContentLoaded(@NotNull final VirtualFile virtualFile, @NotNull Document document) {
PsiFile psiFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
@Override
public PsiFile compute() {
return myProject.isDisposed() || !virtualFile.isValid() ? null : getCachedPsiFile(virtualFile);
}
});
fireDocumentCreated(document, psiFile);
}
});
busConnection.subscribe(DocumentBulkUpdateListener.TOPIC, new DocumentBulkUpdateListener.Adapter() {
@Override
public void updateFinished(@NotNull Document doc) {
documentCommitThread.queueCommit(project, doc, "Bulk update finished", ApplicationManager.getApplication().getDefaultModalityState());
}
});
}