List of usage examples for javax.swing JCheckBoxMenuItem addActionListener
public void addActionListener(ActionListener l)
ActionListener
to the button. From source file:edu.ku.brc.specify.Specify.java
/** * Create menus/*w w w . j av a 2s .c o m*/ */ public JMenuBar createMenus() { JMenuBar mb = new JMenuBar(); JMenuItem mi; //-------------------------------------------------------------------- //-- File Menu //-------------------------------------------------------------------- JMenu menu = null; if (!UIHelper.isMacOS() || !isWorkbenchOnly) { menu = UIHelper.createLocalizedMenu(mb, "Specify.FILE_MENU", "Specify.FILE_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$ } if (!isWorkbenchOnly) { // Add Menu for switching Collection String title = "Specify.CHANGE_COLLECTION"; //$NON-NLS-1$ String mnu = "Specify.CHANGE_COLL_MNEU"; //$NON-NLS-1$ changeCollectionMenuItem = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, false, null); changeCollectionMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { if (SubPaneMgr.getInstance().aboutToShutdown()) { // Actually we really need to start over // "true" means that it should NOT use any cached values it can find to automatically initialize itself // instead it should ask the user any questions as if it were starting over restartApp(null, databaseName, userName, true, false); } } }); menu.addMenuListener(new MenuListener() { @Override public void menuCanceled(MenuEvent e) { } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuSelected(MenuEvent e) { boolean enable = Uploader.getCurrentUpload() == null && ((SpecifyAppContextMgr) AppContextMgr.getInstance()).getNumOfCollectionsForUser() > 1 && !TaskMgr.areTasksDisabled(); changeCollectionMenuItem.setEnabled(enable); } }); } if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) { if (!UIRegistry.isMobile()) { menu.addSeparator(); } String title = "Specify.EXIT"; //$NON-NLS-1$ String mnu = "Specify.Exit_MNEU"; //$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, true, null); if (!UIHelper.isMacOS()) { mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK)); } mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { doExit(true); } }); } menu = UIRegistry.getInstance().createEditMenu(); mb.add(menu); //menu = UIHelper.createMenu(mb, "EditMenu", "EditMneu"); if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) { menu.addSeparator(); String title = "Specify.PREFERENCES"; //$NON-NLS-1$ String mnu = "Specify.PREFERENCES_MNEU";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, false, null); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { doPreferences(); } }); mi.setEnabled(true); } //-------------------------------------------------------------------- //-- Data Menu //-------------------------------------------------------------------- JMenu dataMenu = UIHelper.createLocalizedMenu(mb, "Specify.DATA_MENU", "Specify.DATA_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$ ResultSetController.addMenuItems(dataMenu); dataMenu.addSeparator(); // Save And New Menu Item Action saveAndNewAction = new AbstractAction(getResourceString("Specify.SAVE_AND_NEW")) { //$NON-NLS-1$ public void actionPerformed(ActionEvent e) { FormViewObj fvo = getCurrentFVO(); if (fvo != null) { fvo.setSaveAndNew(((JCheckBoxMenuItem) e.getSource()).isSelected()); } } }; saveAndNewAction.setEnabled(false); JCheckBoxMenuItem saveAndNewCBMI = new JCheckBoxMenuItem(saveAndNewAction); dataMenu.add(saveAndNewCBMI); UIRegistry.register("SaveAndNew", saveAndNewCBMI); //$NON-NLS-1$ UIRegistry.registerAction("SaveAndNew", saveAndNewAction); //$NON-NLS-1$ mb.add(dataMenu); // Configure Carry Forward Action configCarryForwardAction = new AbstractAction( getResourceString("Specify.CONFIG_CARRY_FORWARD_MENU")) { //$NON-NLS-1$ public void actionPerformed(ActionEvent e) { FormViewObj fvo = getCurrentFVO(); if (fvo != null) { fvo.configureCarryForward(); } } }; configCarryForwardAction.setEnabled(false); JMenuItem configCFWMI = new JMenuItem(configCarryForwardAction); dataMenu.add(configCFWMI); UIRegistry.register("ConfigCarryForward", configCFWMI); //$NON-NLS-1$ UIRegistry.registerAction("ConfigCarryForward", configCarryForwardAction); //$NON-NLS-1$ mb.add(dataMenu); //--------------------------------------- // Carry Forward Menu Item (On / Off) Action carryForwardAction = new AbstractAction(getResourceString("Specify.CARRY_FORWARD_CHECKED_MENU")) { //$NON-NLS-1$ public void actionPerformed(ActionEvent e) { FormViewObj fvo = getCurrentFVO(); if (fvo != null) { fvo.toggleCarryForward(); ((JCheckBoxMenuItem) e.getSource()).setSelected(fvo.isDoCarryForward()); } } }; carryForwardAction.setEnabled(false); JCheckBoxMenuItem carryForwardCBMI = new JCheckBoxMenuItem(carryForwardAction); dataMenu.add(carryForwardCBMI); UIRegistry.register("CarryForward", carryForwardCBMI); //$NON-NLS-1$ UIRegistry.registerAction("CarryForward", carryForwardAction); //$NON-NLS-1$ mb.add(dataMenu); if (!isWorkbenchOnly) { final String AUTO_NUM = "AutoNumbering"; //--------------------------------------- // AutoNumber Menu Item (On / Off) Action autoNumberOnOffAction = new AbstractAction( getResourceString("FormViewObj.SET_AUTONUMBER_ONOFF")) { //$NON-NLS-1$ public void actionPerformed(ActionEvent e) { FormViewObj fvo = getCurrentFVO(); if (fvo != null) { fvo.toggleAutoNumberOnOffState(); ((JCheckBoxMenuItem) e.getSource()).setSelected(fvo.isAutoNumberOn()); } } }; autoNumberOnOffAction.setEnabled(false); JCheckBoxMenuItem autoNumCBMI = new JCheckBoxMenuItem(autoNumberOnOffAction); dataMenu.add(autoNumCBMI); UIRegistry.register(AUTO_NUM, autoNumCBMI); //$NON-NLS-1$ UIRegistry.registerAction(AUTO_NUM, autoNumberOnOffAction); //$NON-NLS-1$ } if (System.getProperty("user.name").equals("rods")) { dataMenu.addSeparator(); AbstractAction gpxAction = new AbstractAction("GPS Data") { @Override public void actionPerformed(ActionEvent e) { GPXPanel.getDlgInstance().setVisible(true); } }; JMenuItem gpxMI = new JMenuItem(gpxAction); dataMenu.add(gpxMI); UIRegistry.register("GPXDlg", gpxMI); //$NON-NLS-1$ UIRegistry.registerAction("GPXDlg", gpxAction); //$NON-NLS-1$ } mb.add(dataMenu); SubPaneMgr.getInstance(); // force creating of the Mgr so the menu Actions are created. //-------------------------------------------------------------------- //-- System Menu //-------------------------------------------------------------------- if (!isWorkbenchOnly) { // TODO This needs to be moved into the SystemTask, but right now there is no way // to ask a task for a menu. menu = UIHelper.createLocalizedMenu(mb, "Specify.SYSTEM_MENU", "Specify.SYSTEM_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$ /*if (true) { menu = UIHelper.createMenu(mb, "Forms", "o"); Action genForms = new AbstractAction() { public void actionPerformed(ActionEvent ae) { FormGenerator fg = new FormGenerator(); fg.generateForms(); } }; mi = UIHelper.createMenuItemWithAction(menu, "Generate All Forms", "G", "", true, genForms); }*/ } //-------------------------------------------------------------------- //-- Tab Menu //-------------------------------------------------------------------- menu = UIHelper.createLocalizedMenu(mb, "Specify.TABS_MENU", "Specify.TABS_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$ String ttl = UIRegistry.getResourceString("Specify.SBP_CLOSE_CUR_MENU"); String mnu = UIRegistry.getResourceString("Specify.SBP_CLOSE_CUR_MNEU"); mi = UIHelper.createMenuItemWithAction(menu, ttl, mnu, ttl, true, getAction("CloseCurrent")); if (!UIHelper.isMacOS()) { mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK)); } ttl = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALL_MENU"); mnu = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALL_MNEU"); mi = UIHelper.createMenuItemWithAction(menu, ttl, mnu, ttl, true, getAction("CloseAll")); if (!UIHelper.isMacOS()) { mi.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); } ttl = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALLBUT_MENU"); mnu = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALLBUT_MNEU"); mi = UIHelper.createMenuItemWithAction(menu, ttl, mnu, ttl, true, getAction("CloseAllBut")); menu.addSeparator(); // Configure Task JMenuItem configTaskMI = new JMenuItem(getAction("ConfigureTask")); menu.add(configTaskMI); //UIRegistry.register("ConfigureTask", configTaskMI); //$NON-NLS-1$ //-------------------------------------------------------------------- //-- Debug Menu //-------------------------------------------------------------------- boolean doDebug = AppPreferences.getLocalPrefs().getBoolean("debug.menu", false); if (!UIRegistry.isRelease() || doDebug) { menu = UIHelper.createLocalizedMenu(mb, "Specify.DEBUG_MENU", "Specify.DEBUG_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$ String ttle = "Specify.SHOW_LOC_PREFS";//$NON-NLS-1$ String mneu = "Specify.SHOW_LOC_PREF_MNEU";//$NON-NLS-1$ String desc = "Specify.SHOW_LOC_PREFS";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @SuppressWarnings("synthetic-access") //$NON-NLS-1$ public void actionPerformed(ActionEvent ae) { openLocalPrefs(); } }); ttle = "Specify.SHOW_REM_PREFS";//$NON-NLS-1$ mneu = "Specify.SHOW_REM_PREFS_MNEU";//$NON-NLS-1$ desc = "Specify.SHOW_REM_PREFS";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @SuppressWarnings("synthetic-access") //$NON-NLS-1$ public void actionPerformed(ActionEvent ae) { openRemotePrefs(); } }); menu.addSeparator(); ttle = "Specify.CONFIG_LOGGERS";//$NON-NLS-1$ mneu = "Specify.CONFIG_LOGGERS_MNEU";//$NON-NLS-1$ desc = "Specify.CONFIG_LOGGER";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @SuppressWarnings("synthetic-access") //$NON-NLS-1$ public void actionPerformed(ActionEvent ae) { final LoggerDialog dialog = new LoggerDialog(topFrame); UIHelper.centerAndShow(dialog); } }); ttle = "Specify.CONFIG_DEBUG_LOGGERS";//$NON-NLS-1$ mneu = "Specify.CONFIG_DEBUG_LOGGERS_MNEU";//$NON-NLS-1$ desc = "Specify.CONFIG_DEBUG_LOGGER";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @SuppressWarnings("synthetic-access") //$NON-NLS-1$ public void actionPerformed(ActionEvent ae) { DebugLoggerDialog dialog = new DebugLoggerDialog(topFrame); UIHelper.centerAndShow(dialog); } }); menu.addSeparator(); ttle = "Specify.SHOW_MEM_STATS";//$NON-NLS-1$ mneu = "Specify.SHOW_MEM_STATS_MNEU";//$NON-NLS-1$ desc = "Specify.SHOW_MEM_STATS";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @SuppressWarnings("synthetic-access") //$NON-NLS-1$ public void actionPerformed(ActionEvent ae) { System.gc(); System.runFinalization(); // Get current size of heap in bytes double meg = 1024.0 * 1024.0; double heapSize = Runtime.getRuntime().totalMemory() / meg; // Get maximum size of heap in bytes. The heap cannot grow beyond this size. // Any attempt will result in an OutOfMemoryException. double heapMaxSize = Runtime.getRuntime().maxMemory() / meg; // Get amount of free memory within the heap in bytes. This size will increase // after garbage collection and decrease as new objects are created. double heapFreeSize = Runtime.getRuntime().freeMemory() / meg; UIRegistry.getStatusBar() .setText(String.format("Heap Size: %7.2f Max: %7.2f Free: %7.2f Used: %7.2f", //$NON-NLS-1$ heapSize, heapMaxSize, heapFreeSize, (heapSize - heapFreeSize))); } }); JMenu prefsMenu = new JMenu(UIRegistry.getResourceString("Specify.PREFS_IMPORT_EXPORT")); //$NON-NLS-1$ menu.add(prefsMenu); ttle = "Specify.IMPORT_MENU";//$NON-NLS-1$ mneu = "Specify.IMPORT_MNEU";//$NON-NLS-1$ desc = "Specify.IMPORT_PREFS";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(prefsMenu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @SuppressWarnings("synthetic-access") //$NON-NLS-1$ public void actionPerformed(ActionEvent ae) { importPrefs(); } }); ttle = "Specify.EXPORT_MENU";//$NON-NLS-1$ mneu = "Specify.EXPORT_MNEU";//$NON-NLS-1$ desc = "Specify.EXPORT_PREFS";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(prefsMenu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @SuppressWarnings("synthetic-access") //$NON-NLS-1$ public void actionPerformed(ActionEvent ae) { exportPrefs(); } }); ttle = "Associate Storage Items";//$NON-NLS-1$ mneu = "A";//$NON-NLS-1$ desc = "";//$NON-NLS-1$ mi = UIHelper.createMenuItemWithAction(menu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @SuppressWarnings("synthetic-access") //$NON-NLS-1$ public void actionPerformed(ActionEvent ae) { associateStorageItems(); } }); ttle = "Load GPX Points";//$NON-NLS-1$ mneu = "a";//$NON-NLS-1$ desc = "";//$NON-NLS-1$ mi = UIHelper.createMenuItemWithAction(menu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @SuppressWarnings("synthetic-access") //$NON-NLS-1$ public void actionPerformed(ActionEvent ae) { CustomDialog dlg = GPXPanel.getDlgInstance(); if (dlg != null) { dlg.setVisible(true); } } }); JCheckBoxMenuItem cbMenuItem = new JCheckBoxMenuItem("Security Activated"); //$NON-NLS-1$ menu.add(cbMenuItem); cbMenuItem.setSelected(AppContextMgr.isSecurityOn()); cbMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { boolean isSecurityOn = !SpecifyAppContextMgr.isSecurityOn(); AppContextMgr.getInstance().setSecurity(isSecurityOn); ((JMenuItem) ae.getSource()).setSelected(isSecurityOn); JLabel secLbl = statusField.getSectionLabel(3); if (secLbl != null) { secLbl.setIcon(IconManager.getImage(isSecurityOn ? "SecurityOn" : "SecurityOff", IconManager.IconSize.Std16)); secLbl.setHorizontalAlignment(SwingConstants.CENTER); secLbl.setToolTipText(getResourceString("Specify.SEC_" + (isSecurityOn ? "ON" : "OFF"))); } } }); JMenuItem sizeMenuItem = new JMenuItem("Set to " + PREFERRED_WIDTH + "x" + PREFERRED_HEIGHT); //$NON-NLS-1$ menu.add(sizeMenuItem); sizeMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { topFrame.setSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); } }); } //---------------------------------------------------- //-- Helper Menu //---------------------------------------------------- JMenu helpMenu = UIHelper.createLocalizedMenu(mb, "Specify.HELP_MENU", "Specify.HELP_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$ HelpMgr.createHelpMenuItem(helpMenu, getResourceString("SPECIFY_HELP")); //$NON-NLS-1$ helpMenu.addSeparator(); String ttle = "Specify.LOG_SHOW_FILES";//$NON-NLS-1$ String mneu = "Specify.LOG_SHOW_FILES_MNEU";//$NON-NLS-1$ String desc = "Specify.LOG_SHOW_FILES";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null); helpMenu.addSeparator(); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { AppBase.displaySpecifyLogFiles(); } }); ttle = "SecurityAdminTask.CHANGE_PWD_MENU"; //$NON-NLS-1$ mneu = "SecurityAdminTask.CHANGE_PWD_MNEU"; //$NON-NLS-1$ desc = "SecurityAdminTask.CHANGE_PWD_DESC"; //$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { SecurityAdminTask.changePassword(true); } }); ttle = "Specify.CHECK_UPDATE";//$NON-NLS-1$ mneu = "Specify.CHECK_UPDATE_MNEU";//$NON-NLS-1$ desc = "Specify.CHECK_UPDATE_DESC";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { checkForUpdates(); } }); ttle = "Specify.AUTO_REG";//$NON-NLS-1$ mneu = "Specify.AUTO_REG_MNEU";//$NON-NLS-1$ desc = "Specify.AUTO_REG_DESC";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { RegisterSpecify.register(true, 0); } }); ttle = "Specify.SA_REG";//$NON-NLS-1$ mneu = "Specify.SA_REG_MNEU";//$NON-NLS-1$ desc = "Specify.SA_REG_DESC";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { RegisterSpecify.registerISA(); } }); ttle = "Specify.FEEDBACK";//$NON-NLS-1$ mneu = "Specify.FB_MNEU";//$NON-NLS-1$ desc = "Specify.FB_DESC";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { FeedBackDlg feedBackDlg = new FeedBackDlg(); feedBackDlg.sendFeedback(); } }); if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) { helpMenu.addSeparator(); ttle = "Specify.ABOUT";//$NON-NLS-1$ mneu = "Specify.ABOUTMNEU";//$NON-NLS-1$ desc = "Specify.ABOUT";//$NON-NLS-1$ mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { doAbout(); } }); } return mb; }
From source file:edu.ku.brc.af.ui.forms.FormViewObj.java
/** * Shows Parent Form's Context Menu./*w w w.j a va2 s . c o m*/ * @param e the mouse event */ protected void showContextMenu(MouseEvent e) { if (e.isPopupTrigger() && mvParent != null && mvParent.isTopLevel() && isEditing) { JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(UIRegistry.getResourceString("CONFIG_CARRY_FORWARD_MENU")); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { configureCarryForward(); } }); popup.add(menuItem); JCheckBoxMenuItem chkMI = new JCheckBoxMenuItem( UIRegistry.getResourceString("CARRY_FORWARD_CHECKED_MENU")); chkMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { toggleCarryForward(); } }); chkMI.setSelected(isCarryForwardConfgured() && isDoCarryForward()); chkMI.setEnabled(isCarryForwardConfgured()); popup.add(chkMI); popup.addSeparator(); chkMI = new JCheckBoxMenuItem(UIRegistry.getAction(AUTO_NUM)); /*chkMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { toggleAutoNumberOnOffState(); } });*/ chkMI.setSelected(isAutoNumberOn); popup.add(chkMI); popup.show(e.getComponent(), e.getX(), e.getY()); } }
From source file:gui.DownloadManagerGUI.java
private JMenuBar initMenuBar() { JMenuBar menuBar = new JMenuBar(); ///////////////////////////////////////////////////////////////////////// JMenu fileMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.fileMenu.name")); exportDataItem = new JMenuItem("Export Data..."); importDataItem = new JMenuItem("Import Data..."); exitItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.exitItem.name")); exitItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.exitItem.iconPath")))); // NOI18N exportDataItem.setEnabled(false);/*from w w w. j a va 2s. c o m*/ importDataItem.setEnabled(false); // fileMenu.add(exportDataItem); // fileMenu.add(importDataItem); fileMenu.addSeparator(); fileMenu.add(exitItem); ///////////////////////////////////////////////////////////////////////// JMenu windowMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.windowMenu.name")); JMenu showMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.showMenu.name")); prefsItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.prefsItem.name")); prefsItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.prefsItem.iconPath")))); JCheckBoxMenuItem showFormItem = new JCheckBoxMenuItem( messagesBundle.getString("downloadManagerGUI.showFormItem.name")); showFormItem.setSelected(true); showMenu.add(showFormItem); windowMenu.add(showMenu); windowMenu.add(prefsItem); exportDataItem.addActionListener(this); importDataItem.addActionListener(this); exitItem.addActionListener(this); prefsItem.addActionListener(this); ///////////////////////////////////////////////////////////////////////// JMenu downloadsMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.downloadsMenu.name")); newDownloadItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.newDownloadItem.name")); newDownloadItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.newDownloadItem.iconPath")))); openItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.openItem.name")); openFolderItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.openFolderItem.name")); resumeItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.resumeItem.name")); resumeItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.resumeItem.iconPath")))); pauseItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.pauseItem.name")); pauseItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.pauseItem.iconPath")))); pauseAllItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.pauseAllItem.name")); pauseAllItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.pauseAllItem.iconPath")))); clearItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.clearItem.name")); clearItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.clearItem.iconPath")))); clearAllCompletedItem = new JMenuItem( messagesBundle.getString("downloadManagerGUI.clearAllCompletedItem.name")); clearAllCompletedItem.setIcon(new javax.swing.ImageIcon(getClass() .getResource(messagesBundle.getString("downloadManagerGUI.clearAllCompletedItem.iconPath")))); reJoinItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.reJoinItem.name")); reJoinItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.reJoinItem.iconPath")))); reDownloadItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.reDownloadItem.name")); reDownloadItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.reDownloadItem.iconPath")))); moveToQueueItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.moveToQueueItem.name")); removeFromQueueItem = new JMenuItem( messagesBundle.getString("downloadManagerGUI.removeFromQueueItem.name")); propertiesItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.propertiesItem.name")); propertiesItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.propertiesItem.iconPath")))); downloadsMenu.add(newDownloadItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(openItem); downloadsMenu.add(openFolderItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(resumeItem); downloadsMenu.add(pauseItem); downloadsMenu.add(pauseAllItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(clearItem); downloadsMenu.add(clearAllCompletedItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(reJoinItem); downloadsMenu.add(reDownloadItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(moveToQueueItem); downloadsMenu.add(removeFromQueueItem); downloadsMenu.add(new JSeparator()); downloadsMenu.add(propertiesItem); newDownloadItem.addActionListener(this); openItem.addActionListener(this); openFolderItem.addActionListener(this); resumeItem.addActionListener(this); pauseItem.addActionListener(this); pauseAllItem.addActionListener(this); clearItem.addActionListener(this); clearAllCompletedItem.addActionListener(this); reDownloadItem.addActionListener(this); moveToQueueItem.addActionListener(this); removeFromQueueItem.addActionListener(this); propertiesItem.addActionListener(this); setStateOfMenuItems(); ///////////////////////////////////////////////////////////////////////// JMenu helpMenu = new JMenu(messagesBundle.getString("downloadManagerGUI.helpMenu.name")); aboutItem = new JMenuItem(messagesBundle.getString("downloadManagerGUI.aboutItem.name")); aboutItem.setIcon(new javax.swing.ImageIcon( getClass().getResource(messagesBundle.getString("downloadManagerGUI.aboutItem.iconPath")))); helpMenu.add(aboutItem); aboutItem.addActionListener(this); menuBar.add(fileMenu); menuBar.add(windowMenu); menuBar.add(downloadsMenu); menuBar.add(helpMenu); showFormItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ev.getSource(); if (menuItem.isSelected()) { mainSplitPane.setDividerLocation((int) categoryPanel.getMinimumSize().getWidth()); } categoryPanel.setVisible(menuItem.isSelected()); } }); fileMenu.setMnemonic(KeyEvent.VK_F); exitItem.setMnemonic(KeyEvent.VK_X); prefsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); importDataItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK)); return menuBar; }
From source file:org.broad.igv.track.TrackMenuUtils.java
/** * Return popup menu with items applicable to data tracks * * @return/* w w w . j a v a 2s . c o m*/ */ public static void addDataItems(JPopupMenu menu, final Collection<Track> tracks) { if (log.isDebugEnabled()) { log.debug("enter getDataPopupMenu"); } final String[] labels = { "Heatmap", "Bar Chart", "Scatterplot", "Line Plot" }; final Class[] renderers = { HeatmapRenderer.class, BarChartRenderer.class, PointsRenderer.class, LineplotRenderer.class }; //JLabel popupTitle = new JLabel(LEADING_HEADING_SPACER + title, JLabel.CENTER); JLabel rendererHeading = new JLabel(LEADING_HEADING_SPACER + "Type of Graph", JLabel.LEFT); rendererHeading.setFont(UIConstants.boldFont); menu.add(rendererHeading); // Get existing selections Set<Class> currentRenderers = new HashSet<Class>(); for (Track track : tracks) { if (track.getRenderer() != null) { currentRenderers.add(track.getRenderer().getClass()); } } // Create and renderer menu items for (int i = 0; i < labels.length; i++) { JCheckBoxMenuItem item = new JCheckBoxMenuItem(labels[i]); final Class rendererClass = renderers[i]; if (currentRenderers.contains(rendererClass)) { item.setSelected(true); } item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { changeRenderer(tracks, rendererClass); } }); menu.add(item); } menu.addSeparator(); // Get union of all valid window functions for selected tracks Set<WindowFunction> avaibleWindowFunctions = new HashSet(); for (Track track : tracks) { avaibleWindowFunctions.addAll(track.getAvailableWindowFunctions()); } avaibleWindowFunctions.add(WindowFunction.none); // dataPopupMenu.addSeparator(); // Collection all window functions for selected tracks Set<WindowFunction> currentWindowFunctions = new HashSet<WindowFunction>(); for (Track track : tracks) { if (track.getWindowFunction() != null) { currentWindowFunctions.add(track.getWindowFunction()); } } if (avaibleWindowFunctions.size() > 1 || currentWindowFunctions.size() > 1) { JLabel statisticsHeading = new JLabel(LEADING_HEADING_SPACER + "Windowing Function", JLabel.LEFT); statisticsHeading.setFont(UIConstants.boldFont); menu.add(statisticsHeading); for (final WindowFunction wf : ORDERED_WINDOW_FUNCTIONS) { JCheckBoxMenuItem item = new JCheckBoxMenuItem(wf.getDisplayName()); if (avaibleWindowFunctions.contains(wf) || currentWindowFunctions.contains(wf)) { if (currentWindowFunctions.contains(wf)) { item.setSelected(true); } item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { changeStatType(wf.toString(), tracks); } }); menu.add(item); } } menu.addSeparator(); } menu.add(getDataRangeItem(tracks)); menu.add(getHeatmapScaleItem(tracks)); if (tracks.size() > 0) { menu.add(getLogScaleItem(tracks)); } menu.add(getAutoscaleItem(tracks)); menu.add(getShowDataRangeItem(tracks)); menu.addSeparator(); menu.add(getChangeKMPlotItem(tracks)); }
From source file:org.broad.igv.track.TrackMenuUtils.java
private static JMenuItem getDrawBorderItem() { // Change track height by attribute final JCheckBoxMenuItem drawBorderItem = new JCheckBoxMenuItem("Draw borders"); drawBorderItem.setSelected(FeatureTrack.isDrawBorder()); drawBorderItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { FeatureTrack.setDrawBorder(drawBorderItem.isSelected()); IGV.getInstance().repaintDataPanels(); }/* w w w . j a v a 2s . c om*/ }); return drawBorderItem; }
From source file:org.broad.igv.track.TrackMenuUtils.java
public static JMenuItem getLogScaleItem(final Collection<Track> selectedTracks) { // Change track height by attribute final JCheckBoxMenuItem logScaleItem = new JCheckBoxMenuItem("Log scale"); final boolean logScale = selectedTracks.iterator().next().getDataRange().isLog(); logScaleItem.setSelected(logScale);//from w ww . j a v a2 s . c o m logScaleItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DataRange.Type scaleType = logScaleItem.isSelected() ? DataRange.Type.LOG : DataRange.Type.LINEAR; for (Track t : selectedTracks) { t.getDataRange().setType(scaleType); } IGV.getInstance().repaintDataPanels(); } }); return logScaleItem; }
From source file:org.broad.igv.track.TrackMenuUtils.java
private static JMenuItem getAutoscaleItem(final Collection<Track> selectedTracks) { final JCheckBoxMenuItem autoscaleItem = new JCheckBoxMenuItem("Autoscale"); if (selectedTracks.size() == 0) { autoscaleItem.setEnabled(false); } else {// w w w . jav a 2 s . c om boolean autoScale = false; for (Track t : selectedTracks) { if (t instanceof DataTrack && ((DataTrack) t).isAutoscale()) { autoScale = true; break; } } autoscaleItem.setSelected(autoScale); autoscaleItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { boolean autoScale = autoscaleItem.isSelected(); for (Track t : selectedTracks) { if (t instanceof DataTrack) { ((DataTrack) t).setAutoscale(autoScale); } } IGV.getInstance().repaintDataPanels(); } }); } return autoscaleItem; }
From source file:org.broad.igv.track.TrackMenuUtils.java
public static JMenuItem getShowDataRangeItem(final Collection<Track> selectedTracks) { final JCheckBoxMenuItem item = new JCheckBoxMenuItem("Show Data Range"); if (selectedTracks.size() == 0) { item.setEnabled(false);//ww w. jav a 2s . co m } else { boolean showDataRange = true; for (Track t : selectedTracks) { if (!t.isShowDataRange()) { showDataRange = false; break; } } item.setSelected(showDataRange); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { boolean showDataRange = item.isSelected(); for (Track t : selectedTracks) { if (t instanceof DataTrack) { ((DataTrack) t).setShowDataRange(showDataRange); } } IGV.getInstance().repaintDataPanels(); } }); } return item; }
From source file:org.esa.nest.dat.views.polarview.PolarView.java
private JCheckBoxMenuItem createCheckedMenuItem(String name, JMenu parent, boolean state) { final JCheckBoxMenuItem item = new JCheckBoxMenuItem(name); item.setHorizontalTextPosition(JMenuItem.RIGHT); item.addActionListener(this); parent.add(item);// w ww . ja v a 2 s.com return item; }
From source file:org.nebulaframework.ui.swing.node.NodeMainUI.java
/** * Setup Menu Bar/*w w w.j a va 2 s . co m*/ * @return JMenu Bar */ private JMenuBar setupMenu() { JMenuBar menuBar = new JMenuBar(); /* -- GridNode Menu -- */ JMenu gridNodeMenu = new JMenu("GridNode"); gridNodeMenu.setMnemonic(KeyEvent.VK_N); menuBar.add(gridNodeMenu); // Discover JMenuItem clusterDiscoverItem = new JMenuItem("Disover and Connect Clusters"); clusterDiscoverItem.setMnemonic(KeyEvent.VK_D); clusterDiscoverItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)); gridNodeMenu.add(clusterDiscoverItem); clusterDiscoverItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doDiscover(false); ((JCheckBoxMenuItem) getUIElement("menu.node.autodiscover")).setSelected(false); } }); addUIElement("menu.node.discover", clusterDiscoverItem); // Add to components map // Auto-Discovery final JCheckBoxMenuItem autodiscoveryItem = new JCheckBoxMenuItem("Auto Discover"); autodiscoveryItem.setMnemonic(KeyEvent.VK_A); autodiscoveryItem.setSelected(true); gridNodeMenu.add(autodiscoveryItem); autodiscoveryItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { autodiscover = autodiscoveryItem.isSelected(); } }); addUIElement("menu.node.autodiscover", autodiscoveryItem); // Add to components map gridNodeMenu.addSeparator(); // Cluster-> Shutdown JMenuItem nodeShutdownItem = new JMenuItem("Shutdown", 'u'); nodeShutdownItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0)); nodeShutdownItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doShutdownNode(); } }); gridNodeMenu.add(nodeShutdownItem); addUIElement("menu.node.shutdown", nodeShutdownItem); // Add to components map /* -- Options Menu -- */ JMenu optionsMenu = new JMenu("Options"); optionsMenu.setMnemonic(KeyEvent.VK_O); menuBar.add(optionsMenu); // Configuration JMenuItem optionsConfigItem = new JMenuItem("Configuration...", 'C'); optionsConfigItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showConfiguration(); } }); optionsMenu.add(optionsConfigItem); optionsConfigItem.setEnabled(false); // TODO Create Configuration Options /* -- Help Menu -- */ JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic(KeyEvent.VK_H); menuBar.add(helpMenu); // Help Contents JMenuItem helpContentsItem = new JMenuItem("Help Contents", 'H'); helpContentsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); helpContentsItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showHelp(); } }); helpMenu.add(helpContentsItem); helpMenu.addSeparator(); JMenuItem helpAboutItem = new JMenuItem("About", 'A'); helpAboutItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showAbout(); } }); helpMenu.add(helpAboutItem); return menuBar; }