@Override
    public void mouseDragged(MouseEvent e) {
      int ctrlMask = InputEvent.CTRL_DOWN_MASK;
      int action =
          ((e.getModifiersEx() & ctrlMask) == ctrlMask)
              ? TransferHandler.COPY
              : TransferHandler.MOVE;

      JTable setTable = (JTable) e.getSource();
      // 非選択状態からいきなりドラッグを開始すると cellEditor が残ってしまう問題の workaround
      if (setTable.isEditing()) {
        setTable.getCellEditor().stopCellEditing();
      }
      TransferHandler handler = setTable.getTransferHandler();
      handler.exportAsDrag(setTable, e, action);
    }
Example #2
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);
        }
      }
    }