Example usage for javax.swing Action putValue

List of usage examples for javax.swing Action putValue

Introduction

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

Prototype

public void putValue(String key, Object value);

Source Link

Document

Sets one of this object's properties using the associated key.

Usage

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

/**
 * //from   w  ww.  ja  v  a 2  s  . 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

/**
 * //from  w  w  w .j av  a 2  s  .  co 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:net.sf.jabref.gui.JabRefFrame.java

private static Action enableToggle(Action a, boolean initialValue) {
    // toggle only works correctly when the SELECTED_KEY is set to false or true explicitly upon start
    a.putValue(Action.SELECTED_KEY, String.valueOf(initialValue));

    return a;//from www.j  a v  a2s  . c o  m
}

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

/**
 * //from www .  j a  v a2  s  .co  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

/**
 * /* ww w  . j  a  v  a2s. co  m*/
 * @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:com.intuit.tank.tools.debugger.ActionProducer.java

/**
 * /*from   ww  w . j  ava 2  s . co  m*/
 * @return
 */
public Action getShowVariablesAction() {
    Action ret = actionMap.get(ACTION_SHOW_VARIABLES);
    if (ret == null) {
        ret = new AbstractAction(ACTION_SHOW_VARIABLES, getIcon("data_grid.png", IconSize.SMALL)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    new VariableDialog(debuggerFrame, debuggerFrame.getProjectVariables()).setVisible(true);
                } catch (Exception e1) {
                    showError("Error downloading datafiles: " + e1);
                }
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, "Display and edit project variables.");
        actionMap.put(ACTION_SHOW_VARIABLES, ret);
    }
    return ret;
}

From source file:com.diversityarrays.kdxplore.KDXploreFrame.java

private JMenuBar buildMenuBar() {

    RunMode runMode = RunMode.getRunMode();

    JMenuBar mb = new JMenuBar();

    mb.add(createMainMenu(runMode));//from ww w. java  2 s. c  o  m

    if (!backupProviders.isEmpty()) {
        String toolsMenuLabel = Msg.MENU_TOOLS();
        JMenu toolsMenu = new JMenu(toolsMenuLabel);
        mb.add(toolsMenu);
        for (Action a : pluginInfo.getToolsMenuActions()) {
            toolsMenu.add(a);
        }

        Action backupAction = new AbstractAction(Msg.MENUITEM_BACKUP_DB()) {
            @Override
            public void actionPerformed(ActionEvent e) {
                doBackupDatabase();
            }
        };
        backupAction.putValue(Action.SMALL_ICON, KDClientUtils.getIcon(ImageId.DB_BACKUP));

        toolsMenu.add(backupAction);
        boolean seen = false;
        for (BackupProvider bp : backupProviders) {
            Action a = bp.getOfflineDataAction();
            if (a != null) {
                if (!seen) {
                    seen = true;
                    toolsMenu.add(new JSeparator());
                }
                toolsMenu.add(a);
            }
        }
    }

    mb.add(frameWindowOpener.getWindowsMenu());
    mb.add(createHelpMenu());

    return mb;
}

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

/**
 * /*from w ww  . j a v  a  2 s  .co  m*/
 * @return
 */
public Action getFindAction() {
    Action ret = actionMap.get(ACTION_FIND);
    if (ret == null) {
        ret = new AbstractAction(ACTION_FIND, getIcon("find.png", IconSize.SMALL)) {
            private static final long serialVersionUID = 1L;
            private FindReplaceDialog dialog;

            @Override
            public void actionPerformed(ActionEvent event) {
                try {
                    if (dialog == null) {
                        dialog = new FindReplaceDialog(debuggerFrame, DialogType.SEARCH);
                    }
                    dialog.setVisible(true);
                } catch (HeadlessException e) {
                    showError("Error opening file: " + e);
                }
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, "Find in script.");
        ret.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke('F', menuActionMods));
        ret.putValue(Action.MNEMONIC_KEY, new Integer('F'));
        ret.setEnabled(false);
        actionMap.put(ACTION_FIND, ret);
    }
    return ret;
}

From source file:ca.phon.ipamap.IpaMap.java

private JXButton getToggleButton(Grid grid, JXCollapsiblePane cp) {
    Action toggleAction = cp.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION);

    // use the collapse/expand icons from the JTree UI
    toggleAction.putValue(JXCollapsiblePane.COLLAPSE_ICON, UIManager.getIcon("Tree.expandedIcon"));
    toggleAction.putValue(JXCollapsiblePane.EXPAND_ICON, UIManager.getIcon("Tree.collapsedIcon"));
    toggleAction.putValue(Action.NAME, grid.getName());

    JXButton btn = new JXButton(toggleAction) {
        @Override//from w  w  w  .  ja  v  a  2s  .com
        public Insets getInsets() {
            Insets retVal = super.getInsets();

            retVal.top = 0;
            retVal.bottom = 0;

            return retVal;
        }

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(0, 20);
        }

    };

    btn.setHorizontalAlignment(SwingConstants.LEFT);

    btn.setBackgroundPainter(new Painter<JXButton>() {

        @Override
        public void paint(Graphics2D g, JXButton object, int width, int height) {
            MattePainter mp = new MattePainter(UIManager.getColor("Button.background"));
            mp.paint(g, object, width, height);
        }
    });

    btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    btn.setBorderPainted(false);
    btn.setFocusable(false);

    btn.putClientProperty("JComponent.sizeVariant", "small");

    btn.revalidate();

    return btn;
}

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

/**
 * //w ww. j  a v  a2  s.  co m
 * @return
 */
public Action getSelectDataFileAction() {
    Action ret = actionMap.get(ACTION_CHOOSE_DATAFILE);
    if (ret == null) {
        ret = new AbstractAction(ACTION_CHOOSE_DATAFILE, getIcon("table_lightning.png", IconSize.SMALL)) {
            private static final long serialVersionUID = 1L;

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    List<DataFileDescriptor> dataFiles = dataFileClient.getDataFiles();
                    Collections.sort(dataFiles, new Comparator<DataFileDescriptor>() {
                        public int compare(DataFileDescriptor o1, DataFileDescriptor o2) {
                            return o2.getName().compareTo(o1.getName());
                        }
                    });
                    SelectDialog<DataFileDescriptor> selectDialog = new SelectDialog<DataFileDescriptor>(
                            debuggerFrame, dataFiles, "datafiles", false);
                    selectDialog.setVisible(true);
                    List<DataFileDescriptor> selectedObjects = selectDialog.getSelectedObjects();
                    if (!selectedObjects.isEmpty()) {
                        debuggerFrame.setDataFiles(selectedObjects);
                    }
                } catch (Exception e1) {
                    showError("Error downloading datafiles: " + e1);
                }
            }
        };
        ret.putValue(Action.SHORT_DESCRIPTION, "Choose Datafiles from Tank.");
        actionMap.put(ACTION_CHOOSE_DATAFILE, ret);
    }
    return ret;
}