当前位置: 首页>>代码示例>>Java>>正文


Java MessageBusConnection类代码示例

本文整理汇总了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);
}
 
开发者ID:testmycode,项目名称:tmc-intellij,代码行数:20,代码来源:SpywareRunListener.java

示例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);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ExternalAnnotationsManagerImpl.java

示例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());
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:AutoScrollFromSourceHandler.java

示例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);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:LibraryDependentToolWindowManager.java

示例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();
    }
  });

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:EditorNotificationsImpl.java

示例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();
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:LibNotifyWrapper.java

示例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();
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:StartupManagerImpl.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:VcsEventWatcher.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:NavBarListener.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:JavaGradleFacet.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AndroidGradleFacet.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:AarResourceClassRegistry.java

示例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);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:AndroidStudioSpecificInitializer.java

示例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());
        }
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AndroidProjectTreeBuilder.java

示例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);
            }
          }
        }
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:IdeaDecompiler.java


注:本文中的com.intellij.util.messages.MessageBusConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。