static void subscribeTo(NavBarPanel panel) {
    if (panel.getClientProperty(LISTENER) != null) {
      unsubscribeFrom(panel);
    }

    final NavBarListener listener = new NavBarListener(panel);
    final Project project = panel.getProject();
    panel.putClientProperty(LISTENER, listener);
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(listener);
    FileStatusManager.getInstance(project).addFileStatusListener(listener);
    PsiManager.getInstance(project).addPsiTreeChangeListener(listener);
    WolfTheProblemSolver.getInstance(project).addProblemListener(listener);
    ActionManager.getInstance().addAnActionListener(listener);

    final MessageBusConnection connection = project.getMessageBus().connect();
    connection.subscribe(ProjectTopics.PROJECT_ROOTS, listener);
    connection.subscribe(NavBarModelListener.NAV_BAR, listener);
    connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);
    panel.putClientProperty(BUS, connection);
    panel.addKeyListener(listener);

    if (panel.isInFloatingMode()) {
      final Window window = SwingUtilities.windowForComponent(panel);
      if (window != null) {
        window.addWindowFocusListener(listener);
      }
    }
  }
예제 #2
0
 void installActivateListener() {
   // FIXME: should watch for hierarchy changes
   Window toplevel = getTopLevel(target);
   if (toplevel != null) {
     toplevel.addWindowFocusListener(this);
     applicationActive = toplevel.isFocused();
   }
 }
예제 #3
0
 private void addListener(final Window container) {
   container.addWindowFocusListener(
       new WindowAdapter() {
         public void windowLostFocus(WindowEvent evt) {
           container.setVisible(false);
         }
       });
   container.pack();
 }