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, Icon icon) 

Source Link

Document

Creates an Action with the specified name and small icon.

Usage

From source file:es.emergya.ui.plugins.admin.AdminLayers.java

protected Action bajaCapaAction(final CapaInformacion capa) {
    Action a = new AbstractAction("", LogicConstants.getIcon("button_down")) {

        private static final long serialVersionUID = -4001983030571380494L;

        @Override//from w  w  w  . j a  v a 2 s  .c  om
        public void actionPerformed(ActionEvent e) {
            log.debug("bajaCapaAction(" + capa + ")");
            SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() {

                @Override
                protected Object doInBackground() throws Exception {
                    CapaInformacionAdmin.baja(capa);
                    return null;
                }

                @Override
                protected void done() {
                    super.done();
                    AdminLayers.this.refresh(null);
                }
            };
            sw.execute();
        }
    };

    return a;
}

From source file:com.intuit.tank.tools.debugger.ActionProducer.java

/**
 * //from  ww w. ja v a2 s. c  o m
 * @return
 */
public Action getClearBookmarksAction() {
    Action ret = actionMap.get(ACTION_REMOVE_BOOKMARKS);
    if (ret == null) {
        ret = new AbstractAction(ACTION_REMOVE_BOOKMARKS, getIcon("bookmark-remove.png", IconSize.SMALL)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                debuggerFrame.clearBookmarks();
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, ACTION_REMOVE_BOOKMARKS);
        actionMap.put(ACTION_REMOVE_BOOKMARKS, ret);
    }
    return ret;
}

From source file:com.intuit.tank.tools.debugger.ActionProducer.java

/**
 * /*from  w  ww. j  ava  2s .c o m*/
 * @return
 */
public Action getClearSkipsAction() {
    Action ret = actionMap.get(ACTION_REMOVE_SKIP);
    if (ret == null) {
        ret = new AbstractAction(ACTION_REMOVE_SKIP, getIcon("remove-all-skips.png", IconSize.SMALL)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                debuggerFrame.clearSkips();
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, ACTION_REMOVE_SKIP);
        actionMap.put(ACTION_REMOVE_SKIP, ret);
    }
    return ret;
}

From source file:com.intuit.tank.tools.debugger.ActionProducer.java

/**
 * /*  w  w  w.ja va2s .  c o m*/
 * @return
 */
public Action getEndDebugAction() {
    Action ret = actionMap.get(ACTION_STOP);
    if (ret == null) {
        ret = new AbstractAction(ACTION_STOP, getIcon("control_stop_blue.png", IconSize.SMALL)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                debuggerFrame.stop();
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, "Stop Debugging.");
        actionMap.put(ACTION_STOP, ret);
    }
    return ret;
}

From source file:com.intuit.tank.tools.debugger.ActionProducer.java

/**
 * //from  w ww.  j a  v  a 2s  . c  o  m
 * @return
 */
public Action getRunToAction() {
    Action ret = actionMap.get(ACTION_RUN_TO);
    if (ret == null) {
        ret = new AbstractAction(ACTION_RUN_TO, getIcon("control_fastforward_blue.png", IconSize.SMALL)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                debuggerFrame.runToBreakpoint();
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, ACTION_RUN_TO);
        actionMap.put(ACTION_RUN_TO, ret);
    }
    return ret;
}

From source file:com.intuit.tank.tools.debugger.ActionProducer.java

/**
 * //from ww  w . java2  s.co  m
 * @return
 */
public Action getPauseAction() {
    Action ret = actionMap.get(ACTION_PAUSE);
    if (ret == null) {
        ret = new AbstractAction(ACTION_PAUSE, getIcon("control_pause_blue.png", IconSize.SMALL)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                debuggerFrame.pause();
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, ACTION_PAUSE);
        actionMap.put(ACTION_PAUSE, ret);
    }
    return ret;
}

From source file:com.intuit.tank.tools.debugger.ActionProducer.java

/**
 * /*from w w w. j ava 2  s.c o m*/
 * @return
 */
public Action getSkipAction() {
    Action ret = actionMap.get(ACTION_SKIP);
    if (ret == null) {
        ret = new AbstractAction(ACTION_SKIP, getIcon("control_repeat_blue.png", IconSize.SMALL)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                debuggerFrame.skip();
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, ACTION_SKIP);
        actionMap.put(ACTION_SKIP, ret);
    }
    return ret;
}

From source file:com.intuit.tank.tools.debugger.ActionProducer.java

/**
 * /*from   w  w w.  java  2  s  .  c  o m*/
 * @return
 */
public Action getSkipStepAction() {
    Action ret = actionMap.get(ACTION_SKIP_STEP);
    if (ret == null) {
        ret = new AbstractAction(ACTION_SKIP_STEP, getIcon("skip.png", IconSize.SMALL)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                debuggerFrame.toggleSkip();
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, ACTION_SKIP_STEP);
        actionMap.put(ACTION_SKIP_STEP, ret);
    }
    return ret;
}

From source file:com.intuit.tank.tools.debugger.ActionProducer.java

/**
 * /* ww  w  .j  a  v a  2s  . c om*/
 * @return
 */
public Action getToggleBreakpointAction() {
    Action ret = actionMap.get(ACTION_TOGGLE_BREAKPOINT);
    if (ret == null) {
        ret = new AbstractAction(ACTION_TOGGLE_BREAKPOINT, getIcon("bullet_blue.png", IconSize.SMALL)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                debuggerFrame.toggleBreakPoint();
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, ACTION_TOGGLE_BREAKPOINT);
        actionMap.put(ACTION_TOGGLE_BREAKPOINT, ret);
    }
    return ret;
}

From source file:it.cnr.icar.eric.client.ui.swing.graph.JBGraph.java

/**
 * DOCUMENT ME!//  w  w  w.jav a 2 s. c  o m
 *
 * @return DOCUMENT ME!
 */
public JToolBar createToolBar() {
    JButton button = null;
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);

    //TODO: SwingBoost: Localize this
    TreeNode tempTreeNode = new DefaultMutableTreeNode("loading object types...");
    objectTypeCombo = new it.cnr.icar.eric.client.ui.swing.TreeCombo(new DefaultTreeModel(tempTreeNode));
    toolbar.add(objectTypeCombo);

    // use a SwingWorker to get the real model, since it might not have been initialized yet
    final SwingWorker worker = new SwingWorker(this) {
        public Object doNonUILogic() {
            ConceptsTreeModel objectTypesTreeModel = BusinessQueryPanel.getObjectTypesTreeModel();
            return objectTypesTreeModel;
        }

        public void doUIUpdateLogic() {
            ConceptsTreeModel objectTypesTreeModel = (ConceptsTreeModel) get();
            objectTypeCombo.setModel(objectTypesTreeModel);
        }
    };
    worker.start();

    // Insert
    URL insertUrl = getClass().getClassLoader().getResource("icons/insert.gif");
    ImageIcon insertIcon = new ImageIcon(insertUrl);
    button = toolbar.add(new AbstractAction("", insertIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            insert(new Point(10, 10));
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Insert");

    // Toggle Connect Mode
    URL connectUrl = getClass().getClassLoader().getResource("icons/connecton.gif");
    ImageIcon connectIcon = new ImageIcon(connectUrl);
    button = toolbar.add(new AbstractAction("", connectIcon) {

        /**
        * 
        */
        private static final long serialVersionUID = 657528648199915209L;

        public void actionPerformed(ActionEvent e) {
            setPortsVisible(!isPortsVisible());

            URL connectUrl;

            if (isPortsVisible()) {
                connectUrl = getClass().getClassLoader().getResource("icons/connecton.gif");
            } else {
                connectUrl = getClass().getClassLoader().getResource("icons/connectoff.gif");
            }

            ImageIcon connectIcon = new ImageIcon(connectUrl);
            putValue(SMALL_ICON, connectIcon);
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Toggle Connect Mode");

    // Undo
    toolbar.addSeparator();

    URL undoUrl = getClass().getClassLoader().getResource("icons/undo.gif");
    ImageIcon undoIcon = new ImageIcon(undoUrl);
    undo = new AbstractAction("", undoIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -740055667372297781L;

        public void actionPerformed(ActionEvent e) {
            undo();
        }
    };
    undo.setEnabled(false);
    button = toolbar.add(undo);
    button.setText(""); //an icon-only button
    button.setToolTipText("Undo");

    // Redo
    URL redoUrl = getClass().getClassLoader().getResource("icons/redo.gif");
    ImageIcon redoIcon = new ImageIcon(redoUrl);
    redo = new AbstractAction("", redoIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = 5021485220988522968L;

        public void actionPerformed(ActionEvent e) {
            redo();
        }
    };
    redo.setEnabled(false);
    button = toolbar.add(redo);
    button.setText(""); //an icon-only button
    button.setToolTipText("Redo");

    //
    // Edit Block
    //
    toolbar.addSeparator();

    Action action;
    URL url;

    // Copy
    action = TransferHandler.getCopyAction();
    url = getClass().getClassLoader().getResource("icons/copy.gif");
    action.putValue(Action.SMALL_ICON, new ImageIcon(url));

    //Commented out until we can figure out how to assign new id to copied objects
    //button = toolbar.add(copy = new EventRedirector(action));
    button.setText(""); //an icon-only button
    button.setToolTipText("Copy");

    // Paste
    action = TransferHandler.getPasteAction();
    url = getClass().getClassLoader().getResource("icons/paste.gif");
    action.putValue(Action.SMALL_ICON, new ImageIcon(url));

    //Commented out until we can figure out how to assign new id to copied objects
    //button = toolbar.add(paste = new EventRedirector(action));
    button.setText(""); //an icon-only button
    button.setToolTipText("Paste");

    // Cut
    action = TransferHandler.getCutAction();
    url = getClass().getClassLoader().getResource("icons/cut.gif");
    action.putValue(Action.SMALL_ICON, new ImageIcon(url));

    //Commented out until we can figure out how to assign new id to copied objects
    //button = toolbar.add(cut = new EventRedirector(action));
    button.setText(""); //an icon-only button
    button.setToolTipText("Cut");

    // Remove
    URL removeUrl = getClass().getClassLoader().getResource("icons/delete.gif");
    ImageIcon removeIcon = new ImageIcon(removeUrl);
    remove = new AbstractAction("", removeIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = 6889927067487680474L;

        public void actionPerformed(ActionEvent e) {
            if (!isSelectionEmpty()) {
                Object[] cells = getSelectionCells();
                cells = getDescendants(cells);
                getModel().remove(cells);

                //Remove entry from map of cells on the graph
                for (int i = 0; i < cells.length; i++) {
                    Object cell = cells[i];

                    if (cell instanceof JBGraphCell) {
                        RegistryObject ro = ((JBGraphCell) cell).getRegistryObject();
                        registryObjectToCellMap.remove(ro);
                    }
                }
            }
        }
    };
    remove.setEnabled(false);
    button = toolbar.add(remove);
    button.setText(""); //an icon-only button
    button.setToolTipText(resourceBundle.getString("menu.graphPanel.removeFromView"));

    // Zoom Std
    toolbar.addSeparator();

    URL zoomUrl = getClass().getClassLoader().getResource("icons/zoom.gif");
    ImageIcon zoomIcon = new ImageIcon(zoomUrl);
    button = toolbar.add(new AbstractAction("", zoomIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -4404610379022823602L;

        public void actionPerformed(ActionEvent e) {
            setScale(1.0);
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Zoom");

    // Zoom In
    URL zoomInUrl = getClass().getClassLoader().getResource("icons/zoomin.gif");
    ImageIcon zoomInIcon = new ImageIcon(zoomInUrl);
    button = toolbar.add(new AbstractAction("", zoomInIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = 6782766891458235321L;

        public void actionPerformed(ActionEvent e) {
            setScale(2 * getScale());
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Zoom In");

    // Zoom Out
    URL zoomOutUrl = getClass().getClassLoader().getResource("icons/zoomout.gif");
    ImageIcon zoomOutIcon = new ImageIcon(zoomOutUrl);
    button = toolbar.add(new AbstractAction("", zoomOutIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -5480242207934335070L;

        public void actionPerformed(ActionEvent e) {
            setScale(getScale() / 2);
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Zoom Out");

    // Group
    /*
    toolbar.addSeparator();
            
    URL groupUrl          =
    getClass().getClassLoader().getResource("icons/group.gif");
    ImageIcon groupIcon   = new ImageIcon(groupUrl);
    group =
    new AbstractAction("", groupIcon) {
            public void actionPerformed(ActionEvent e) {
                group(getSelectionCells());
            }
        };
    group.setEnabled(false);
    //button                = toolbar.add(group);
    button.setText(""); //an icon-only button
    button.setToolTipText("Group");
            
    // Ungroup
    URL ungroupUrl        =
    getClass().getClassLoader().getResource("icons/ungroup.gif");
    ImageIcon ungroupIcon = new ImageIcon(ungroupUrl);
    ungroup =
    new AbstractAction("", ungroupIcon) {
            public void actionPerformed(ActionEvent e) {
                ungroup(getSelectionCells());
            }
        };
    ungroup.setEnabled(false);
    //button                = toolbar.add(ungroup);
    button.setText(""); //an icon-only button
    button.setToolTipText("Ungroup");
     */
    // To Front
    toolbar.addSeparator();

    URL toFrontUrl = getClass().getClassLoader().getResource("icons/tofront.gif");
    ImageIcon toFrontIcon = new ImageIcon(toFrontUrl);
    tofront = new AbstractAction("", toFrontIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -4901428890590828561L;

        public void actionPerformed(ActionEvent e) {
            if (!isSelectionEmpty()) {
                toFront(getSelectionCells());
            }
        }
    };
    tofront.setEnabled(false);
    button = toolbar.add(tofront);
    button.setText(""); //an icon-only button
    button.setToolTipText("To Front");

    // To Back
    URL toBackUrl = getClass().getClassLoader().getResource("icons/toback.gif");
    ImageIcon toBackIcon = new ImageIcon(toBackUrl);
    toback = new AbstractAction("", toBackIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -5942025518651424307L;

        public void actionPerformed(ActionEvent e) {
            if (!isSelectionEmpty()) {
                toBack(getSelectionCells());
            }
        }
    };
    toback.setEnabled(false);
    button = toolbar.add(toback);
    button.setText(""); //an icon-only button
    button.setToolTipText("To Back");

    return toolbar;
}