本文整理汇总了Java中com.intellij.util.messages.MessageBusConnection类的典型用法代码示例。如果您正苦于以下问题:Java MessageBusConnection类的具体用法?Java MessageBusConnection怎么用?Java MessageBusConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageBusConnection类属于com.intellij.util.messages包,在下文中一共展示了MessageBusConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectToMessageBus
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
private void connectToMessageBus(Project project) {
logger.info("Connecting to message bus.");
MessageBusConnection bus = project.getMessageBus().connect();
bus.setDefaultHandler(
(method, objects) -> {
logger.info("Method call observed in message bus.");
for (Object object : objects) {
if (method.toString().toLowerCase().contains("contentselected")) {
if (object.toString().toLowerCase().contains("debug")) {
new ButtonInputListener().receiveDebugRunAction();
} else if (object.toString().contains("DefaultRunExecutor")) {
new ButtonInputListener().receiveRunAction();
}
}
}
});
logger.info("Subscribing to RunContentManager topic.");
bus.subscribe(RunContentManager.TOPIC);
}
示例2: ExternalAnnotationsManagerImpl
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
public ExternalAnnotationsManagerImpl(@NotNull final Project project, final PsiManager psiManager) {
super(psiManager);
myBus = project.getMessageBus();
final MessageBusConnection connection = myBus.connect(project);
connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
@Override
public void rootsChanged(ModuleRootEvent event) {
dropCache();
}
});
final MyVirtualFileListener fileListener = new MyVirtualFileListener();
VirtualFileManager.getInstance().addVirtualFileListener(fileListener);
Disposer.register(myPsiManager.getProject(), new Disposable() {
@Override
public void dispose() {
VirtualFileManager.getInstance().removeVirtualFileListener(fileListener);
}
});
}
示例3: install
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
public void install() {
final MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() {
@Override
public void selectionChanged(@NotNull FileEditorManagerEvent event) {
final FileEditor editor = event.getNewEditor();
if (editor != null && myComponent.isShowing() && isAutoScrollEnabled()) {
myAlarm.cancelAllRequests();
myAlarm.addRequest(new Runnable() {
@Override
public void run() {
selectElementFromEditor(editor);
}
}, getAlarmDelay(), getModalityState());
}
}
});
}
示例4: projectOpened
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
@Override
public void projectOpened() {
final ModuleRootListener rootListener = new ModuleRootAdapter() {
public void rootsChanged(ModuleRootEvent event) {
if (!myProject.isDisposed()) {
checkToolWindowStatuses(myProject);
}
}
};
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new Runnable() {
public void run() {
if (!myProject.isDisposed()) {
checkToolWindowStatuses(myProject);
final MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
connection.subscribe(ProjectTopics.PROJECT_ROOTS, rootListener);
}
}
});
}
示例5: EditorNotificationsImpl
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
public EditorNotificationsImpl(Project project) {
super(project);
myUpdateMerger = new MergingUpdateQueue("EditorNotifications update merger", 100, true, null, project);
MessageBusConnection connection = project.getMessageBus().connect(project);
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() {
@Override
public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
updateNotifications(file);
}
});
connection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
@Override
public void enteredDumbMode() {
updateAllNotifications();
}
@Override
public void exitDumbMode() {
updateAllNotifications();
}
});
}
示例6: LibNotifyWrapper
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
private LibNotifyWrapper() {
myLibNotify = (LibNotify)Native.loadLibrary("libnotify.so.4", LibNotify.class);
String appName = ApplicationNamesInfo.getInstance().getProductName();
if (myLibNotify.notify_init(appName) == 0) {
throw new IllegalStateException("notify_init failed");
}
String icon = AppUIUtil.findIcon(PathManager.getBinPath());
myIcon = icon != null ? icon : "dialog-information";
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
@Override
public void appClosing() {
synchronized (myLock) {
myDisposed = true;
myLibNotify.notify_uninit();
}
}
});
}
示例7: scheduleInitialVfsRefresh
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
public void scheduleInitialVfsRefresh() {
UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
if (myProject.isDisposed()) return;
markContentRootsForRefresh();
Application app = ApplicationManager.getApplication();
if (!app.isHeadlessEnvironment()) {
final long sessionId = VirtualFileManager.getInstance().asyncRefresh(null);
final MessageBusConnection connection = app.getMessageBus().connect();
connection.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener.Adapter() {
@Override
public void afterProjectClosed(@NotNull Project project) {
RefreshQueue.getInstance().cancelSession(sessionId);
connection.disconnect();
}
});
}
else {
VirtualFileManager.getInstance().syncRefresh();
}
}
});
}
示例8: projectOpened
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
@Override
public void projectOpened() {
MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
@Override
public void rootsChanged(ModuleRootEvent event) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (myProject.isDisposed()) return;
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
}
}, ModalityState.NON_MODAL);
}
});
final WolfTheProblemSolver.ProblemListener myProblemListener = new MyProblemListener();
WolfTheProblemSolver.getInstance(myProject).addProblemListener(myProblemListener,myProject);
}
示例9: unsubscribeFrom
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
static void unsubscribeFrom(NavBarPanel panel) {
final NavBarListener listener = (NavBarListener)panel.getClientProperty(LISTENER);
panel.putClientProperty(LISTENER, null);
if (listener != null) {
final Project project = panel.getProject();
KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener(listener);
FileStatusManager.getInstance(project).removeFileStatusListener(listener);
PsiManager.getInstance(project).removePsiTreeChangeListener(listener);
WolfTheProblemSolver.getInstance(project).removeProblemListener(listener);
ActionManager.getInstance().removeAnActionListener(listener);
final MessageBusConnection connection = (MessageBusConnection)panel.getClientProperty(BUS);
panel.putClientProperty(BUS, null);
if (connection != null) {
connection.disconnect();
}
LafManager.getInstance().removeLafManagerListener(listener);
}
}
示例10: initFacet
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
@Override
public void initFacet() {
MessageBusConnection connection = getModule().getMessageBus().connect(this);
connection.subscribe(PROJECT_ROOTS, new ModuleRootAdapter() {
@Override
public void rootsChanged(ModuleRootEvent event) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (!isDisposed()) {
PsiDocumentManager.getInstance(getModule().getProject()).commitAllDocuments();
updateConfiguration();
}
}
});
}
});
updateConfiguration();
}
示例11: initFacet
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
@Override
public void initFacet() {
MessageBusConnection connection = getModule().getMessageBus().connect(this);
connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
@Override
public void rootsChanged(ModuleRootEvent event) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (!isDisposed()) {
PsiDocumentManager.getInstance(getModule().getProject()).commitAllDocuments();
updateConfiguration();
}
}
});
}
});
updateConfiguration();
}
示例12: registerSyncListenerIfNecessary
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
/**
* There's a bug in the ModuleClassLoader's cache implementation, which results in crashes during preview rendering. The workaround is
* to clear the cache on each build. This registers a build complete listener to trigger the cache refresh.
*/
private void registerSyncListenerIfNecessary() {
if (myBuildCompleteListener != null) {
return;
}
myBuildCompleteListener = new GradleBuildListener() {
@Override
public void buildFinished(@NotNull Project builtProject, @Nullable BuildMode mode) {
if (mode == null || builtProject != myProject) {
return;
}
switch (mode) {
case CLEAN:
case ASSEMBLE:
case COMPILE_JAVA:
case REBUILD:
ModuleClassLoader.clearCache();
clearCache();
case SOURCE_GEN:
case ASSEMBLE_TRANSLATE:
}
}
};
MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
connection.subscribe(GRADLE_BUILD_TOPIC, myBuildCompleteListener);
}
示例13: registerAppClosing
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
/**
* Registers an callback that gets notified when the IDE is closing.
*/
private static void registerAppClosing() {
Application app = ApplicationManager.getApplication();
MessageBusConnection connection = app.getMessageBus().connect(app);
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
@Override
public void appClosing() {
try {
stopAllGradleDaemons(false);
}
catch (IOException e) {
LOG.info("Failed to stop Gradle daemons", e);
}
}
});
}
示例14: AndroidProjectTreeBuilder
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
public AndroidProjectTreeBuilder(@NotNull Project project,
@NotNull JTree tree,
@NotNull DefaultTreeModel treeModel,
@Nullable Comparator<NodeDescriptor> comparator,
@NotNull ProjectAbstractTreeStructureBase treeStructure) {
super(project, tree, treeModel, comparator, treeStructure);
MessageBusConnection connection = project.getMessageBus().connect(project);
connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
for (VFileEvent e : events) {
if (e instanceof VFileDeleteEvent) {
removeMapping(e.getFile());
}
}
}
});
}
示例15: IdeaDecompiler
import com.intellij.util.messages.MessageBusConnection; //导入依赖的package包/类
public IdeaDecompiler() {
Application app = ApplicationManager.getApplication();
myLegalNoticeAccepted = app.isUnitTestMode() || PropertiesComponent.getInstance().isValueSet(LEGAL_NOTICE_KEY);
if (!myLegalNoticeAccepted) {
MessageBusConnection connection = app.getMessageBus().connect(app);
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() {
@Override
public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
if (file.getFileType() == StdFileTypes.CLASS) {
FileEditor editor = source.getSelectedEditor(file);
if (editor instanceof TextEditor) {
CharSequence text = ((TextEditor)editor).getEditor().getDocument().getImmutableCharSequence();
if (StringUtil.startsWith(text, BANNER)) {
showLegalNotice(source.getProject(), file);
}
}
}
}
});
}
}