Example #1
0
  private void processParentWindowMoved() {
    if (isDisposed()) return;

    final Point newOwnerPoint = myOwnerWindow.getLocationOnScreen();

    int deltaX = myLastOwnerPoint.x - newOwnerPoint.x;
    int deltaY = myLastOwnerPoint.y - newOwnerPoint.y;

    myLastOwnerPoint = newOwnerPoint;

    final Window wnd = SwingUtilities.getWindowAncestor(getContent());
    final Point current = wnd.getLocationOnScreen();

    setLocation(new Point(current.x - deltaX, current.y - deltaY));
  }
Example #2
0
 private void registerAutoMove() {
   if (myOwner != null) {
     myOwnerWindow = SwingUtilities.getWindowAncestor(myOwner);
     if (myOwnerWindow != null) {
       myLastOwnerPoint = myOwnerWindow.getLocationOnScreen();
       myOwnerListener = new MyComponentAdapter();
       myOwnerWindow.addComponentListener(myOwnerListener);
     }
   }
 }
  public static void dumpRedsFromImage(Window w) {
    Point offset = w.getLocationOnScreen();

    System.err.println("");
    System.err.println("");
    System.err.println("");

    for (int y = 0; y < w.getHeight(); y++) {
      System.err.print("  ");
      for (int x = 0; x < w.getWidth(); x++) {
        Color rgb = kRobot.getPixelColor(offset.x + x, offset.y + y);
        int r = rgb.getRed();
        String c = (r == 0xff ? "X" : (r == 0 ? "." : "?"));
        System.err.print(c + " ");
        // System.err.print( r + " ");
      }
      System.err.println("");
    }
  }
  private void manageSearchPopup(@Nullable SearchPopup searchPopup) {
    final Project project;
    if (ApplicationManager.getApplication() != null
        && !ApplicationManager.getApplication().isDisposed()) {
      project =
          PlatformDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myComponent));
    } else {
      project = null;
    }

    if (mySearchPopup != null) {
      myPopupLayeredPane.remove(mySearchPopup);
      myPopupLayeredPane.validate();
      myPopupLayeredPane.repaint();
      myPopupLayeredPane = null;

      if (project != null) {
        ((ToolWindowManagerEx) ToolWindowManager.getInstance(project))
            .removeToolWindowManagerListener(myWindowManagerListener);
      }
    } else if (searchPopup != null) {
      FeatureUsageTracker.getInstance().triggerFeatureUsed("ui.tree.speedsearch");
    }

    if (!myComponent.isShowing()) {
      mySearchPopup = null;
    } else {
      mySearchPopup = searchPopup;
    }

    fireStateChanged();

    if (mySearchPopup == null || !myComponent.isDisplayable()) return;

    if (project != null) {
      ((ToolWindowManagerEx) ToolWindowManager.getInstance(project))
          .addToolWindowManagerListener(myWindowManagerListener);
    }
    JRootPane rootPane = myComponent.getRootPane();
    if (rootPane != null) {
      myPopupLayeredPane = rootPane.getLayeredPane();
    } else {
      myPopupLayeredPane = null;
    }
    if (myPopupLayeredPane == null) {
      LOG.error(toString() + " in " + String.valueOf(myComponent));
      return;
    }
    myPopupLayeredPane.add(mySearchPopup, JLayeredPane.POPUP_LAYER);
    if (myPopupLayeredPane == null) return; // See # 27482. Somewho it does happen...
    Point lPaneP = myPopupLayeredPane.getLocationOnScreen();
    Point componentP = getComponentLocationOnScreen();
    Rectangle r = getComponentVisibleRect();
    Dimension prefSize = mySearchPopup.getPreferredSize();
    Window window = (Window) SwingUtilities.getAncestorOfClass(Window.class, myComponent);
    Point windowP;
    if (window instanceof JDialog) {
      windowP = ((JDialog) window).getContentPane().getLocationOnScreen();
    } else if (window instanceof JFrame) {
      windowP = ((JFrame) window).getContentPane().getLocationOnScreen();
    } else {
      windowP = window.getLocationOnScreen();
    }
    int y = r.y + componentP.y - lPaneP.y - prefSize.height;
    y = Math.max(y, windowP.y - lPaneP.y);
    mySearchPopup.setLocation(componentP.x - lPaneP.x + r.x, y);
    mySearchPopup.setSize(prefSize);
    mySearchPopup.setVisible(true);
    mySearchPopup.validate();
  }