@Override
 public void actionPerformed(ActionEvent e) {
   int tamanyo = 14;
   try {
     if ((JComboBox) (e.getSource()) == comboTamanyo) {
       tamanyo = (int) ((JComboBox) e.getSource()).getSelectedItem();
       if (tamanyo == 10) jrdm10pt.setSelected(true);
       else if (tamanyo == 14) jrdm14pt.setSelected(true);
       else if (tamanyo == 18) jrdm18pt.setSelected(true);
       else if (tamanyo == 22) jrdm22pt.setSelected(true);
     }
   } catch (Exception ex) {
   }
   try {
     if ((JRadioButtonMenuItem) (e.getSource()) == jrdm10pt
         || (JRadioButtonMenuItem) (e.getSource()) == jrdm14pt
         || (JRadioButtonMenuItem) (e.getSource()) == jrdm18pt
         || (JRadioButtonMenuItem) (e.getSource()) == jrdm22pt) {
       tamanyo = Integer.parseInt(((JRadioButtonMenuItem) e.getSource()).getText());
       comboTamanyo.setSelectedItem(tamanyo);
     }
   } catch (Exception ex) {
   }
   // Establecemos la acción que queremos que haga cuando se cambie
   Action accion = new StyledEditorKit.FontSizeAction("Tamaño", tamanyo);
   // Hacemos que la accion ejecute el actionPerformand
   accion.actionPerformed(e);
   jtaTexto.requestFocus();
 }
示例#2
0
 protected void processWindowEvent(WindowEvent e) {
   if (e.getID() == WindowEvent.WINDOW_CLOSING) {
     abortAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, ""));
   } else if (e.getID() == WindowEvent.WINDOW_CLOSED) {
     close();
   }
 }
示例#3
0
 public void activate() {
   // arranco la primera opcion
   if (m_actionfirst != null) {
     m_actionfirst.actionPerformed(null);
     m_actionfirst = null;
   }
 }
    @Override
    public GridBoundsChange performAction(GridManager gridManager, DesignerContext context) {
      GridInfoProvider info = gridManager.getGridInfo();
      int oldColumns = info.getColumnCount();
      int oldRows = info.getRowCount();
      GridUtils.removePaddingComponents(gridManager);

      // Undo/redo itself
      delegate.actionPerformed(null);
      gridManager.updateLayout(true);

      // Remove deleted components from selection
      Set<Component> newSelection = new HashSet<Component>();
      for (Component comp : context.getSelectedComponents()) {
        if (comp.getParent() != null) {
          newSelection.add(comp);
        }
      }
      context.setSelectedComponents(newSelection);

      GridUtils.revalidateGrid(gridManager);
      gridManager.updateGaps(false);
      int newColumns = info.getColumnCount();
      int newRows = info.getRowCount();
      int columns = Math.max(oldColumns, newColumns);
      int rows = Math.max(oldRows, newRows);
      GridUtils.addPaddingComponents(gridManager, columns, rows);
      GridUtils.revalidateGrid(gridManager);
      return null;
    }
    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());
      }
    }
示例#6
0
    public void actionPerformed(ActionEvent e) {
      JComboBox combo = (JComboBox) e.getSource();
      Object s = combo.getSelectedItem();

      if (s instanceof Action) {
        ((Action) s).actionPerformed(e);

        // after the selection of "fit to window" the new calculated zoom
        // percentage is displayed
        if (s instanceof CommonActions.ZoomToFitAction) {
          updateZoomCombo();
        }
      } else if (s instanceof String) {
        String zs = (String) s;
        zs = zs.replace("%", "");
        try {
          double zf = Double.parseDouble(zs);
          if (zf > 0) { // Ignore negative number
            ZoomAction za = new ZoomAction(swingEngine.getEngine(), zf);
            za.setEnabled(true);
            za.actionPerformed(e);
          }
        } catch (Exception ex) {
          // Ignore bad input
        }
      }
    }
示例#7
0
 /** Perform the callback action */
 public void performAction(SystemAction action) {
   JTextComponent component = getComponent();
   Action ea = getEditorAction();
   if (component != null && ea != null) {
     ea.actionPerformed(new ActionEvent(component, 0, "")); // NOI18N
   }
 }
  public void testInitialTab() throws Exception {
    Action action =
        Actions.forID("System", "org.netbeans.modules.autoupdate.ui.actions.PluginManagerAction");
    assertNotNull("Action found", action);
    action.actionPerformed(new ActionEvent(this, 100, "local"));

    assertEquals("local", PluginManagerAction.getPluginManagerUI().getSelectedTabName());
  }
示例#9
0
 boolean insertBreakSpecialHandling(ActionEvent e) {
   Action a = tokenMaker.getInsertBreakAction();
   if (a != null) {
     a.actionPerformed(e);
     return true;
   }
   return false;
 }
 @Override
 protected void okAction(ActionEvent ae) {
   try {
     saveFields();
     okAction.actionPerformed(ae);
   } catch (Exception e) {
     errorValueFormat.setText(e.toString());
   }
 }
示例#11
0
 public static void renameProject(Project p, Object caller) {
   if (p == null) {
     return;
   }
   ContextAwareAction action = (ContextAwareAction) CommonProjectActions.renameProjectAction();
   Lookup ctx = Lookups.singleton(p);
   Action ctxAction = action.createContextAwareInstance(ctx);
   ctxAction.actionPerformed(new ActionEvent(caller, 0, "")); // NOI18N
 }
示例#12
0
 // ============================================================[ api for scripting
 public int perform(Action a) {
   try {
     a.actionPerformed(null);
   } catch (Exception e) {
     System.err.println("failed to perform action");
     return -1;
   }
   return 0;
 }
示例#13
0
    public void mouseEntered(MouseEvent e) {
      if (tooltipMouseHandlerEnabled) {
        JComponent c = (JComponent) e.getComponent();
        Action action = c.getActionMap().get("postTip");

        if (action != null) {
          action.actionPerformed(new ActionEvent(c, ActionEvent.ACTION_PERFORMED, "postTip"));
        }
      }
    }
示例#14
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;
 }
示例#15
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();
    }
  }
 private void exitIfFatal() {
   ErrorInfo info = pane.getErrorInfo();
   // FYI: info can be null
   if (info != null && info.getErrorLevel() == ErrorLevel.FATAL) {
     Action fatalAction = pane.getActionMap().get(JXErrorPane.FATAL_ACTION_KEY);
     if (fatalAction == null) {
       System.exit(1);
     } else {
       ActionEvent ae = new ActionEvent(closeButton, -1, "fatal");
       fatalAction.actionPerformed(ae);
     }
   }
 }
示例#17
0
    /** {@inheritDoc} */
    @Override
    public void actionPerformed(ActionEvent e) {
      JComboBox comboBox = (JComboBox) e.getSource();
      JTextComponent textComponent = (JTextComponent) comboBox.getEditor().getEditorComponent();
      AutoCompleteDocument doc = (AutoCompleteDocument) textComponent.getDocument();

      // doing this prevents the updating of the selected item to "" during the remove prior
      // to the insert in JTextComponent.setText
      doc.strictMatching = true;
      try {
        delegate.actionPerformed(e);
      } finally {
        doc.strictMatching = false;
      }
    }
示例#18
0
 public static void executeMenuItems(final List<String> menuItemKeys) {
   LogUtils.info("menu items to execute: " + menuItemKeys);
   final MenuBuilder menuBuilder = getMenuBuilder();
   for (String menuItemKey : menuItemKeys) {
     final DefaultMutableTreeNode treeNode = menuBuilder.get(menuItemKey);
     if (treeNode == null
         || !treeNode.isLeaf()
         || !(treeNode.getUserObject() instanceof JMenuItem)) {
       UITools.errorMessage(TextUtils.format("MenuUtils.invalid_menuitem", menuItemKey));
       return;
     }
     final JMenuItem menuItem = (JMenuItem) treeNode.getUserObject();
     final Action action = menuItem.getAction();
     LogUtils.info("executing " + menuItem.getText() + "(" + menuItemKey + ")");
     ActionEvent e = new ActionEvent(menuItem, 0, null);
     action.actionPerformed(e);
   }
 }
示例#19
0
  protected void list_keyPressed(KeyEvent e) {
    int key = e.getKeyCode();
    if (key == KeyEvent.VK_ESCAPE) {
      cancelEdit();
    } else if (key == KeyEvent.VK_ENTER) {
      if (OSUtils.isMacOSX()) {
        actionStartRename();
      }
    } else if (key == KeyEvent.VK_F2) {
      if (!OSUtils.isMacOSX()) {
        actionStartRename();
      }
    } else if (key == KeyEvent.VK_DELETE || (OSUtils.isMacOSX() && key == KeyEvent.VK_BACK_SPACE)) {
      deleteAction.actionPerformed(null);
    }

    if (LibraryUtils.isRefreshKeyEvent(e)) {
      refreshSelection();
    }
  }
    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);
    }
  }
示例#22
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();
  }
  /**
   * This executes one of the actions, based on the stored ArgoUML configuration. This function is
   * intended for the initial setting of the snap when ArgoUML is started.
   */
  static void init() {
    String id = Configuration.getString(Argo.KEY_SNAP, DEFAULT_ID);
    List<Action> actions = createAdjustSnapActions();
    for (Action a : actions) {
      if (a.getValue("ID").equals(id)) {
        a.actionPerformed(null);

        if (myGroup != null) {
          for (Enumeration e = myGroup.getElements(); e.hasMoreElements(); ) {
            AbstractButton ab = (AbstractButton) e.nextElement();
            Action action = ab.getAction();
            if (action instanceof ActionAdjustSnap) {
              String currentID = (String) action.getValue("ID");
              if (id.equals(currentID)) {
                myGroup.setSelected(ab.getModel(), true);
                return;
              }
            }
          }
        }
        return;
      }
    }
  }
示例#24
0
 public void actionPerformed(ActionEvent e) {
   delegate.actionPerformed(e);
 }
示例#25
0
  @Override
  public boolean dispatchKeyEvent(KeyEvent e) {

    if (!FocusManager.getCurrentManager()
        .getActiveWindow()
        .equals(model.getGUIManager().getParent())) return false;
    if (e.getID() == KeyEvent.KEY_PRESSED) {
      switch (e.getKeyCode()) {
        case KeyEvent.VK_HOME:
          start.actionPerformed(null);
          return true;
        case KeyEvent.VK_END:
          end.actionPerformed(null);
          return true;
        case KeyEvent.VK_LEFT:
        case KeyEvent.VK_NUMPAD4:
          left.actionPerformed(null);
          return true;
        case KeyEvent.VK_RIGHT:
        case KeyEvent.VK_NUMPAD6:
          right.actionPerformed(null);
          return true;
        case KeyEvent.VK_ADD:
        case KeyEvent.VK_UP:
        case KeyEvent.VK_PLUS:
        case KeyEvent.VK_EQUALS:
          zoomin.actionPerformed(null);
          return true;
        case KeyEvent.VK_SUBTRACT:
        case KeyEvent.VK_DOWN:
        case KeyEvent.VK_MINUS:
          zoomout.actionPerformed(null);
          return true;
        case KeyEvent.VK_DELETE:
        case KeyEvent.VK_BACK_SPACE:
          remove.actionPerformed(null);
          return true;
        default:
          return false;
          // do nothing
      }
    }
    return false;

    // /* zoom in */
    // inputs.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, 0),
    // "customZoomIn");
    // actions.put("customZoomIn", new AnnotationZoomInAction(model));
    // inputs.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, 0),
    // "customZoomOut");
    // actions.put("customZoomOut", new AnnotationZoomOutAction(model));
    //
    // /* select first from selection */
    // inputs.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD7, 0),
    // "customSelectFirst");
    // inputs.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0),
    // "customSelectFirst");
    // actions.put("customSelectFirst", new SelectFromSelectedFirst(model));
    //
    // /* select last from selection */
    // inputs.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD1, 0),
    // "customSelectLast");
    // inputs.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0),
    // "customSelectLast");
    // actions.put("customSelectLast", new SelectFromSelectedLast(model));
    //
    // /* move selection one location forward */
    // inputs.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD9, 0),
    // "customSelectForward");
    // inputs.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0),
    // "customSelectForward");
    // actions
    // .put("customSelectForward",
    // new SelectFromSelectedForward(model));
    //
    // /* move selection one location back */
    // inputs.put(KeyStroke.getKeyStroke(KeyEvent.VK_NUMPAD3, 0),
    // "customSelectBack");
    // inputs.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0),
    // "customSelectBack");
    // actions.put("customSelectBack", new SelectFromSelectedBack(model));

  }
示例#26
0
 public void invokeOriginalAction(String key) {
   ActionEvent e = new ActionEvent(this, 0, key);
   Action action = originalAm.get(key);
   action.actionPerformed(e);
 }
示例#27
0
 public void selectLine() {
   Action selectLine = getAction(DefaultEditorKit.selectLineAction);
   if (selectLine != null) {
     selectLine.actionPerformed(null);
   }
 }
示例#28
0
文件: Apps.java 项目: dpharris/JMRI
 public void doPreferences() {
   prefsAction.actionPerformed(null);
 }
 public void actionPerformed(ActionEvent event) {
   saveHistoryAction.actionPerformed(event);
 }
示例#30
-1
 public void actionPerformed(ActionEvent e) {
   JTextComponent c = (JTextComponent) componentRef.get();
   if (c != null) { // Override action event to text component
     e = new ActionEvent(c, e.getID(), e.getActionCommand());
   }
   delegate.actionPerformed(e);
 }