예제 #1
0
 public void actionPerformed(ActionEvent e) {
   KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
   Container container = kfm.getCurrentFocusCycleRoot();
   FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
   if (null == policy) policy = kfm.getDefaultFocusTraversalPolicy();
   Component next =
       moveDown
           ? policy.getComponentAfter(container, PaletteGroupHeader.this)
           : policy.getComponentBefore(container, PaletteGroupHeader.this);
   if (null != next && next instanceof PaletteComponentList) {
     final PaletteComponentList list = (PaletteComponentList) next;
     if (list.getModel().getSize() != 0) {
       list.takeFocusFrom(PaletteGroupHeader.this, list == myComponentList ? 0 : -1);
       return;
     } else {
       next =
           moveDown
               ? policy.getComponentAfter(container, next)
               : policy.getComponentBefore(container, next);
     }
   }
   if (null != next && next instanceof PaletteGroupHeader) {
     next.requestFocus();
   }
 }
  public boolean editCellAt(int index, EventObject e) {
    if (editor != null && !editor.stopCellEditing()) return false;

    if (index < 0 || index >= getModel().getSize()) return false;

    if (!isCellEditable(index)) return false;

    if (editorRemover == null) {
      KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
      editorRemover = new CellEditorRemover(fm);
      fm.addPropertyChangeListener("permanentFocusOwner", editorRemover); // NOI18N
    }

    if (editor != null && editor.isCellEditable(e)) {
      editorComp = prepareEditor(index);
      if (editorComp == null) {
        removeEditor();
        return false;
      }
      editorComp.setBounds(getCellBounds(index, index));
      add(editorComp);
      editorComp.validate();

      editingIndex = index;
      editor.addCellEditorListener(this);

      return true;
    }
    return false;
  }
예제 #3
0
 @Override
 public void actionPerformed(ActionEvent evt) {
   switch (command) {
     case TAB_OUT_FORWARD:
       KeyboardFocusManager.getCurrentKeyboardFocusManager().focusNextComponent();
       break;
     case TAB_OUT_BACK:
       KeyboardFocusManager.getCurrentKeyboardFocusManager().focusPreviousComponent();
       break;
     case EDIT_PLUGIN:
       int[] rows = table.getSelectedRows();
       Object[] state = new Object[rows.length];
       for (int i = 0; i < rows.length; i++) {
         state[i] = pluginModel.getValueAt(rows[i], 0);
       }
       for (int i = 0; i < rows.length; i++) {
         pluginModel.setValueAt(state[i].equals(Boolean.FALSE), rows[i], 0);
       }
       break;
     case CLOSE_PLUGIN_MANAGER:
       window.ok();
       break;
     default:
       throw new InternalError();
   }
 }
예제 #4
0
  void test3(Window owner, Window child1, Window child2) {
    System.out.println("* * * STAGE 3 * * *\nWidow owner: " + owner);

    owner.setFocusableWindowState(true);
    owner.setVisible(true);

    child1.setFocusableWindowState(false);
    child1.setVisible(true);

    child2.setFocusableWindowState(true);
    child2.add(button);
    child2.setVisible(true);

    Util.waitTillShown(child2);

    Util.clickOnComp(button, robot);
    System.err.println(
        "focus owner: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
    if (button != KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) {
      throw new RuntimeException("Test failed.");
    }
    child1.dispose();
    child2.dispose();
    owner.dispose();
  }
  private void tabBackward() {
    final KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    manager.focusPreviousComponent();

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            if (manager.getFocusOwner() instanceof JScrollBar) manager.focusPreviousComponent();
          }
        });
  }
  /*
   *  Create using the specified focus policy
   */
  public TabFocusHandler(JTabbedPane tabbedPane, int focusPolicy) {
    if (focusPolicy != RESET_FOCUS && focusPolicy != RETAIN_FOCUS)
      throw new IllegalArgumentException("Invalid focus policy");

    this.tabbedPane = tabbedPane;
    this.focusPolicy = focusPolicy;

    //  Add listeners to manage a tab change

    tabbedPane.addChangeListener(this);
    KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    focusManager.addPropertyChangeListener("permanentFocusOwner", this);
  }
예제 #7
0
  /*
   * The method maps the list of the active windows to the window's AppContext,
   * then the method registers ActiveWindowListener, GuiDisposedListener listeners;
   * it executes the initilialization only once per AppContext.
   */
  @SuppressWarnings("unchecked")
  private static void initActiveWindowsTracking(Window w) {
    AppContext appContext = AppContext.getAppContext();
    synchronized (appContext) {
      List<WWindowPeer> l = (List<WWindowPeer>) appContext.get(ACTIVE_WINDOWS_KEY);
      if (l == null) {
        l = new LinkedList<WWindowPeer>();
        appContext.put(ACTIVE_WINDOWS_KEY, l);
        appContext.addPropertyChangeListener(AppContext.GUI_DISPOSED, guiDisposedListener);

        KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        kfm.addPropertyChangeListener("activeWindow", activeWindowListener);
      }
    }
  }
예제 #8
0
    public void propertyChange(PropertyChangeEvent e) {
      boolean isDisposed = (Boolean) e.getNewValue();
      if (isDisposed != true) {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
          log.fine(" Assertion (newValue != true) failed for AppContext.GUI_DISPOSED ");
        }
      }
      AppContext appContext = AppContext.getAppContext();
      synchronized (appContext) {
        appContext.remove(ACTIVE_WINDOWS_KEY);
        appContext.removePropertyChangeListener(AppContext.GUI_DISPOSED, this);

        KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
        kfm.removePropertyChangeListener("activeWindow", activeWindowListener);
      }
    }
예제 #9
0
  /**
   * Creates a swing applet instance.
   *
   * <p>This constructor sets the component's locale property to the value returned by <code>
   * JComponent.getDefaultLocale</code>.
   *
   * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true.
   * @see java.awt.GraphicsEnvironment#isHeadless
   * @see JComponent#getDefaultLocale
   */
  public JApplet() throws HeadlessException {
    super();
    // Check the timerQ and restart if necessary.
    TimerQueue q = TimerQueue.sharedInstance();
    if (q != null) {
      synchronized (q) {
        if (!q.running) q.start();
      }
    }

    /* Workaround for bug 4155072.  The shared double buffer image
     * may hang on to a reference to this applet; unfortunately
     * Image.getGraphics() will continue to call JApplet.getForeground()
     * and getBackground() even after this applet has been destroyed.
     * So we ensure that these properties are non-null here.
     */
    setForeground(Color.black);
    setBackground(Color.white);

    setLocale(JComponent.getDefaultLocale());
    setLayout(new BorderLayout());
    setRootPane(createRootPane());
    setRootPaneCheckingEnabled(true);

    // This code should be changed after the RFE 4719336 is resolved
    // to not make the applet a FocusCycleRoot, but set it's
    // FocusTraversalPolicy only.
    setFocusCycleRoot(true);
    setFocusTraversalPolicy(
        KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalPolicy());

    enableEvents(AWTEvent.KEY_EVENT_MASK);
  }
  public static boolean isFocused(@Nullable Component[] components) {
    if (components == null) return false;

    Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();

    if (owner == null) return false;

    Window wnd;
    if (owner instanceof Window) {
      wnd = (Window) owner;
    } else {
      wnd = SwingUtilities.getWindowAncestor(owner);
    }

    for (Component each : components) {
      if (each != null && SwingUtilities.isDescendingFrom(owner, each)) {
        Window eachWindow =
            each instanceof Window ? (Window) each : SwingUtilities.getWindowAncestor(each);
        if (eachWindow == wnd) {
          return true;
        }
      }
    }

    return false;
  }
  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);
      }
    }
  }
예제 #12
0
 /**
  * Because there may be many AppContexts, and we can't be sure where this EmbeddedFrame is first
  * created or shown, we can't automatically determine the correct KeyboardFocusManager to attach
  * to as KeyEventDispatcher. Those who want to use the functionality of traversing out of the
  * EmbeddedFrame must call this method on the Applet's AppContext. After that, all the changes can
  * be handled automatically, including possible replacement of KeyboardFocusManager.
  */
 public void registerListeners() {
   if (appletKFM != null) {
     removeTraversingOutListeners(appletKFM);
   }
   appletKFM = KeyboardFocusManager.getCurrentKeyboardFocusManager();
   if (isVisible()) {
     addTraversingOutListeners(appletKFM);
   }
 }
예제 #13
0
  /*
   * Requests platform to set native focus on a frame/dialog.
   * In case of a simple window, triggers appropriate java focus change.
   */
  public boolean requestWindowFocus(CausedFocusEvent.Cause cause) {
    if (focusLog.isLoggable(PlatformLogger.FINE)) {
      focusLog.fine("requesting native focus to " + this);
    }

    if (!focusAllowedFor()) {
      focusLog.fine("focus is not allowed");
      return false;
    }

    if (platformWindow.rejectFocusRequest(cause)) {
      return false;
    }

    Window currentActive = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();

    Window opposite = LWKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow();

    // Make the owner active window.
    if (isSimpleWindow()) {
      LWWindowPeer owner = getOwnerFrameDialog(this);

      // If owner is not natively active, request native
      // activation on it w/o sending events up to java.
      if (owner != null && !owner.platformWindow.isActive()) {
        if (focusLog.isLoggable(PlatformLogger.FINE)) {
          focusLog.fine("requesting native focus to the owner " + owner);
        }
        LWWindowPeer currentActivePeer =
            (currentActive != null ? (LWWindowPeer) currentActive.getPeer() : null);

        // Ensure the opposite is natively active and suppress sending events.
        if (currentActivePeer != null && currentActivePeer.platformWindow.isActive()) {
          if (focusLog.isLoggable(PlatformLogger.FINE)) {
            focusLog.fine("the opposite is " + currentActivePeer);
          }
          currentActivePeer.skipNextFocusChange = true;
        }
        owner.skipNextFocusChange = true;

        owner.platformWindow.requestWindowFocus();
      }

      // DKFM will synthesize all the focus/activation events correctly.
      changeFocusedWindow(true, opposite);
      return true;

      // In case the toplevel is active but not focused, change focus directly,
      // as requesting native focus on it will not have effect.
    } else if (getTarget() == currentActive && !getTarget().hasFocus()) {

      changeFocusedWindow(true, opposite);
      return true;
    }

    return platformWindow.requestWindowFocus();
  }
예제 #14
0
 public void actionPerformed(ActionEvent evt) {
   Component focusOwner =
       KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
   if (focusOwner != null) {
     if (focusOwner instanceof EditableComponent) {
       ((EditableComponent) focusOwner).duplicate();
     } else {
       focusOwner.getToolkit().beep();
     }
   }
 }
예제 #15
0
    @Override
    public Dimension getPreferredSize() {
      final Component focusOwner =
          KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
      Point p = null;
      if (focusOwner != null && focusOwner.isShowing()) {
        p = focusOwner.getLocationOnScreen();
      }

      return computeNotBiggerDimension(super.getPreferredSize().getSize(), p);
    }
 @Override
 public void actionPerformed(ActionEvent evt) {
   JComponent c = target;
   if (c == null
       && (KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner()
           instanceof JComponent)) {
     c =
         (JComponent)
             KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
   }
   if (c != null && c.isEnabled()) {
     if (c instanceof EditableComponent) {
       ((EditableComponent) c).clearSelection();
     } else if (c instanceof JTextComponent) {
       JTextComponent tc = ((JTextComponent) c);
       tc.select(tc.getSelectionStart(), tc.getSelectionStart());
     } else {
       c.getToolkit().beep();
     }
   }
 }
예제 #17
0
 @FeatureEntryPoint(JHotDrawFeatures.BASIC_EDITING)
 public void actionPerformed(ActionEvent evt) {
   Component focusOwner =
       KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
   if (focusOwner != null && focusOwner instanceof JComponent) {
     JComponent component = (JComponent) focusOwner;
     component
         .getTransferHandler()
         .exportToClipboard(
             component, component.getToolkit().getSystemClipboard(), TransferHandler.MOVE);
   }
 }
예제 #18
0
  private void processDrag(final MouseEvent e) {
    if (myDragCancelled) return;
    if (!isDraggingNow()) {
      if (myPressedPoint == null) return;
      if (isWithinDeadZone(e)) return;

      myDragPane = findLayeredPane(e);
      if (myDragPane == null) return;
      final BufferedImage image =
          new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_ARGB);
      paint(image.getGraphics());
      myDragButtonImage =
          new JLabel(new ImageIcon(image)) {

            public String toString() {
              return "Image for: " + StripeButton.this.toString();
            }
          };
      myDragPane.add(myDragButtonImage, JLayeredPane.POPUP_LAYER);
      myDragButtonImage.setSize(myDragButtonImage.getPreferredSize());
      setVisible(false);
      myPane.startDrag();
      myDragKeyEventDispatcher = new DragKeyEventDispatcher();
      KeyboardFocusManager.getCurrentKeyboardFocusManager()
          .addKeyEventDispatcher(myDragKeyEventDispatcher);
    }
    if (!isDraggingNow()) return;

    Point xy = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), myDragPane);
    if (myPressedPoint != null) {
      xy.x -= myPressedPoint.x;
      xy.y -= myPressedPoint.y;
    }
    myDragButtonImage.setLocation(xy);

    SwingUtilities.convertPointToScreen(xy, myDragPane);

    final Stripe stripe =
        myPane.getStripeFor(new Rectangle(xy, myDragButtonImage.getSize()), (Stripe) getParent());
    if (stripe == null) {
      if (myLastStripe != null) {
        myLastStripe.resetDrop();
      }
    } else {
      if (myLastStripe != null && myLastStripe != stripe) {
        myLastStripe.resetDrop();
      }
      stripe.processDropButton(this, myDragButtonImage, xy);
    }

    myLastStripe = stripe;
  }
 private void addListeners() {
   control.addTrackListener(this);
   // There's a chance the control might have loaded all its tracks before we add ourselves as a
   // tracklistener, so spawn a thread to check if this is so
   control
       .getExecutor()
       .execute(
           new CatchingRunnable() {
             public void doRun() throws Exception {
               checkTracksLoaded();
             }
           });
   // Grab our events...
   KeyboardFocusManager.getCurrentKeyboardFocusManager()
       .addKeyEventDispatcher(new KeyEventHandler());
 }
예제 #20
0
 private void finishDragging() {
   if (!isDraggingNow()) return;
   myDragPane.remove(myDragButtonImage);
   myDragButtonImage = null;
   myPane.stopDrag();
   myDragPane.repaint();
   setVisible(true);
   if (myLastStripe != null) {
     myLastStripe.finishDrop();
     myLastStripe = null;
   }
   if (myDragKeyEventDispatcher != null) {
     KeyboardFocusManager.getCurrentKeyboardFocusManager()
         .removeKeyEventDispatcher(myDragKeyEventDispatcher);
     myDragKeyEventDispatcher = null;
   }
 }
 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();
     }
   }
 }
  public IdeFrame getIdeFrame(@Nullable final Project project) {
    if (project != null) {
      return getFrame(project);
    }
    final Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
    final Component parent = UIUtil.findUltimateParent(window);
    if (parent instanceof IdeFrame) return (IdeFrame) parent;

    final Frame[] frames = Frame.getFrames();
    for (Frame each : frames) {
      if (each instanceof IdeFrame) {
        return (IdeFrame) each;
      }
    }

    return null;
  }
예제 #23
0
 private void init() {
   setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
   addWindowListener(
       new WindowAdapter() {
         @Override
         public void windowClosing(final WindowEvent e) {
           cleanExit();
         }
       });
   addWindowStateListener(
       new WindowStateListener() {
         public void windowStateChanged(final WindowEvent arg0) {
           switch (arg0.getID()) {
             case WindowEvent.WINDOW_ICONIFIED:
               lessCpu(true);
               break;
             case WindowEvent.WINDOW_DEICONIFIED:
               lessCpu(false);
               break;
           }
         }
       });
   setIconImage(Configuration.getImage(Configuration.Paths.Resources.ICON));
   JPopupMenu.setDefaultLightWeightPopupEnabled(false);
   WindowUtil.setFrame(this);
   panel = new BotPanel();
   menuBar = new BotMenuBar(this);
   toolBar = new BotToolBar(this, menuBar);
   panel.setFocusTraversalKeys(0, new HashSet<AWTKeyStroke>());
   new BotKeyboardShortcuts(KeyboardFocusManager.getCurrentKeyboardFocusManager(), this, this);
   menuBar.setBot(null);
   setJMenuBar(menuBar);
   textScroll =
       new JScrollPane(
           TextAreaLogHandler.TEXT_AREA,
           ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
           ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
   textScroll.setBorder(null);
   textScroll.setPreferredSize(new Dimension(PANEL_WIDTH, 120));
   textScroll.setVisible(true);
   JScrollPane scrollableBotPanel = new JScrollPane(panel);
   add(toolBar, BorderLayout.NORTH);
   add(scrollableBotPanel, BorderLayout.CENTER);
   add(textScroll, BorderLayout.SOUTH);
 }
예제 #24
0
  void test1(Window owner, Window child) {
    System.out.println("* * * STAGE 1 * * *\nWindow owner: " + owner);

    owner.setFocusableWindowState(false);
    owner.setVisible(true);

    child.add(button);
    child.setVisible(true);

    Util.waitTillShown(child);

    Util.clickOnComp(button, robot);
    if (button == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) {
      throw new RuntimeException("Test Failed.");
    }
    child.dispose();
    owner.dispose();
  }
  public void showCenteredInCurrentWindow(@NotNull Project project) {
    Window window = null;

    Component focusedComponent = getWndManager().getFocusedComponent(project);
    if (focusedComponent != null) {
      Component parent = UIUtil.findUltimateParent(focusedComponent);
      if (parent instanceof Window) {
        window = (Window) parent;
      }
    }
    if (window == null) {
      window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
    }

    if (window != null) {
      showInCenterOf(window);
    }
  }
  public void removeEditor() {
    KeyboardFocusManager.getCurrentKeyboardFocusManager()
        .removePropertyChangeListener("permanentFocusOwner", editorRemover); // NOI18N
    editorRemover = null;

    if (editor != null) {
      editor.removeCellEditorListener(this);

      if (editorComp != null) {
        remove(editorComp);
      }

      Rectangle cellRect = getCellBounds(editingIndex, editingIndex);

      editingIndex = -1;
      editorComp = null;

      repaint(cellRect);
    }
  }
예제 #27
0
  /**
   * Needed to track which KeyboardFocusManager is current. We want to avoid memory leaks, so when
   * KFM stops being current, we remove ourselves as listeners.
   */
  public void propertyChange(PropertyChangeEvent evt) {
    // We don't handle any other properties. Skip it.
    if (!evt.getPropertyName().equals("managingFocus")) {
      return;
    }

    // We only do it if it stops being current. Technically, we should
    // never get an event about KFM starting being current.
    if (evt.getNewValue() == Boolean.TRUE) {
      return;
    }

    // should be the same as appletKFM
    removeTraversingOutListeners((KeyboardFocusManager) evt.getSource());

    appletKFM = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    if (isVisible()) {
      addTraversingOutListeners(appletKFM);
    }
  }
    public void propertyChange(PropertyChangeEvent ev) {
      if (!isEditing() || getClientProperty("terminateEditOnFocusLost") != Boolean.TRUE) { // NOI18N
        return;
      }

      Component c = focusManager.getPermanentFocusOwner();
      while (c != null) {
        if (c == JListMutable.this) {
          // focus remains inside the table
          return;
        } else if ((c instanceof Window) || (c instanceof Applet && c.getParent() == null)) {
          if (c == SwingUtilities.getRoot(JListMutable.this)) {
            if (!getListCellEditor().stopCellEditing()) {
              getListCellEditor().cancelCellEditing();
            }
          }
          break;
        }
        c = c.getParent();
      }
    }
예제 #29
0
    @Override
    public void update(AnActionEvent e) {
      Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
      e.getPresentation().setEnabled(false);
      if (focusOwner instanceof JComponent
          && SpeedSearchBase.hasActiveSpeedSearch((JComponent) focusOwner)) {
        return;
      }

      if (StackingPopupDispatcher.getInstance().isPopupFocused()) return;

      if (focusOwner instanceof JTree) {
        JTree tree = (JTree) focusOwner;
        if (!tree.isEditing()) {
          e.getPresentation().setEnabled(true);
        }
      } else if (focusOwner instanceof JTable) {
        JTable table = (JTable) focusOwner;
        if (!table.isEditing()) {
          e.getPresentation().setEnabled(true);
        }
      }
    }
예제 #30
0
    private void disposeFocusTrackbackIfNoChildWindowFocused(
        @Nullable IdeFocusManager focusManager) {
      if (myFocusTrackback == null) return;

      final DialogWrapper wrapper = myDialogWrapper.get();
      if (wrapper == null || !wrapper.isShowing()) {
        myFocusTrackback.dispose();
        return;
      }

      if (focusManager != null) {
        final Component c = focusManager.getFocusedDescendantFor(wrapper.getContentPane());
        if (c == null) {
          myFocusTrackback.dispose();
        }
      } else {
        final Component owner =
            KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
        if (owner == null || !SwingUtilities.isDescendingFrom(owner, wrapper.getContentPane())) {
          myFocusTrackback.dispose();
        }
      }
    }