List of usage examples for javax.swing Action SHORT_DESCRIPTION
String SHORT_DESCRIPTION
To view the source code for javax.swing Action SHORT_DESCRIPTION.
Click Source Link
String
description for the action, used for tooltip text. From source file:ca.phon.ipamap.IpaMap.java
/** * Create the context menu based on source component *///from w w w . j a v a 2 s.c o m public void setupContextMenu(JPopupMenu menu, JComponent comp) { final CommonModuleFrame parentFrame = (CommonModuleFrame) SwingUtilities .getAncestorOfClass(CommonModuleFrame.class, comp); if (parentFrame != null) { final PhonUIAction toggleAlwaysOnTopAct = new PhonUIAction(parentFrame, "setAlwaysOnTop", !parentFrame.isAlwaysOnTop()); toggleAlwaysOnTopAct.putValue(PhonUIAction.NAME, "Always on top"); toggleAlwaysOnTopAct.putValue(PhonUIAction.SELECTED_KEY, parentFrame.isAlwaysOnTop()); final JCheckBoxMenuItem toggleAlwaysOnTopItem = new JCheckBoxMenuItem(toggleAlwaysOnTopAct); menu.add(toggleAlwaysOnTopItem); } // button options first if (comp instanceof CellButton) { CellButton btn = (CellButton) comp; Cell cell = btn.cell; // copy to clipboard options String cellData = cell.getText().replaceAll("" + (char) 0x25cc, ""); PhonUIAction copyToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", cellData); copyToClipboardAct.putValue(PhonUIAction.NAME, "Copy character (" + cell.getText() + ")"); JMenuItem copyToClipboardItem = new JMenuItem(copyToClipboardAct); menu.add(copyToClipboardItem); String htmlVal = new String(); for (Character c : cellData.toCharArray()) { htmlVal += "&#" + (int) c + ";"; } PhonUIAction copyHTMLToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", htmlVal); copyHTMLToClipboardAct.putValue(PhonUIAction.NAME, "Copy as HTML (" + htmlVal + ")"); JMenuItem copyHTMLToClipboardItem = new JMenuItem(copyHTMLToClipboardAct); menu.add(copyHTMLToClipboardItem); String hexVal = new String(); for (Character c : cellData.toCharArray()) { hexVal += (hexVal.length() > 0 ? " " : "") + Integer.toHexString((int) c); } hexVal = hexVal.toUpperCase(); PhonUIAction copyHEXToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", hexVal); copyHEXToClipboardAct.putValue(PhonUIAction.NAME, "Copy as Unicode HEX (" + hexVal + ")"); JMenuItem copyHEXToClipboardItem = new JMenuItem(copyHEXToClipboardAct); menu.add(copyHEXToClipboardItem); menu.addSeparator(); if (isInFavorites(cell)) { PhonUIAction removeFromFavAct = new PhonUIAction(this, "onRemoveCellFromFavorites", cell); removeFromFavAct.putValue(Action.NAME, "Remove from favorites"); removeFromFavAct.putValue(Action.SHORT_DESCRIPTION, "Remove button from list of favorites"); JMenuItem removeFromFavItem = new JMenuItem(removeFromFavAct); menu.add(removeFromFavItem); } else { PhonUIAction addToFavAct = new PhonUIAction(this, "onAddCellToFavorites", cell); addToFavAct.putValue(Action.NAME, "Add to favorites"); addToFavAct.putValue(Action.SHORT_DESCRIPTION, "Add button to list of favorites"); JMenuItem addToFavItem = new JMenuItem(addToFavAct); menu.add(addToFavItem); } menu.addSeparator(); } // section scroll-tos JMenuItem gotoTitleItem = new JMenuItem("Scroll to:"); gotoTitleItem.setEnabled(false); menu.add(gotoTitleItem); for (JXButton toggleBtn : toggleButtons) { PhonUIAction gotoAct = new PhonUIAction(this, "onGoto", toggleBtn); gotoAct.putValue(Action.NAME, toggleBtn.getText()); gotoAct.putValue(Action.SHORT_DESCRIPTION, "Scroll to " + toggleBtn.getText()); JMenuItem gotoItem = new JMenuItem(gotoAct); menu.add(gotoItem); } menu.addSeparator(); // setup font scaler final JLabel smallLbl = new JLabel("A"); smallLbl.setFont(getFont().deriveFont(12.0f)); smallLbl.setHorizontalAlignment(SwingConstants.CENTER); JLabel largeLbl = new JLabel("A"); largeLbl.setFont(getFont().deriveFont(24.0f)); largeLbl.setHorizontalAlignment(SwingConstants.CENTER); final JSlider scaleSlider = new JSlider(1, 101); scaleSlider.setValue((int) (scale * 100)); scaleSlider.setMajorTickSpacing(20); scaleSlider.setMinorTickSpacing(10); scaleSlider.setSnapToTicks(true); scaleSlider.setPaintTicks(true); scaleSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { int sliderVal = scaleSlider.getValue(); float scale = (float) sliderVal / (float) 100; _cFont = null; setSavedScale(scale); setScale(scale); } }); FormLayout scaleLayout = new FormLayout("3dlu, center:pref, fill:pref:grow, center:pref, 3dlu", "pref"); CellConstraints cc = new CellConstraints(); JPanel scalePanel = new JPanel(scaleLayout) { @Override public Insets getInsets() { Insets retVal = super.getInsets(); retVal.left += UIManager.getIcon("Tree.collapsedIcon").getIconWidth(); return retVal; } }; scalePanel.add(smallLbl, cc.xy(2, 1)); scalePanel.add(scaleSlider, cc.xy(3, 1)); scalePanel.add(largeLbl, cc.xy(4, 1)); JMenuItem scaleItem = new JMenuItem("Font size"); scaleItem.setEnabled(false); menu.add(scaleItem); menu.add(scalePanel); menu.addSeparator(); // highlighting PhonUIAction onToggleHighlightAct = new PhonUIAction(this, "onToggleHighlightRecent"); onToggleHighlightAct.putValue(PhonUIAction.NAME, "Highlight recently used"); onToggleHighlightAct.putValue(PhonUIAction.SELECTED_KEY, isHighlightRecent()); JCheckBoxMenuItem onToggleHighlightItm = new JCheckBoxMenuItem(onToggleHighlightAct); menu.add(onToggleHighlightItm); }
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Activates itself as a viewer by configuring Size, and location of itself, * and configures the default Tabbed Pane elements with the correct layout, * table columns, and sets itself viewable. *///ww w . ja v a2 s. c o m public void activateViewer() { LoggerRepository repo = LogManager.getLoggerRepository(); if (repo instanceof LoggerRepositoryEx) { this.pluginRegistry = ((LoggerRepositoryEx) repo).getPluginRegistry(); } initGUI(); initPrefModelListeners(); /** * We add a simple appender to the MessageCenter logger * so that each message is displayed in the Status bar */ MessageCenter.getInstance().getLogger().addAppender(new AppenderSkeleton() { protected void append(LoggingEvent event) { getStatusBar().setMessage(event.getMessage().toString()); } public void close() { } public boolean requiresLayout() { return false; } }); initSocketConnectionListener(); if (pluginRegistry.getPlugins(Receiver.class).size() == 0) { noReceiversDefined = true; } getFilterableColumns().add(ChainsawConstants.LEVEL_COL_NAME); getFilterableColumns().add(ChainsawConstants.LOGGER_COL_NAME); getFilterableColumns().add(ChainsawConstants.THREAD_COL_NAME); getFilterableColumns().add(ChainsawConstants.NDC_COL_NAME); getFilterableColumns().add(ChainsawConstants.PROPERTIES_COL_NAME); getFilterableColumns().add(ChainsawConstants.CLASS_COL_NAME); getFilterableColumns().add(ChainsawConstants.METHOD_COL_NAME); getFilterableColumns().add(ChainsawConstants.FILE_COL_NAME); getFilterableColumns().add(ChainsawConstants.NONE_COL_NAME); JPanel panePanel = new JPanel(); panePanel.setLayout(new BorderLayout(2, 2)); getContentPane().setLayout(new BorderLayout()); getTabbedPane().addChangeListener(getToolBarAndMenus()); getTabbedPane().addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { LogPanel thisLogPanel = getCurrentLogPanel(); if (thisLogPanel != null) { thisLogPanel.updateStatusBar(); } } }); KeyStroke ksRight = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); KeyStroke ksLeft = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); KeyStroke ksGotoLine = KeyStroke.getKeyStroke(KeyEvent.VK_G, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksRight, "MoveRight"); getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksLeft, "MoveLeft"); getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ksGotoLine, "GotoLine"); Action moveRight = new AbstractAction() { public void actionPerformed(ActionEvent e) { int temp = getTabbedPane().getSelectedIndex(); ++temp; if (temp != getTabbedPane().getTabCount()) { getTabbedPane().setSelectedTab(temp); } } }; Action moveLeft = new AbstractAction() { public void actionPerformed(ActionEvent e) { int temp = getTabbedPane().getSelectedIndex(); --temp; if (temp > -1) { getTabbedPane().setSelectedTab(temp); } } }; Action gotoLine = new AbstractAction() { public void actionPerformed(ActionEvent e) { String inputLine = JOptionPane.showInputDialog(LogUI.this, "Enter the line number to go:", "Goto Line", -1); try { int lineNumber = Integer.parseInt(inputLine); int row = getCurrentLogPanel().setSelectedEvent(lineNumber); if (row == -1) { JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid line number", "Error", 0); } } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid line number", "Error", 0); } } }; getTabbedPane().getActionMap().put("MoveRight", moveRight); getTabbedPane().getActionMap().put("MoveLeft", moveLeft); getTabbedPane().getActionMap().put("GotoLine", gotoLine); /** * We listen for double clicks, and auto-undock currently selected Tab if * the mouse event location matches the currently selected tab */ getTabbedPane().addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if ((e.getClickCount() > 1) && ((e.getModifiers() & InputEvent.BUTTON1_MASK) > 0)) { int tabIndex = getTabbedPane().getSelectedIndex(); if ((tabIndex != -1) && (tabIndex == getTabbedPane().getSelectedIndex())) { LogPanel logPanel = getCurrentLogPanel(); if (logPanel != null) { logPanel.undock(); } } } } }); panePanel.add(getTabbedPane()); addWelcomePanel(); getContentPane().add(toolbar, BorderLayout.NORTH); getContentPane().add(statusBar, BorderLayout.SOUTH); mainReceiverSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, panePanel, receiversPanel); dividerSize = mainReceiverSplitPane.getDividerSize(); mainReceiverSplitPane.setDividerLocation(-1); getContentPane().add(mainReceiverSplitPane, BorderLayout.CENTER); /** * We need to make sure that all the internal GUI components have been added to the * JFrame so that any plugns that get activated during initPlugins(...) method * have access to inject menus */ initPlugins(pluginRegistry); mainReceiverSplitPane.setResizeWeight(1.0); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { exit(); } }); preferencesFrame.setTitle("'Application-wide Preferences"); preferencesFrame.setIconImage(((ImageIcon) ChainsawIcons.ICON_PREFERENCES).getImage()); preferencesFrame.getContentPane().add(applicationPreferenceModelPanel); preferencesFrame.setSize(750, 520); Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); preferencesFrame.setLocation(new Point((screenDimension.width / 2) - (preferencesFrame.getSize().width / 2), (screenDimension.height / 2) - (preferencesFrame.getSize().height / 2))); pack(); final JPopupMenu tabPopup = new JPopupMenu(); final Action hideCurrentTabAction = new AbstractAction("Hide") { public void actionPerformed(ActionEvent e) { Component selectedComp = getTabbedPane().getSelectedComponent(); if (selectedComp instanceof LogPanel) { displayPanel(getCurrentLogPanel().getIdentifier(), false); tbms.stateChange(); } else { getTabbedPane().remove(selectedComp); } } }; final Action hideOtherTabsAction = new AbstractAction("Hide Others") { public void actionPerformed(ActionEvent e) { Component selectedComp = getTabbedPane().getSelectedComponent(); String currentName; if (selectedComp instanceof LogPanel) { currentName = getCurrentLogPanel().getIdentifier(); } else if (selectedComp instanceof WelcomePanel) { currentName = ChainsawTabbedPane.WELCOME_TAB; } else { currentName = ChainsawTabbedPane.ZEROCONF; } int count = getTabbedPane().getTabCount(); int index = 0; for (int i = 0; i < count; i++) { String name = getTabbedPane().getTitleAt(index); if (getPanelMap().keySet().contains(name) && !name.equals(currentName)) { displayPanel(name, false); tbms.stateChange(); } else { index++; } } } }; Action showHiddenTabsAction = new AbstractAction("Show All Hidden") { public void actionPerformed(ActionEvent e) { for (Iterator iter = getPanels().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); Boolean docked = (Boolean) entry.getValue(); if (docked.booleanValue()) { String identifier = (String) entry.getKey(); int count = getTabbedPane().getTabCount(); boolean found = false; for (int i = 0; i < count; i++) { String name = getTabbedPane().getTitleAt(i); if (name.equals(identifier)) { found = true; break; } } if (!found) { displayPanel(identifier, true); tbms.stateChange(); } } } } }; tabPopup.add(hideCurrentTabAction); tabPopup.add(hideOtherTabsAction); tabPopup.addSeparator(); tabPopup.add(showHiddenTabsAction); final PopupListener tabPopupListener = new PopupListener(tabPopup); getTabbedPane().addMouseListener(tabPopupListener); this.handler.addPropertyChangeListener("dataRate", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { double dataRate = ((Double) evt.getNewValue()).doubleValue(); statusBar.setDataRate(dataRate); } }); getSettingsManager().addSettingsListener(this); getSettingsManager().addSettingsListener(MRUFileListPreferenceSaver.getInstance()); getSettingsManager().addSettingsListener(receiversPanel); try { //if an uncaught exception is thrown, allow the UI to continue to load getSettingsManager().loadSettings(); } catch (Exception e) { e.printStackTrace(); } //app preferences have already been loaded (and configuration url possibly set to blank if being overridden) //but we need a listener so the settings will be saved on exit (added after loadsettings was called) getSettingsManager().addSettingsListener(new ApplicationPreferenceModelSaver(applicationPreferenceModel)); setVisible(true); if (applicationPreferenceModel.isReceivers()) { showReceiverPanel(); } else { hideReceiverPanel(); } removeSplash(); synchronized (initializationLock) { isGUIFullyInitialized = true; initializationLock.notifyAll(); } if (noReceiversDefined && applicationPreferenceModel.isShowNoReceiverWarning()) { SwingHelper.invokeOnEDT(new Runnable() { public void run() { showReceiverConfigurationPanel(); } }); } Container container = tutorialFrame.getContentPane(); final JEditorPane tutorialArea = new JEditorPane(); tutorialArea.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); tutorialArea.setEditable(false); container.setLayout(new BorderLayout()); try { tutorialArea.setPage(ChainsawConstants.TUTORIAL_URL); JTextComponentFormatter.applySystemFontAndSize(tutorialArea); container.add(new JScrollPane(tutorialArea), BorderLayout.CENTER); } catch (Exception e) { MessageCenter.getInstance().getLogger().error("Error occurred loading the Tutorial", e); } tutorialFrame.setIconImage(new ImageIcon(ChainsawIcons.HELP).getImage()); tutorialFrame.setSize(new Dimension(640, 480)); final Action startTutorial = new AbstractAction("Start Tutorial", new ImageIcon(ChainsawIcons.ICON_RESUME_RECEIVER)) { public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(null, "This will start 3 \"Generator\" receivers for use in the Tutorial. Is that ok?", "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { new Thread(new Tutorial()).start(); putValue("TutorialStarted", Boolean.TRUE); } else { putValue("TutorialStarted", Boolean.FALSE); } } }; final Action stopTutorial = new AbstractAction("Stop Tutorial", new ImageIcon(ChainsawIcons.ICON_STOP_RECEIVER)) { public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(null, "This will stop all of the \"Generator\" receivers used in the Tutorial, but leave any other Receiver untouched. Is that ok?", "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { new Thread(new Runnable() { public void run() { LoggerRepository repo = LogManager.getLoggerRepository(); if (repo instanceof LoggerRepositoryEx) { PluginRegistry pluginRegistry = ((LoggerRepositoryEx) repo).getPluginRegistry(); List list = pluginRegistry.getPlugins(Generator.class); for (Iterator iter = list.iterator(); iter.hasNext();) { Plugin plugin = (Plugin) iter.next(); pluginRegistry.stopPlugin(plugin.getName()); } } } }).start(); setEnabled(false); startTutorial.putValue("TutorialStarted", Boolean.FALSE); } } }; stopTutorial.putValue(Action.SHORT_DESCRIPTION, "Removes all of the Tutorials Generator Receivers, leaving all other Receivers untouched"); startTutorial.putValue(Action.SHORT_DESCRIPTION, "Begins the Tutorial, starting up some Generator Receivers so you can see Chainsaw in action"); stopTutorial.setEnabled(false); final SmallToggleButton startButton = new SmallToggleButton(startTutorial); PropertyChangeListener pcl = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { stopTutorial.setEnabled(((Boolean) startTutorial.getValue("TutorialStarted")).equals(Boolean.TRUE)); startButton.setSelected(stopTutorial.isEnabled()); } }; startTutorial.addPropertyChangeListener(pcl); stopTutorial.addPropertyChangeListener(pcl); pluginRegistry.addPluginListener(new PluginListener() { public void pluginStarted(PluginEvent e) { } public void pluginStopped(PluginEvent e) { List list = pluginRegistry.getPlugins(Generator.class); if (list.size() == 0) { startTutorial.putValue("TutorialStarted", Boolean.FALSE); } } }); final SmallButton stopButton = new SmallButton(stopTutorial); final JToolBar tutorialToolbar = new JToolBar(); tutorialToolbar.setFloatable(false); tutorialToolbar.add(startButton); tutorialToolbar.add(stopButton); container.add(tutorialToolbar, BorderLayout.NORTH); tutorialArea.addHyperlinkListener(new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { if (e.getDescription().equals("StartTutorial")) { startTutorial.actionPerformed(null); } else if (e.getDescription().equals("StopTutorial")) { stopTutorial.actionPerformed(null); } else { try { tutorialArea.setPage(e.getURL()); } catch (IOException e1) { MessageCenter.getInstance().getLogger() .error("Failed to change the URL for the Tutorial", e1); } } } } }); /** * loads the saved tab settings and if there are hidden tabs, * hide those tabs out of currently loaded tabs.. */ if (!getTabbedPane().tabSetting.isWelcome()) { displayPanel(ChainsawTabbedPane.WELCOME_TAB, false); } if (!getTabbedPane().tabSetting.isZeroconf()) { displayPanel(ChainsawTabbedPane.ZEROCONF, false); } tbms.stateChange(); }
From source file:org.gtdfree.GTDFree.java
private ActionMap getActionMap() { if (actionMap == null) { actionMap = new ActionMap(); AbstractAction a = new AbstractAction(Messages.getString("GTDFree.View.Closed")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override/*from ww w . j a v a 2s. c om*/ public void actionPerformed(ActionEvent e) { getEngine().getGlobalProperties().putProperty(GlobalProperties.SHOW_ALL_ACTIONS, !getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_ALL_ACTIONS)); } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.View.Closed.desc")); //$NON-NLS-1$ actionMap.put(GlobalProperties.SHOW_ALL_ACTIONS, a); a = new AbstractAction(Messages.getString("GTDFree.View.Empty")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { getEngine().getGlobalProperties().putProperty(GlobalProperties.SHOW_EMPTY_FOLDERS, !getEngine() .getGlobalProperties().getBoolean(GlobalProperties.SHOW_EMPTY_FOLDERS, true)); } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.View.Empty.desc")); //$NON-NLS-1$ actionMap.put(GlobalProperties.SHOW_EMPTY_FOLDERS, a); a = new AbstractAction(Messages.getString("GTDFree.View.ClosedLists")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { getEngine().getGlobalProperties().putProperty(GlobalProperties.SHOW_CLOSED_FOLDERS, !getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_CLOSED_FOLDERS)); } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.View.ClosedLists.desc")); //$NON-NLS-1$ actionMap.put(GlobalProperties.SHOW_CLOSED_FOLDERS, a); a = new AbstractAction(Messages.getString("GTDFree.View.Overview")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { getEngine().getGlobalProperties().putProperty(GlobalProperties.SHOW_OVERVIEW_TAB, !getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_OVERVIEW_TAB)); } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.View.Overview.desc")); //$NON-NLS-1$ actionMap.put(GlobalProperties.SHOW_OVERVIEW_TAB, a); a = new AbstractAction(Messages.getString("GTDFree.View.Quick")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { getEngine().getGlobalProperties().putProperty(GlobalProperties.SHOW_QUICK_COLLECT, !getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_QUICK_COLLECT)); } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.View.Quick.desc")); //$NON-NLS-1$ actionMap.put(GlobalProperties.SHOW_QUICK_COLLECT, a); a = new AbstractAction(Messages.getString("GTDFree.View.Tray")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { boolean b = !getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_TRAY_ICON); getEngine().getGlobalProperties().putProperty(GlobalProperties.SHOW_TRAY_ICON, b); if (b) { try { SystemTray.getSystemTray().add(getTrayIcon()); } catch (AWTException e1) { Logger.getLogger(this.getClass()).error("System tray icon initialization failed.", e1); //$NON-NLS-1$ } } else { SystemTray.getSystemTray().remove(getTrayIcon()); } } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.View.Tray.desc")); //$NON-NLS-1$ a.setEnabled(SystemTray.isSupported()); actionMap.put(GlobalProperties.SHOW_TRAY_ICON, a); a = new AbstractAction(Messages.getString("GTDFree.ImportExamples")) { //$NON-NLS-1$ private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent e) { getImportDialog().getDialog(getJFrame()).setVisible(true); } }; a.putValue(Action.SHORT_DESCRIPTION, Messages.getString("GTDFree.ImportExamples.desc")); //$NON-NLS-1$ actionMap.put("importDialog", a); //$NON-NLS-1$ } return actionMap; }
From source file:com.mirth.connect.client.ui.Frame.java
/** * Initializes the bound method call for the task pane actions and adds them to the * taskpane/popupmenu./* w ww . j av a 2 s .c om*/ */ public int addTask(String callbackMethod, String displayName, String toolTip, String shortcutKey, ImageIcon icon, JXTaskPane pane, JPopupMenu menu, Object handler) { BoundAction boundAction = ActionFactory.createBoundAction(callbackMethod, displayName, shortcutKey); if (icon != null) { boundAction.putValue(Action.SMALL_ICON, icon); } boundAction.putValue(Action.SHORT_DESCRIPTION, toolTip); boundAction.registerCallback(handler, callbackMethod); Component component = pane.add(boundAction); getComponentTaskMap().put(component, callbackMethod); if (menu != null) { menu.add(boundAction); } return (pane.getContentPane().getComponentCount() - 1); }
From source file:com.diversityarrays.kdxplore.curate.TrialDataEditor.java
private JSplitPane createStatsAndSamplesTable(JComponent top) { curationTableModel.addPropertyChangeListener(CurationTableModel.PROPERTY_TRAIT_INSTANCES, traitInstancesChanged);/*from ww w. j av a 2s. co m*/ onlyUneditedCheckbox.addActionListener(filtersActionListener); hideInactivePlots.addActionListener(filtersActionListener); if (onlyRowsWithScoresCheckbox != null) { onlyRowsWithScoresCheckbox.addActionListener(filtersActionListener); onlyRowsWithScoresCheckbox.setEnabled(curationTableModel.hasAnyTraitInstanceColumns()); } JComponent tagFilters = null; if (!curationData.getSortedTagLabels().isEmpty()) { tagFilters = tagLabelFiltersButton; } JComponent posFilters = null; if (curationData.hasAnySpecimens()) { updatePlotSpecimenIcon(); posFilters = plotOrSpecimenFilterButton; } plotOrSpecimenFilterAction.putValue(Action.LARGE_ICON_KEY, inactivePlotOrSpecimenFilterIcon); plotOrSpecimenFilterAction.putValue(Action.SHORT_DESCRIPTION, "Filter on Plot/Specimen"); tagLabelFiltersAction.putValue(Action.LARGE_ICON_KEY, inactiveTagFilterIcon); tagLabelFiltersAction.putValue(Action.SHORT_DESCRIPTION, "Filter on Tags"); curationTablePanel = new TitledTablePanelWithResizeControls(SAMPLES_TABLE_NAME, curationTable, smallFont, hideInactivePlots, onlyUneditedCheckbox, onlyRowsWithScoresCheckbox, tagFilters, posFilters, new JButton(curationHelpAction)); // curationTablePanel.scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, // makeUndockButton()); Transformer<TraitInstance, Color> traitInstanceColorProvider = new Transformer<TraitInstance, Color>() { @Override public Color transform(TraitInstance ti) { ColorPair cp = colorProviderFactory.get().getTraitInstanceColor(ti); return cp.getBackground(); } }; markerPanelManager = new MarkerPanelManager(curationData.getTrial(), curationTableModel, curationTable, curationTablePanel, traitInstanceColorProvider, curationTableSelectionModel); // fieldViewIcon = KDClientUtils.getIcon(ImageId.FIELD_VIEW_24); samplesTableIcon = KDClientUtils.getIcon(ImageId.TABLE_24); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, top, curationTablePanel); splitPane.setResizeWeight(0.3); splitPane.setOneTouchExpandable(true); return splitPane; }
From source file:edu.ku.brc.ui.UIRegistry.java
/** * @param action//w w w . j a va 2 s .co m * @param name * @param icon * @param toolTip * @param mnemonicKeyCode * @param acceleratorKey * @return */ public Action makeAction(Action action, String name, ImageIcon icon, String toolTip, Integer mnemonicKeyCode, KeyStroke acceleratorKey) { if (name != null) action.putValue(Action.NAME, name); if (icon != null) action.putValue(Action.SMALL_ICON, icon); if (toolTip != null) action.putValue(Action.SHORT_DESCRIPTION, toolTip); if (mnemonicKeyCode != null) action.putValue(Action.MNEMONIC_KEY, mnemonicKeyCode); if (acceleratorKey != null) action.putValue(Action.ACCELERATOR_KEY, acceleratorKey); return action; }
From source file:src.gui.ItSIMPLE.java
/** * This method initializes newMenuItem *//www .j av a 2 s . co 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; }