Example usage for javax.swing JMenuItem getToolTipText

List of usage examples for javax.swing JMenuItem getToolTipText

Introduction

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

Prototype

public String getToolTipText() 

Source Link

Document

Returns the tooltip string that has been set with setToolTipText.

Usage

From source file:com.pironet.tda.TDA.java

/**
 * check menu and button events./*ww w  .  ja  v  a  2s  .  co m*/
 */
public void actionPerformed(ActionEvent e) {
    if (e.getSource() instanceof JMenuItem) {
        JMenuItem source = (JMenuItem) (e.getSource());
        if (source.getText().substring(1).startsWith(":\\") || source.getText().startsWith("/")) {
            if (source.getText().endsWith(".tsf")) {
                try {
                    loadSession(new File(source.getText()), true);
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            } else {
                dumpFile = source.getText();
                openFiles(new File[] { new File(dumpFile) }, true);
            }
        } else if ("Open...".equals(source.getText())) {
            chooseFile();
        } else if ("Open loggc file...".equals(source.getText())) {
            openLoggcFile();
        } else if ("Save Logfile...".equals(source.getText())) {
            saveLogFile();
        } else if ("Save Session...".equals(source.getText())) {
            saveSession();
        } else if ("Open Session...".equals(source.getText())) {
            openSession();
        } else if ("Preferences".equals(source.getText())) {
            showPreferencesDialog();
        } else if ("Filters".equals(source.getText())) {
            showFilterDialog();
        } else if ("Categories".equals(source.getText())) {
            showCategoriesDialog();
        } else if ("Get Logfile from clipboard".equals(source.getText())) {
            getLogfileFromClipboard();
        } else if ("Exit TDA".equals(source.getText())) {
            saveState();
            frame.dispose();
        } else if (ResourceManager.translate("help.contents").equals(source.getText())) {
            showHelp();
        } else if ("Help".equals(source.getText())) {
            showHelp();
        } else if ("Release Notes".equals(source.getText())) {
            showInfoFile("Release Notes", "doc/README", Const.ICON_DOCUMENT);
        } else if ("License".equals(source.getText())) {
            showInfoFile("License Information", "doc/COPYING", Const.ICON_DOCUMENT);
        } else if ("Forum".equals(source.getText())) {
            try {
                Browser.open("https://tda.dev.java.net/servlets/ForumMessageList?forumID=1967");
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(this.getRootPane(),
                        "Error opening TDA Online Forum\nPlease open https://tda.dev.java.net/servlets/ForumMessageList?forumID=1967 in your browser!",
                        "Error", JOptionPane.ERROR_MESSAGE);
            }
        } else if ("About TDA".equals(source.getText())) {
            showInfo();
        } else if ("Search...".equals(source.getText())) {
            showSearchDialog();
        } else if ("Parse loggc-logfile...".equals(source.getText())) {
            parseLoggcLogfile();
        } else if ("Find long running threads...".equals(source.getText())) {
            findLongRunningThreads();
        } else if (("Close logfile...".equals(source.getText())) || ("Close...".equals(source.getText()))) {
            closeCurrentDump();
        } else if ("Close all...".equals(source.getText())) {
            closeAllDumps();
        } else if ("Diff Selection".equals(source.getText())) {
            final TreePath[] paths = tree.getSelectionPaths();
            if (paths != null) {
                if ((paths.length < 2)) {
                    JOptionPane.showMessageDialog(this.getRootPane(),
                            "You must select at least two dumps for getting a diff!\n", "Error",
                            JOptionPane.ERROR_MESSAGE);

                } else {
                    DefaultMutableTreeNode mergeRoot = fetchTop(tree.getSelectionPath());
                    Map dumpMap = dumpStore.getFromDumpFiles(mergeRoot.getUserObject().toString());
                    ((Logfile) mergeRoot.getUserObject()).getUsedParser().mergeDumps(mergeRoot, dumpMap, paths,
                            paths.length, null);
                    createTree();
                    this.getRootPane().revalidate();
                }
            }
        } else if ("Show selected Dump in logfile".equals(source.getText())) {
            navigateToDumpInLogfile();
        } else if ("Show Toolbar".equals(source.getText())) {
            setShowToolbar(((JCheckBoxMenuItem) source).getState());
        } else if ("Request Thread Dump...".equals(source.getText())) {
            addMXBeanDump();
        } else if ("Expand all nodes".equals(source.getText())) {
            expandAllCatNodes(true);
        } else if ("Collapse all nodes".equals(source.getText())) {
            expandAllCatNodes(false);
        } else if ("Sort by thread count".equals(source.getText())) {
            sortCatByThreads();
        } else if ("Expand all Dump nodes".equals(source.getText())) {
            expandAllDumpNodes(true);
        } else if ("Collapse all Dump nodes".equals(source.getText())) {
            expandAllDumpNodes(false);
        }
    } else if (e.getSource() instanceof JButton) {
        JButton source = (JButton) e.getSource();
        if ("Open Logfile".equals(source.getToolTipText())) {
            chooseFile();
        } else if ("Close selected Logfile".equals(source.getToolTipText())) {
            closeCurrentDump();
        } else if ("Get Logfile from clipboard".equals(source.getToolTipText())) {
            getLogfileFromClipboard();
        } else if ("Preferences".equals(source.getToolTipText())) {
            showPreferencesDialog();
        } else if ("Find long running threads".equals(source.getToolTipText())) {
            findLongRunningThreads();
        } else if ("Expand all nodes".equals(source.getToolTipText())) {
            expandAllDumpNodes(true);
        } else if ("Collapse all nodes".equals(source.getToolTipText())) {
            expandAllDumpNodes(false);
        } else if ("Find long running threads".equals(source.getToolTipText())) {
            findLongRunningThreads();
        } else if ("Filters".equals(source.getToolTipText())) {
            showFilterDialog();
        } else if ("Custom Categories".equals(source.getToolTipText())) {
            showCategoriesDialog();
        } else if ("Request a Thread Dump".equals(source.getToolTipText())) {
            addMXBeanDump();
        } else if ("Help".equals(source.getToolTipText())) {
            showHelp();
        }
        source.setSelected(false);
    }
}

From source file:org.kepler.gui.MenuMapper.java

/**
 * Recurse through all the submenu heirarchy beneath the passed JMenu
 * parameter, and for each "leaf node" (ie a menu item that is not a
 * container for other menu items), add the Action and its menu path to the
 * passed Map//from   w w w  .  ja v a2 s  . c  o m
 * 
 * @param nextMenuItem
 *            the JMenu to recurse into
 * @param menuPathBuff
 *            a delimited String representation of the hierarchical "path"
 *            to this menu item. This will be used as the key in the
 *            actionsMap. For example, the "Graph Editor" menu item beneath
 *            the "New" item on the "File" menu would have a menuPath of
 *            File->New->Graph Editor. Delimeter is "->" (no quotes), and
 *            spaces are allowed within menu text strings, but not around
 *            the delimiters; i.e: New->Graph Editor is OK, but File ->New
 *            is not.
 * @param MENU_PATH_DELIMITER
 *            String
 * @param actionsMap
 *            the Map containing key => value pairs of the form: menuPath
 *            (as described above) => Action (the javax.swing.Action
 *            assigned to this menu item)
 */
public static void storePTIIMenuItems(JMenuItem nextMenuItem, StringBuffer menuPathBuff,
        final String MENU_PATH_DELIMITER, Map<String, Action> actionsMap) {

    menuPathBuff.append(MENU_PATH_DELIMITER);
    if (nextMenuItem != null && nextMenuItem.getText() != null) {
        String str = nextMenuItem.getText();
        // do not make the recent files menu item upper case since
        // it contains paths in the file system.
        if (menuPathBuff.toString().startsWith("FILE->RECENT FILES->")) {
            menuPathBuff = new StringBuffer("File->Recent Files->");
        } else {
            str = str.toUpperCase();
        }
        menuPathBuff.append(str);
    }

    if (isDebugging) {
        log.debug(menuPathBuff.toString());
    }
    // System.out.println(menuPathBuff.toString());

    if (nextMenuItem instanceof JMenu) {
        storePTIITopLevelMenus((JMenu) nextMenuItem, menuPathBuff.toString(), MENU_PATH_DELIMITER, actionsMap);
    } else {
        Action nextAction = nextMenuItem.getAction();
        // if there is no Action, look for an ActionListener
        // System.out.println("Processing menu " + nextMenuItem.getText());
        if (nextAction == null) {
            final ActionListener[] actionListeners = nextMenuItem.getActionListeners();
            // System.out.println("No Action for " + nextMenuItem.getText()
            // + "; found " + actionListeners.length
            // + " ActionListeners");
            if (actionListeners.length > 0) {
                if (isDebugging) {
                    log.debug(actionListeners[0].getClass().getName());
                }
                // ASSUMPTION: there is only one ActionListener
                nextAction = new AbstractAction() {
                    public void actionPerformed(ActionEvent a) {
                        actionListeners[0].actionPerformed(a);
                    }
                };
                // add all these values - @see diva.gui.GUIUtilities
                nextAction.putValue(Action.NAME, nextMenuItem.getText());
                // System.out.println("storing ptII action for menu " +
                // nextMenuItem.getText());
                nextAction.putValue(GUIUtilities.LARGE_ICON, nextMenuItem.getIcon());
                nextAction.putValue(GUIUtilities.MNEMONIC_KEY, new Integer(nextMenuItem.getMnemonic()));
                nextAction.putValue("tooltip", nextMenuItem.getToolTipText());
                nextAction.putValue(GUIUtilities.ACCELERATOR_KEY, nextMenuItem.getAccelerator());
                nextAction.putValue("menuItem", nextMenuItem);
            } else {
                if (isDebugging) {
                    log.warn("No Action or ActionListener found for " + nextMenuItem.getText());
                }
            }
        }
        if (!actionsMap.containsValue(nextAction)) {
            actionsMap.put(menuPathBuff.toString(), nextAction);
            if (isDebugging) {
                log.debug(menuPathBuff.toString() + " :: ACTION: " + nextAction);
            }
        }
    }
}

From source file:org.openmicroscopy.shoola.env.ui.TaskBarView.java

/**
 * Makes and returns a copy of the specified item.
 *
 * @param original The item to handle./*from  w ww.  ja  v a  2s . co m*/
 * @return See above.
 */
private JMenuItem copyItem(JMenuItem original) {
    JMenuItem item = new JMenuItem(original.getAction());
    item.setIcon(original.getIcon());
    item.setText(original.getText());
    item.setToolTipText(original.getToolTipText());
    ActionListener[] al = original.getActionListeners();
    for (int j = 0; j < al.length; j++)
        item.addActionListener(al[j]);
    return item;
}