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);
      }
    }
  }
 private void onRemoveGraph() {
   // i18n[graph.delGraph=Do you really wish to delete this graph?]
   Window parent = SwingUtilities.windowForComponent(_desktopPane);
   int res = JOptionPane.showConfirmDialog(parent, s_stringMgr.getString("graph.delGraph"));
   if (res == JOptionPane.YES_OPTION) {
     _listener.removeRequest();
   }
 }
 @Override
 public Dimension getSize() {
   if (myPopup != null) {
     final Window popupWindow = SwingUtilities.windowForComponent(myContent);
     return popupWindow.getSize();
   } else {
     return myForcedSize;
   }
 }
  private void onRenameGraph() {

    // i18n[graph.newName=Please enter a new name]
    Window parent = SwingUtilities.windowForComponent(_desktopPane);
    String newName = JOptionPane.showInputDialog(parent, s_stringMgr.getString("graph.newName"));
    if (null != newName && 0 != newName.trim().length()) {
      _listener.renameRequest(newName);
    }
  }
  @Override
  public void moveToFitScreen() {
    if (myPopup == null) return;

    final Window popupWindow = SwingUtilities.windowForComponent(myContent);
    Rectangle bounds = popupWindow.getBounds();

    ScreenUtil.moveRectangleToFitTheScreen(bounds);
    setLocation(bounds.getLocation());
    setSize(bounds.getSize(), false);
  }
 public static Window setSize(JComponent content, final Dimension size) {
   final Window popupWindow = SwingUtilities.windowForComponent(content);
   final Point location = popupWindow.getLocation();
   popupWindow.setLocation(location.x, location.y);
   Insets insets = content.getInsets();
   if (insets != null) {
     size.width += insets.left + insets.right;
     size.height += insets.top + insets.bottom;
   }
   content.setPreferredSize(size);
   popupWindow.pack();
   return popupWindow;
 }
Ejemplo n.º 7
0
  public void actionPerformed(ActionEvent event) {
    Window window;
    String msg;

    if (model.isZoomUndoStackEmpty()) {
      window = SwingUtilities.windowForComponent((JToolBar) toolbar);
      msg = "Zoom Undo Stack is empty";
      Dialogs.warn(window, msg);
    } else model.zoomUndo();

    // Set toolbar buttons to reflect status
    if (toolbar != null) toolbar.resetZoomButtons();

    if (Debug.isActive()) Debug.println("Action for Zoom Undo button.");
  }
  private RelativePoint relativePointByQuickSearch(final DataContext dataContext) {
    Rectangle dominantArea = PlatformDataKeys.DOMINANT_HINT_AREA_RECTANGLE.getData(dataContext);

    if (dominantArea != null) {
      final Component focusedComponent = getWndManager().getFocusedComponent(myProject);
      Window window = SwingUtilities.windowForComponent(focusedComponent);
      JLayeredPane layeredPane;
      if (window instanceof JFrame) {
        layeredPane = ((JFrame) window).getLayeredPane();
      } else if (window instanceof JDialog) {
        layeredPane = ((JDialog) window).getLayeredPane();
      } else if (window instanceof JWindow) {
        layeredPane = ((JWindow) window).getLayeredPane();
      } else {
        throw new IllegalStateException(
            "cannot find parent window: project=" + myProject + "; window=" + window);
      }

      return relativePointWithDominantRectangle(layeredPane, dominantArea);
    }

    return JBPopupFactory.getInstance().guessBestPopupLocation(dataContext);
  }
  private void onTablesDroped(DropTargetDropEvent dtde) {
    try {
      Object transferData =
          dtde.getTransferable()
              .getTransferData(dtde.getTransferable().getTransferDataFlavors()[0]);

      if (transferData instanceof ObjectTreeDndTransfer) {
        ObjectTreeDndTransfer objectTreeDndTransfer = (ObjectTreeDndTransfer) transferData;

        if (false
            == objectTreeDndTransfer.getSessionIdentifier().equals(_session.getIdentifier())) {
          JOptionPane.showMessageDialog(
              SwingUtilities.windowForComponent(_desktopPane),
              s_stringMgr.getString("GraphDesktopController.tableDropedFormOtherSession"));
          return;
        }

        _listener.tablesDropped(objectTreeDndTransfer.getSelectedTables(), dtde.getLocation());
      }

    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }