コード例 #1
0
      @Override
      public void mouseDragged(MouseEvent e) {
        if (!myDragging) return;
        MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, MyDivider.this);
        final ToolWindowAnchor anchor = myInfo.getAnchor();
        final Point point = event.getPoint();
        final Container windowPane = InternalDecorator.this.getParent();
        myLastPoint = SwingUtilities.convertPoint(MyDivider.this, point, windowPane);
        myLastPoint.x = Math.min(Math.max(myLastPoint.x, 0), windowPane.getWidth());
        myLastPoint.y = Math.min(Math.max(myLastPoint.y, 0), windowPane.getHeight());

        final Rectangle bounds = InternalDecorator.this.getBounds();
        if (anchor == ToolWindowAnchor.TOP) {
          InternalDecorator.this.setBounds(0, 0, bounds.width, myLastPoint.y);
        } else if (anchor == ToolWindowAnchor.LEFT) {
          InternalDecorator.this.setBounds(0, 0, myLastPoint.x, bounds.height);
        } else if (anchor == ToolWindowAnchor.BOTTOM) {
          InternalDecorator.this.setBounds(
              0, myLastPoint.y, bounds.width, windowPane.getHeight() - myLastPoint.y);
        } else if (anchor == ToolWindowAnchor.RIGHT) {
          InternalDecorator.this.setBounds(
              myLastPoint.x, 0, windowPane.getWidth() - myLastPoint.x, bounds.height);
        }
        InternalDecorator.this.validate();
        e.consume();
      }
コード例 #2
0
  @Override
  public void keyPressed(final KeyEvent e) {
    if (!(e.isAltDown() || e.isMetaDown() || e.isControlDown() || myPanel.isNodePopupActive())) {
      if (!Character.isLetter(e.getKeyChar())) {
        return;
      }

      final IdeFocusManager focusManager = IdeFocusManager.getInstance(myPanel.getProject());
      final ActionCallback firstCharTyped = new ActionCallback();
      focusManager.typeAheadUntil(firstCharTyped);
      myPanel.moveDown();
      //noinspection SSBasedInspection
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              try {
                final Robot robot = new Robot();
                final boolean shiftOn = e.isShiftDown();
                final int code = e.getKeyCode();
                if (shiftOn) {
                  robot.keyPress(KeyEvent.VK_SHIFT);
                }
                robot.keyPress(code);
                robot.keyRelease(code);

                // don't release Shift
                firstCharTyped.setDone();
              } catch (AWTException ignored) {
              }
            }
          });
    }
  }
コード例 #3
0
  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);
      }
    }
  }
コード例 #4
0
  public void paintComponent(Graphics g) {
    Icon icon = getIcon();
    FontMetrics fm = getFontMetrics(getFont());
    Rectangle viewRect = new Rectangle(getSize());
    JBInsets.removeFrom(viewRect, getInsets());

    Rectangle iconRect = new Rectangle();
    Rectangle textRect = new Rectangle();
    String text =
        SwingUtilities.layoutCompoundLabel(
            this,
            fm,
            getText(),
            icon,
            SwingConstants.CENTER,
            horizontalTextAlignment(),
            SwingConstants.CENTER,
            horizontalTextPosition(),
            viewRect,
            iconRect,
            textRect,
            iconTextSpace());
    ActionButtonLook look = ActionButtonLook.IDEA_LOOK;
    look.paintBackground(g, this);
    look.paintIconAt(g, this, icon, iconRect.x, iconRect.y);
    look.paintBorder(g, this);

    UISettings.setupAntialiasing(g);
    g.setColor(isButtonEnabled() ? getForeground() : getInactiveTextColor());
    SwingUtilities2.drawStringUnderlineCharAt(
        this, g, text, getMnemonicCharIndex(text), textRect.x, textRect.y + fm.getAscent());
  }
コード例 #5
0
  public void focusLost(final FocusEvent e) {
    if (myPanel.getProject().isDisposed()) {
      myPanel.setContextComponent(null);
      myPanel.hideHint();
      return;
    }
    final DialogWrapper dialog = DialogWrapper.findInstance(e.getOppositeComponent());
    shouldFocusEditor = dialog != null;
    if (dialog != null) {
      Disposer.register(
          dialog.getDisposable(),
          new Disposable() {
            @Override
            public void dispose() {
              if (dialog.getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) {
                shouldFocusEditor = false;
              }
            }
          });
    }

    // required invokeLater since in current call sequence KeyboardFocusManager is not initialized
    // yet
    // but future focused component
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            processFocusLost(e);
          }
        });
  }
コード例 #6
0
  private void setDataInternal(
      SmartPsiElementPointer element, String text, final Rectangle viewRect, boolean skip) {
    boolean justShown = false;

    myElement = element;

    if (!myIsShown && myHint != null) {
      myEditorPane.setText(text);
      applyFontSize();
      myManager.showHint(myHint);
      myIsShown = justShown = true;
    }

    if (!justShown) {
      myEditorPane.setText(text);
      applyFontSize();
    }

    if (!skip) {
      myText = text;
    }

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            myEditorPane.scrollRectToVisible(viewRect);
          }
        });
  }
コード例 #7
0
 /**
  * @param component component
  * @return whether the component in Swing tree or not. This method is more weak then {@link
  *     Component#isShowing() }
  */
 private boolean isInTree(final Component component) {
   if (component instanceof Window) {
     return component.isShowing();
   } else {
     Window windowAncestor = SwingUtilities.getWindowAncestor(component);
     return windowAncestor != null && windowAncestor.isShowing();
   }
 }
コード例 #8
0
 // Event forwarding. We need it if user does press-and-drag gesture for opening popup and
 // choosing item there.
 // It works in JComboBox, here we provide the same behavior
 private void dispatchEventToPopup(MouseEvent e) {
   if (myPopup != null && myPopup.isVisible()) {
     JComponent content = myPopup.getContent();
     Rectangle rectangle = content.getBounds();
     Point location = rectangle.getLocation();
     SwingUtilities.convertPointToScreen(location, content);
     Point eventPoint = e.getLocationOnScreen();
     rectangle.setLocation(location);
     if (rectangle.contains(eventPoint)) {
       MouseEvent event =
           SwingUtilities.convertMouseEvent(e.getComponent(), e, myPopup.getContent());
       Component component =
           SwingUtilities.getDeepestComponentAt(content, event.getX(), event.getY());
       if (component != null) component.dispatchEvent(event);
     }
   }
 }
コード例 #9
0
 public final void update() {
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           doUpdate();
         }
       });
 }
コード例 #10
0
  private void updateMnemonic(int lastMnemonic, int mnemonic) {
    if (mnemonic == lastMnemonic) {
      return;
    }
    InputMap windowInputMap = SwingUtilities.getUIInputMap(this, JComponent.WHEN_IN_FOCUSED_WINDOW);

    int mask = SystemInfo.isMac ? InputEvent.ALT_MASK | InputEvent.CTRL_MASK : InputEvent.ALT_MASK;
    if (lastMnemonic != 0 && windowInputMap != null) {
      windowInputMap.remove(KeyStroke.getKeyStroke(lastMnemonic, mask, false));
    }
    if (mnemonic != 0) {
      if (windowInputMap == null) {
        windowInputMap = new ComponentInputMapUIResource(this);
        SwingUtilities.replaceUIInputMap(this, JComponent.WHEN_IN_FOCUSED_WINDOW, windowInputMap);
      }
      windowInputMap.put(KeyStroke.getKeyStroke(mnemonic, mask, false), "doClick");
    }
  }
コード例 #11
0
 public static void enableAction(final AnActionEvent event, final boolean enable) {
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           event.getPresentation().setEnabled(enable);
           event.getPresentation().setVisible(true);
         }
       });
 }
コード例 #12
0
  public boolean isFocused() {
    IdeFocusManager fm = IdeFocusManager.getInstance(myProject);
    Component component = fm.getFocusedDescendantFor(myToolWindow.getComponent());
    if (component != null) return true;

    Component owner = fm.getLastFocusedFor(WindowManager.getInstance().getIdeFrame(myProject));

    return owner != null && SwingUtilities.isDescendingFrom(owner, myToolWindow.getComponent());
  }
コード例 #13
0
 private void startEditingAtSelection() {
   myTable.editCellAt(myTable.getSelectedRow(), 2);
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           if (myTable.isEditing()) {
             myTable.getEditorComponent().requestFocus();
           }
         }
       });
 }
コード例 #14
0
  void buildFinished(
      boolean isProgressAborted,
      long buildTimeInMilliseconds,
      @NotNull final AntBuildListener antBuildListener,
      OutputPacketProcessor dispatcher) {
    final boolean aborted = isProgressAborted || myIsAborted;
    final String message = getFinishStatusText(aborted, buildTimeInMilliseconds);

    dispatcher.processOutput(
        new Printable() {
          @Override
          public void printOn(Printer printer) {
            if (!myProject.isDisposed()) { // if not disposed
              addCommand(new FinishBuildCommand(message));
              final StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
              if (statusBar != null) {
                statusBar.setInfo(message);
              }
            }
          }
        });
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            if (!myIsOutputPaused) {
              new OutputFlusher().doFlush();
            }
            final AntBuildFileBase buildFile = myBuildFile;
            if (buildFile != null) {
              if (getErrorCount() == 0 && buildFile.isViewClosedWhenNoErrors()) {
                close();
              } else if (getErrorCount() > 0) {
                myTreeView.scrollToFirstError();
              } else {
                myTreeView.scrollToStatus();
              }
            } else {
              myTreeView.scrollToLastMessage();
            }
            VirtualFileManager.getInstance()
                .asyncRefresh(
                    new Runnable() {
                      public void run() {
                        antBuildListener.buildFinished(
                            aborted
                                ? AntBuildListener.ABORTED
                                : AntBuildListener.FINISHED_SUCCESSFULLY,
                            getErrorCount());
                      }
                    });
          }
        });
  }
コード例 #15
0
 private boolean fitsInBounds(final Rectangle rect) {
   final Container container = getParent();
   if (container instanceof JViewport) {
     final Container scrollPane = container.getParent();
     if (scrollPane instanceof JScrollPane) {
       final Rectangle rectangle =
           SwingUtilities.convertRectangle(this, rect, scrollPane.getParent());
       return scrollPane.getBounds().contains(rectangle);
     }
   }
   return true;
 }
コード例 #16
0
  private void setSizeAndDimensions(
      @NotNull JTable table,
      @NotNull JBPopup popup,
      @NotNull RelativePoint popupPosition,
      @NotNull List<UsageNode> data) {
    JComponent content = popup.getContent();
    Window window = SwingUtilities.windowForComponent(content);
    Dimension d = window.getSize();

    int width = calcMaxWidth(table);
    width = (int) Math.max(d.getWidth(), width);
    Dimension headerSize = ((AbstractPopup) popup).getHeaderPreferredSize();
    width = Math.max((int) headerSize.getWidth(), width);
    width = Math.max(myWidth, width);

    if (myWidth == -1) myWidth = width;
    int newWidth = Math.max(width, d.width + width - myWidth);

    myWidth = newWidth;

    int rowsToShow = Math.min(30, data.size());
    Dimension dimension = new Dimension(newWidth, table.getRowHeight() * rowsToShow);
    Rectangle rectangle = fitToScreen(dimension, popupPosition, table);
    dimension = rectangle.getSize();
    Point location = window.getLocation();
    if (!location.equals(rectangle.getLocation())) {
      window.setLocation(rectangle.getLocation());
    }

    if (!data.isEmpty()) {
      TableScrollingUtil.ensureSelectionExists(table);
    }
    table.setSize(dimension);
    // table.setPreferredSize(dimension);
    // table.setMaximumSize(dimension);
    // table.setPreferredScrollableViewportSize(dimension);

    Dimension footerSize = ((AbstractPopup) popup).getFooterPreferredSize();

    int newHeight =
        (int) (dimension.height + headerSize.getHeight() + footerSize.getHeight())
            + 4 /* invisible borders, margins etc*/;
    Dimension newDim = new Dimension(dimension.width, newHeight);
    window.setSize(newDim);
    window.setMinimumSize(newDim);
    window.setMaximumSize(newDim);

    window.validate();
    window.repaint();
    table.revalidate();
    table.repaint();
  }
コード例 #17
0
 @TestOnly
 public static void dispatchAllInvocationEventsInIdeEventQueue() throws InterruptedException {
   assert SwingUtilities.isEventDispatchThread() : Thread.currentThread();
   final EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
   while (true) {
     AWTEvent event = eventQueue.peekEvent();
     if (event == null) break;
     AWTEvent event1 = eventQueue.getNextEvent();
     if (event1 instanceof InvocationEvent) {
       IdeEventQueue.getInstance().dispatchEvent(event1);
     }
   }
 }
コード例 #18
0
 private void treeSelectionChanged() {
   SwingUtilities.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           if (isDisposed) return;
           List<UsageInfo> infos = getSelectedUsageInfos();
           if (infos != null && myUsagePreviewPanel != null) {
             myUsagePreviewPanel.updateLayout(infos);
           }
         }
       });
 }
コード例 #19
0
 public void removeProgressPanel() {
   if (myProgressPanel != null) {
     myMessagePanel.remove(myProgressPanel);
     // fix of 9377
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             myMessagePanel.validate();
           }
         });
     myProgressPanel = null;
   }
 }
コード例 #20
0
 private void setToComponent(final JComponent cmp, final boolean requestFocus) {
   myMatchingCountPanel.removeAll();
   myMatchingCountPanel.add(cmp, BorderLayout.CENTER);
   myMatchingCountPanel.revalidate();
   myMatchingCountPanel.repaint();
   if (requestFocus) {
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             myPatternField.getTextField().requestFocusInWindow();
           }
         });
   }
 }
コード例 #21
0
 @Nullable
 public RelativePoint getHyperlinkLocation(HyperlinkInfo info) {
   Editor editor = myLogEditor.getValue();
   Project project = editor.getProject();
   RangeHighlighter range = myHyperlinkSupport.getValue().findHyperlinkRange(info);
   Window window = NotificationsManagerImpl.findWindowForBalloon(project);
   if (range != null && window != null) {
     Point point =
         editor.visualPositionToXY(editor.offsetToVisualPosition(range.getStartOffset()));
     return new RelativePoint(
         window, SwingUtilities.convertPoint(editor.getContentComponent(), point, window));
   }
   return null;
 }
コード例 #22
0
      @Override
      public void windowActivated(final WindowEvent e) {
        SwingUtilities.invokeLater(
            new Runnable() {
              @Override
              public void run() {
                final DialogWrapper wrapper = getActiveWrapper();
                if (wrapper == null && !myFocusedCallback.isProcessed()) {
                  myFocusedCallback.setRejected();
                  myTypeAheadDone.setRejected();
                  return;
                }

                if (myActivated) {
                  return;
                }
                myActivated = true;
                JComponent toFocus =
                    wrapper == null ? null : wrapper.getPreferredFocusedComponent();
                if (toFocus == null) {
                  toFocus = getRootPane().getDefaultButton();
                }

                moveMousePointerOnButton(getRootPane().getDefaultButton());
                setupSelectionOnPreferredComponent(toFocus);

                if (toFocus != null) {
                  final JComponent toRequest = toFocus;
                  SwingUtilities.invokeLater(
                      new Runnable() {
                        @Override
                        public void run() {
                          if (isShowing() && isActive()) {
                            getFocusManager().requestFocus(toRequest, true);
                            notifyFocused(wrapper);
                          }
                        }
                      });
                } else {
                  if (isShowing()) {
                    notifyFocused(wrapper);
                  }
                }
                if (myTypeAheadCallback != null) {
                  myTypeAheadCallback.setDone();
                }
              }
            });
      }
コード例 #23
0
 @Override
 public void windowOpened(WindowEvent e) {
   SwingUtilities.invokeLater(
       new Runnable() {
         @Override
         public void run() {
           myOpened = true;
           final DialogWrapper activeWrapper = getActiveWrapper();
           if (activeWrapper == null) {
             myFocusedCallback.setRejected();
             myTypeAheadDone.setRejected();
           }
         }
       });
 }
コード例 #24
0
    public void run(@NotNull final ProgressIndicator indicator) {
      final SvnVcs17 vcs = SvnVcs17.getInstance(myProject);
      final SVNWCClient client = vcs.createWCClient();

      try {
        myBeforeRevisionValue = getBeforeRevisionValue(myChange, vcs);
        myAfterRevision = getAfterRevisionValue(myChange, vcs);

        myBeforeContent =
            getPropertyList(myChange.getBeforeRevision(), myBeforeRevisionValue, client);
        indicator.checkCanceled();
        // gets exactly WORKING revision property
        myAfterContent = getPropertyList(myChange.getAfterRevision(), myAfterRevision, client);
      } catch (SVNException exc) {
        myException = exc;
      }

      // since sometimes called from modal dialog (commit changes dialog)
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              if (myException != null) {
                Messages.showErrorDialog(myException.getMessage(), myErrorTitle);
                return;
              }
              if (myBeforeContent != null
                  && myAfterContent != null
                  && myBeforeRevisionValue != null
                  && myAfterRevision != null) {
                final SimpleDiffRequest diffRequest =
                    new SimpleDiffRequest(myProject, getDiffWindowTitle(myChange));
                if (compareRevisions(myBeforeRevisionValue, myAfterRevision) >= 0) {
                  // before ahead
                  diffRequest.setContents(
                      new SimpleContent(myAfterContent), new SimpleContent(myBeforeContent));
                  diffRequest.setContentTitles(
                      revisionToString(myAfterRevision), revisionToString(myBeforeRevisionValue));
                } else {
                  diffRequest.setContents(
                      new SimpleContent(myBeforeContent), new SimpleContent(myAfterContent));
                  diffRequest.setContentTitles(
                      revisionToString(myBeforeRevisionValue), revisionToString(myAfterRevision));
                }
                DiffManager.getInstance().getDiffTool().show(diffRequest);
              }
            }
          });
    }
コード例 #25
0
    @Override
    public void propertyChange(PropertyChangeEvent e) {
      boolean queueForDispose = getParent() == null;

      String name = e.getPropertyName();
      if (mySynchronized.contains(name)) return;

      mySynchronized.add(name);

      try {
        if (Presentation.PROP_VISIBLE.equals(name)) {
          final boolean visible = myPresentation.isVisible();
          if (!visible && SystemInfo.isMacSystemMenu && myPlace.equals(ActionPlaces.MAIN_MENU)) {
            setEnabled(false);
          } else {
            setVisible(visible);
          }
        } else if (Presentation.PROP_ENABLED.equals(name)) {
          setEnabled(myPresentation.isEnabled());
          updateIcon(myAction.getAction());
        } else if (Presentation.PROP_MNEMONIC_KEY.equals(name)) {
          setMnemonic(myPresentation.getMnemonic());
        } else if (Presentation.PROP_MNEMONIC_INDEX.equals(name)) {
          setDisplayedMnemonicIndex(myPresentation.getDisplayedMnemonicIndex());
        } else if (Presentation.PROP_TEXT.equals(name)) {
          setText(myPresentation.getText());
        } else if (Presentation.PROP_ICON.equals(name)
            || Presentation.PROP_DISABLED_ICON.equals(name)
            || SELECTED.equals(name)) {
          updateIcon(myAction.getAction());
        }
      } finally {
        mySynchronized.remove(name);
        if (queueForDispose) {
          // later since we cannot remove property listeners inside event processing
          //noinspection SSBasedInspection
          SwingUtilities.invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  if (getParent() == null) {
                    uninstallSynchronizer();
                  }
                }
              });
        }
      }
    }
コード例 #26
0
  @Nullable
  private ToolWindow getWindow(AnActionEvent event) {
    if (myWindow != null) return myWindow;

    Project project = CommonDataKeys.PROJECT.getData(event.getDataContext());
    if (project == null) return null;

    ToolWindowManager manager = ToolWindowManager.getInstance(project);

    final ToolWindow window = manager.getToolWindow(manager.getActiveToolWindowId());
    if (window == null) return null;

    final Component context = PlatformDataKeys.CONTEXT_COMPONENT.getData(event.getDataContext());
    if (context == null) return null;

    return SwingUtilities.isDescendingFrom(window.getComponent(), context) ? window : null;
  }
コード例 #27
0
 private void updateListsInChooser() {
   Runnable runnable =
       new Runnable() {
         public void run() {
           if (myChangeListChooser != null && myShowingAllChangeLists) {
             myChangeListChooser.updateLists(
                 ChangeListManager.getInstance(myProject).getChangeListsCopy());
           }
         }
       };
   if (SwingUtilities.isEventDispatchThread()) {
     runnable.run();
   } else {
     ApplicationManager.getApplication()
         .invokeLater(runnable, ModalityState.stateForComponent(this));
   }
 }
コード例 #28
0
  private void reset() {
    ApplicationManager.getApplication().assertIsDispatchThread();

    myUsageNodes.clear();
    myIsFirstVisibleUsageFound = false;

    myModel.reset();
    if (!myPresentation.isDetachedMode()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              if (isDisposed) return;
              TreeUtil.expand(myTree, 2);
            }
          });
    }
  }
コード例 #29
0
  /**
   * @return <code>true</code> if and only if the <code>component</code> represents modal context.
   * @throws IllegalArgumentException if <code>component</code> is <code>null</code>.
   */
  public static boolean isModalContext(@NotNull Component component) {
    Window window;
    if (component instanceof Window) {
      window = (Window) component;
    } else {
      window = SwingUtilities.getWindowAncestor(component);
    }

    if (window instanceof IdeFrameImpl) {
      final Component pane = ((IdeFrameImpl) window).getGlassPane();
      if (pane instanceof IdeGlassPaneEx) {
        return ((IdeGlassPaneEx) pane).isInModalContext();
      }
    }

    if (window instanceof JDialog) {
      final JDialog dialog = (JDialog) window;
      if (!dialog.isModal()) {
        final Window owner = dialog.getOwner();
        return owner != null && isModalContext(owner);
      }
    }

    if (window instanceof JFrame) {
      return false;
    }

    boolean isMainFrame = window instanceof IdeFrameImpl;
    boolean isFloatingDecorator = window instanceof FloatingDecorator;

    boolean isPopup = !(component instanceof JFrame) && !(component instanceof JDialog);
    if (isPopup) {
      if (component instanceof JWindow) {
        JBPopup popup =
            (JBPopup) ((JWindow) component).getRootPane().getClientProperty(JBPopup.KEY);
        if (popup != null) {
          return popup.isModalContext();
        }
      }
    }

    return !isMainFrame && !isFloatingDecorator;
  }
コード例 #30
0
  @Nullable
  private static Container getContainer(@Nullable final Component focusOwner) {
    if (focusOwner == null) return null;
    if (focusOwner.isLightweight()) {
      Container container = focusOwner.getParent();
      while (container != null) {
        final Container parent = container.getParent();
        if (parent instanceof JLayeredPane) break;
        if (parent != null && parent.isLightweight()) {
          container = parent;
        } else {
          break;
        }
      }
      return container;
    }

    return SwingUtilities.windowForComponent(focusOwner);
  }