Example usage for javax.swing AbstractAction AbstractAction

List of usage examples for javax.swing AbstractAction AbstractAction

Introduction

In this page you can find the example usage for javax.swing AbstractAction AbstractAction.

Prototype

public AbstractAction(String name) 

Source Link

Document

Creates an Action with the specified name.

Usage

From source file:com.pianobakery.complsa.MainGui.java

private Action runSearch() {
    return new AbstractAction("The Search") {
        private static final long serialVersionUID = 1L;

        @Override/*from ww  w . j a  va2 s.  c o  m*/
        public void actionPerformed(ActionEvent e) {
            logger.debug("The Search");
            searchMethod();
        }
    };
}

From source file:edu.ku.brc.specify.Specify.java

/**
 * @param name//from  ww w. jav  a  2  s . co  m
 * @param type
 * @param action
 * @return
 */
protected Action createAction(final String name, final String type, final String action) {
    AbstractAction actionObj = new AbstractAction(getResourceString(name)) {
        public void actionPerformed(ActionEvent e) {
            //CommandDispatcher.dispatch(new CommandAction(type, action, null));
        }
    };
    UIRegistry.registerAction(name, actionObj);
    return actionObj;
}

From source file:GUI.MainWindow.java

private void setupUndoListeners() {

    undo_manager.setLimit(-1);/*w w w .  ja  va2  s.  com*/
    this.VulnTitleTextField.getDocument().addUndoableEditListener(this.undo_manager);
    this.VulnDescriptionTextPane.getDocument().addUndoableEditListener(this.undo_manager);
    this.VulnRecommendationTextPane.getDocument().addUndoableEditListener(this.undo_manager);

    // Add actions into the Action Map.
    VulnDescriptionTextPane.getActionMap().put("Undo", new AbstractAction("Undo") {
        public void actionPerformed(ActionEvent evt) {
            try {
                if (undo_manager.canUndo()) {
                    undo_manager.undo();
                }
            } catch (CannotUndoException e) {
            }
        }
    });

    VulnDescriptionTextPane.getActionMap().put("Redo", new AbstractAction("Redo") {
        public void actionPerformed(ActionEvent evt) {
            try {
                if (undo_manager.canRedo()) {
                    undo_manager.redo();
                }
            } catch (CannotRedoException e) {
            }
        }
    });

    VulnRecommendationTextPane.getActionMap().put("Undo", new AbstractAction("Undo") {
        public void actionPerformed(ActionEvent evt) {
            try {
                if (undo_manager.canUndo()) {
                    undo_manager.undo();
                }
            } catch (CannotUndoException e) {
            }
        }
    });

    VulnRecommendationTextPane.getActionMap().put("Redo", new AbstractAction("Redo") {
        public void actionPerformed(ActionEvent evt) {
            try {
                if (undo_manager.canRedo()) {
                    undo_manager.redo();
                }
            } catch (CannotRedoException e) {
            }
        }
    });

    VulnTitleTextField.getActionMap().put("Undo", new AbstractAction("Undo") {
        public void actionPerformed(ActionEvent evt) {
            try {
                if (undo_manager.canUndo()) {
                    undo_manager.undo();
                }
            } catch (CannotUndoException e) {
            }
        }
    });

    VulnTitleTextField.getActionMap().put("Redo", new AbstractAction("Redo") {
        public void actionPerformed(ActionEvent evt) {
            try {
                if (undo_manager.canRedo()) {
                    undo_manager.redo();
                }
            } catch (CannotRedoException e) {
            }
        }
    });

    // Add the key mappings
    VulnDescriptionTextPane.getInputMap().put(KeyStroke.getKeyStroke("control Z"), "Undo");
    VulnDescriptionTextPane.getInputMap().put(KeyStroke.getKeyStroke("control Y"), "Redo");

    VulnRecommendationTextPane.getInputMap().put(KeyStroke.getKeyStroke("control Z"), "Undo");
    VulnRecommendationTextPane.getInputMap().put(KeyStroke.getKeyStroke("control Y"), "Redo");

    VulnTitleTextField.getInputMap().put(KeyStroke.getKeyStroke("control Z"), "Undo");
    VulnTitleTextField.getInputMap().put(KeyStroke.getKeyStroke("control Y"), "Redo");

}

From source file:src.gui.ItSIMPLE.java

/**
    * This method initializes newMenuItem
    *// ww  w  .j  a  v  a 2 s .  c  o  m
    * @return javax.swing.JMenuItem
    */
private JMenuItem getOpenRecentProjectMenu() {
    if (openRecentMenu == null) {
        openRecentMenu = new JMenu();
        openRecentMenu.setText("Open Recent Project");
    }

    if (openRecentMenu != null) {
        openRecentMenu.removeAll();
        List<?> recentProjects = itSettings.getChild("recentProjects").getChildren("project");
        if (recentProjects.size() > 0) {
            int projectCounter = 1;
            for (Iterator<?> iter = recentProjects.iterator(); iter.hasNext();) {
                Element recentProject = (Element) iter.next();
                String path = recentProject.getChildText("filePath");
                String fileName = path.substring(path.lastIndexOf("\\") + 1, path.length());
                Action action = new AbstractAction(
                        projectCounter + ". " + recentProject.getChildText("name") + " [" + fileName + "]") {
                    /**
                     *
                     */
                    public void actionPerformed(ActionEvent e) {
                        //System.out.println(this.getValue("data"));
                        Element projectElement = (Element) this.getValue("data");
                        if (projectElement != null) {
                            openProjectFromPath(projectElement.getChildText("filePath"));
                        }
                    }
                };
                //action.putValue(Action.SMALL_ICON, new ImageIcon("resources/images/project.png"));
                action.putValue(Action.SHORT_DESCRIPTION, path);
                action.putValue("data", recentProject);
                JMenuItem recentProjectItem = new JMenuItem(action);
                recentProjectItem.setMnemonic((int) (projectCounter + "").charAt(0));
                openRecentMenu.add(recentProjectItem);
                projectCounter++;
            }
        }

    }
    return openRecentMenu;
}

From source file:src.gui.ItSIMPLE.java

/**
 * This method should be called every time a project is opened or closed,
 * to update the items, like domains and problems, in the Petri Net view.
 *///from   w  w  w.ja va  2s .c  om
private void updatePetriNetPanels() {
    projectPetriTaskPane.removeAll();
    stateMachineJList.removeAll();
    petriDetailsTextPane.setText("<html><font size='-1' face='Arial'>Select a project.<html>");

    for (int i = 0; i < treeRoot.getChildCount(); i++) {
        ItTreeNode currentNode = (ItTreeNode) treeRoot.getChildAt(i);

        Element project = currentNode.getData();
        //System.out.print(project);
        //Check if the project is a UML project (tag named project)
        if (project.getName().equals("project")) {
            Action action = new AbstractAction(project.getChildText("name")) {
                /**
                *
                */
                private static final long serialVersionUID = -5069133020063854135L;

                public void actionPerformed(ActionEvent e) {
                    Element projectElement = (Element) this.getValue("data");
                    selectedPetriNetProject = projectElement;
                    if (projectElement != null) {
                        String details = "<html><font size='-1' face='Arial'><b>"
                                + projectElement.getChildText("name");
                        if (projectElement.getChildText("description").trim().equals("")) {
                            details = details + "<br>No description...</font></html>";
                        } else {
                            details = details + "<br>" + projectElement.getChildText("description")
                                    + "</font></html>";
                        }
                        petriDetailsTextPane.setText(details);
                        setStateMachineList(projectElement);
                    }
                }
            };
            action.putValue(Action.SMALL_ICON, new ImageIcon("resources/images/project.png"));
            //action.putValue(Action.SHORT_DESCRIPTION, project.getChild("description"));
            action.putValue("data", project);
            projectPetriTaskPane.add(action);

        }

    }
}