public void actionPerformed(ActionEvent e) {
      int selIndexBefore = getSelectedIndex();
      myDefaultAction.actionPerformed(e);
      int selIndexCurrent = getSelectedIndex();
      if (selIndexBefore != selIndexCurrent) {
        return;
      }
      if (myFocusNext && selIndexCurrent == 0) {
        return;
      }

      KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
      Container container = kfm.getCurrentFocusCycleRoot();
      FocusTraversalPolicy policy = container.getFocusTraversalPolicy();
      if (policy == null) {
        policy = kfm.getDefaultFocusTraversalPolicy();
      }
      Component next =
          myFocusNext
              ? policy.getComponentAfter(container, PaletteItemsComponent.this)
              : policy.getComponentBefore(container, PaletteItemsComponent.this);
      if (next instanceof PaletteGroupComponent) {
        clearSelection();
        next.requestFocus();
        ((PaletteGroupComponent) next).scrollRectToVisible(next.getBounds());
      }
    }
Exemplo n.º 2
0
 public void activate() {
   // arranco la primera opcion
   if (m_actionfirst != null) {
     m_actionfirst.actionPerformed(null);
     m_actionfirst = null;
   }
 }
Exemplo n.º 3
0
 private boolean proceedKeyEvent(KeyEvent event, KeyStroke stroke) {
   if (myInputMap.get(stroke) != null) {
     final Action action = myActionMap.get(myInputMap.get(stroke));
     if (action != null && action.isEnabled()) {
       action.actionPerformed(
           new ActionEvent(
               getContent(), event.getID(), "", event.getWhen(), event.getModifiers()));
       return true;
     }
   }
   return false;
 }
Exemplo n.º 4
0
  public void redoAction() {
    try {
      if (undoMgr.canRedo()) {
        redoAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "Redo"));

        setRedoItem();
      } else {
        java.awt.Toolkit.getDefaultToolkit().beep();
      }
    } catch (CannotUndoException ex) {
      ex.printStackTrace();
    }
  }
    public void actionPerformed(ActionEvent e) {
      int selIndexBefore = getSelectedIndex();
      myDefaultAction.actionPerformed(e);
      int selIndexCurrent = getSelectedIndex();
      if (mySelectNext && selIndexBefore < selIndexCurrent
          || !mySelectNext && selIndexBefore > selIndexCurrent) {
        return;
      }

      if (mySelectNext) {
        if (selIndexCurrent == selIndexBefore + 1) {
          selIndexCurrent++;
        }
        if (selIndexCurrent < getModel().getSize() - 1) {
          setSelectedIndex(selIndexCurrent + 1);
          scrollRectToVisible(getCellBounds(selIndexCurrent + 1, selIndexCurrent + 1));
        }
      } else if (selIndexCurrent > 0) {
        setSelectedIndex(selIndexCurrent - 1);
        scrollRectToVisible(getCellBounds(selIndexCurrent - 1, selIndexCurrent - 1));
      }
    }
  @SuppressWarnings("HardCodedStringLiteral")
  private void processListSelection(final KeyEvent e) {
    if (togglePopup(e)) return;

    if (!isPopupShowing()) return;

    final InputMap map = myPathTextField.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    if (map != null) {
      final Object object = map.get(KeyStroke.getKeyStrokeForEvent(e));
      if (object instanceof Action) {
        final Action action = (Action) object;
        if (action.isEnabled()) {
          action.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "action"));
          e.consume();
          return;
        }
      }
    }

    final Object action = getAction(e, myList);

    if ("selectNextRow".equals(action)) {
      if (ensureSelectionExists()) {
        ListScrollingUtil.moveDown(myList, e.getModifiersEx());
      }
    } else if ("selectPreviousRow".equals(action)) {
      ListScrollingUtil.moveUp(myList, e.getModifiersEx());
    } else if ("scrollDown".equals(action)) {
      ListScrollingUtil.movePageDown(myList);
    } else if ("scrollUp".equals(action)) {
      ListScrollingUtil.movePageUp(myList);
    } else if (getSelectedFileFromCompletionPopup() != null
        && (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_TAB)
        && e.getModifiers() == 0) {
      hideCurrentPopup();
      e.consume();
      processChosenFromCompletion(e.getKeyCode() == KeyEvent.VK_TAB);
    }
  }
Exemplo n.º 7
0
  public static boolean notifyAction(
      final Action action,
      final KeyStroke keyStroke,
      final KeyEvent keyEvent,
      final Object sender,
      final int modifiers) {
    if (action == null || !action.isEnabled()) {
      return false;
    }
    Object command = action.getValue(Action.ACTION_COMMAND_KEY);
    if (command == null && !(action instanceof ActionProxy)) {
      char keyChar = keyEvent.getKeyChar();
      if (keyChar != KeyEvent.CHAR_UNDEFINED) {
        command = String.valueOf(keyChar);
      }
    }

    action.actionPerformed(
        new ActionEvent(
            sender, ActionEvent.ACTION_PERFORMED, (String) command, keyEvent.getWhen(), modifiers));

    return true;
  }
Exemplo n.º 8
0
  public ConverterView(ConverterModel model) {
    //        this.model = model;

    this.fileChooser = new JFileChooser();
    this.fileChooser.setFileFilter(new ConverterFileFilter());
    this.fileChooser.setMultiSelectionEnabled(true);

    setTitle(getGuiString(model.getName()));

    this.addButton = new JButton(getGuiString("buttons.change"));
    this.addButton.addActionListener(
        e -> {
          if (this.changeActionListener != null) {
            Action details = fileChooser.getActionMap().get("viewTypeDetails");
            details.actionPerformed(null);
            if (FilePath.getFilePath(this.getTitle()) != null) {
              File file = new File(FilePath.getFilePath(this.getTitle()).getPath());
              fileChooser.setCurrentDirectory(file);
            }
            int ret = fileChooser.showDialog(null, getGuiString("buttons.openFile"));
            if (ret == JFileChooser.APPROVE_OPTION) {
              File[] files = fileChooser.getSelectedFiles();
              FilePath.setFilePath(this.getTitle(), fileChooser.getCurrentDirectory().getPath());
              this.changeActionListener.actionPerformed(files);
            }
          }
          hide();
        });
    this.cancelButton = new JButton(getGuiString("buttons.cancel"));
    this.cancelButton.addActionListener(
        e -> {
          hide();
        });

    buildLayout();
    show();
  }
Exemplo n.º 9
0
 public void selectLine() {
   Action selectLine = getAction(DefaultEditorKit.selectLineAction);
   if (selectLine != null) {
     selectLine.actionPerformed(null);
   }
 }
Exemplo n.º 10
0
 public void actionPerformed(ActionEvent event) {
   saveHistoryAction.actionPerformed(event);
 }
Exemplo n.º 11
0
 public void actionPerformed(ActionEvent event) {
   stopRAction.actionPerformed(event);
 }
Exemplo n.º 12
0
 public void actionPerformed(ActionEvent e) {
   String keyword = EditorUtil.getSelectedkeyword(logArea);
   if (keyword != null) {
     openfunctionAction.actionPerformed(new ActionEvent(this, 0, keyword));
   }
 }
Exemplo n.º 13
0
 public void actionPerformed(ActionEvent event) {
   String keyword = EditorUtil.getSelectedkeyword(logArea);
   if (keyword != null) {
     requesthelpAction.actionPerformed(new ActionEvent(this, 0, keyword));
   }
 }