List of usage examples for javax.swing JCheckBoxMenuItem setSelected
public void setSelected(boolean b)
From source file:de.huxhorn.lilith.swing.ViewActions.java
private void updateShowHideMenu() { columnsMenu.removeAll();//w w w . ja va 2s .c om if (viewContainer != null) { EventWrapperViewPanel<?> viewPanel = viewContainer.getSelectedView(); if (viewPanel != null) { EventWrapperViewTable<?> table = viewPanel.getTable(); if (table != null) { PersistentTableColumnModel tableColumnModel = table.getTableColumnModel(); List<PersistentTableColumnModel.TableColumnLayoutInfo> cli = tableColumnModel .getColumnLayoutInfos(); for (PersistentTableColumnModel.TableColumnLayoutInfo current : cli) { boolean visible = current.isVisible(); JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem( new ShowHideAction(tableColumnModel, current.getColumnName(), visible)); cbmi.setSelected(visible); columnsMenu.add(cbmi); } } } } }
From source file:edu.ku.brc.specify.Specify.java
/** * Create menus//w w w. j a v a 2 s . com */ 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
/** * Updates the AutoNumbering Menu and the control on the form. *//* w w w . j a v a2 s . co m*/ protected void updateAutoNumberFieldState() { JCheckBoxMenuItem mi = (JCheckBoxMenuItem) UIRegistry.get(AUTO_NUM); if (mi != null) { mi.setSelected(isAutoNumberOn); } for (FVOFieldInfo fieldInfo : controlsById.values()) { Component comp = fieldInfo.getComp(); if (comp instanceof AutoNumberableIFace) { ((AutoNumberableIFace) comp).setAutoNumberEnabled(isAutoNumberOn); } } }
From source file:edu.ku.brc.af.ui.forms.FormViewObj.java
/** * Toggles Carry Forward State (Turning it on and off). */// w w w . jav a 2 s .c o m public void toggleCarryForward() { setDoCarryForward(!isDoCarryForward()); JCheckBoxMenuItem mi = (JCheckBoxMenuItem) UIRegistry.get("CarryForward"); if (mi != null) { mi.setSelected(isDoCarryForward()); } }
From source file:edu.ku.brc.af.ui.forms.FormViewObj.java
/** * Shows Parent Form's Context Menu./* ww w . ja v a 2 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:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Setup the program's initial state based on the configuration * properties./*from w w w . j a v a2 s .c o m*/ */ private void processProperties() { String value; lastDirectoryUsed = new File(properties.getProperty(ConfigurationProperty.LAST_DIRECTORY.key(), ".")); LOGGER.debug("Last directory used from properties file: " + lastDirectoryUsed.getAbsolutePath()); value = properties.getProperty(ConfigurationProperty.INPUT_LANGUAGE.key(), "?"); language.setSelectedItem(value); value = properties.getProperty(ConfigurationProperty.REASONING_LEVEL.key(), "-1"); try { final Integer index = Integer.parseInt(value); if (index < 0 || index >= reasoningLevel.getItemCount()) { throw new IllegalArgumentException("Incorrect reasoning level index property value: " + value); } reasoningLevel.setSelectedIndex(index); } catch (Throwable throwable) { LOGGER.warn("Index for reasoner level must be a number from zero to " + (reasoningLevel.getItemCount() - 1)); } reasoningLevel.setToolTipText(((ReasonerSelection) reasoningLevel.getSelectedItem()).description()); value = properties.getProperty(ConfigurationProperty.OUTPUT_FORMAT.key(), "?"); for (JCheckBoxMenuItem outputLanguage : setupOutputAssertionLanguage) { if (outputLanguage.getText().equalsIgnoreCase(value)) { outputLanguage.setSelected(true); } } value = properties.getProperty(ConfigurationProperty.OUTPUT_CONTENT.key(), "?"); if (setupOutputModelTypeAssertionsAndInferences.getText().equalsIgnoreCase(value)) { setupOutputModelTypeAssertionsAndInferences.setSelected(true); } else { setupOutputModelTypeAssertions.setSelected(true); } setupAllowMultilineResultOutput.setSelected( properties.getProperty(ConfigurationProperty.SPARQL_DISPLAY_ALLOW_MULTILINE_OUTPUT.key(), "Y") .toUpperCase().startsWith("Y")); setupOutputFqnNamespaces.setSelected(properties .getProperty(ConfigurationProperty.SHOW_FQN_NAMESPACES.key(), "Y").toUpperCase().startsWith("Y")); setupOutputDatatypesForLiterals .setSelected(properties.getProperty(ConfigurationProperty.SHOW_DATATYPES_ON_LITERALS.key(), "Y") .toUpperCase().startsWith("Y")); setupOutputFlagLiteralValues .setSelected(properties.getProperty(ConfigurationProperty.FLAG_LITERALS_IN_RESULTS.key(), "N") .toUpperCase().startsWith("Y")); setupApplyFormattingToLiteralValues.setSelected( properties.getProperty(ConfigurationProperty.APPLY_FORMATTING_TO_LITERAL_VALUES.key(), "N") .toUpperCase().startsWith("Y")); setupDisplayImagesInSparqlResults.setSelected( properties.getProperty(ConfigurationProperty.SPARQL_DISPLAY_IMAGES_IN_RESULTS.key(), "N") .toUpperCase().startsWith("Y")); // SPARQL query export format - default to CSV if (properties .getProperty(ConfigurationProperty.EXPORT_SPARQL_RESULTS_FORMAT.key(), EXPORT_FORMAT_LABEL_CSV) .equalsIgnoreCase(EXPORT_FORMAT_LABEL_TSV)) { setupExportSparqlResultsAsTsv.setSelected(true); } else { setupExportSparqlResultsAsCsv.setSelected(true); } setupSparqlResultsToFile .setSelected(properties.getProperty(ConfigurationProperty.SPARQL_RESULTS_TO_FILE.key(), "N") .toUpperCase().startsWith("Y")); value = properties.getProperty(ConfigurationProperty.SPARQL_SERVICE_USER_ID.key()); if (value != null) { sparqlServiceUserId.setText(value); } value = properties.getProperty(ConfigurationProperty.SPARQL_DEFAULT_GRAPH_URI.key()); if (value != null) { defaultGraphUri.setText(value); } setupEnableStrictMode.setSelected(properties .getProperty(ConfigurationProperty.ENABLE_STRICT_MODE.key(), "Y").toUpperCase().startsWith("Y")); filterEnableFilters .setSelected(properties.getProperty(ConfigurationProperty.ENFORCE_FILTERS_IN_TREE_VIEW.key(), "Y") .toUpperCase().startsWith("Y")); showFqnInTree.setSelected(properties.getProperty(ConfigurationProperty.DISPLAY_FQN_IN_TREE_VIEW.key(), "Y") .toUpperCase().startsWith("Y")); filterShowAnonymousNodes.setSelected( properties.getProperty(ConfigurationProperty.DISPLAY_ANONYMOUS_NODES_IN_TREE_VIEW.key(), "N") .toUpperCase().startsWith("Y")); setFont(getFontFromProperties(), getColorFromProperties()); extractSkipObjectsFromProperties(); extractRecentAssertedTriplesFilesFromProperties(); extractRecentSparqlQueryFilesFromProperties(); // SPARQL Split Pane Position value = properties.getProperty(ConfigurationProperty.SPARQL_SPLIT_PANE_POSITION.key()); if (value != null) { try { final int position = Integer.parseInt(value); if (position > 0) { sparqlQueryAndResults.setDividerLocation(position); } } catch (Throwable throwable) { LOGGER.warn("Cannot use the SPARQL split pane divider location value: " + value, throwable); } } // Sparql server port value = properties.getProperty(ConfigurationProperty.SPARQL_SERVER_PORT.key()); if (value != null) { try { final Integer port = Integer.parseInt(value); if (port > 0) { SparqlServer.getInstance().setListenerPort(port); } else { LOGGER.warn("Configured port for SPARQL Server must be greater than zero. Was set to " + port); } } catch (Throwable throwable) { LOGGER.warn("Configured port for SPARQL Server must be a number greater than zero. Was set to " + value); } } // SPARQL server max runtime value = properties.getProperty(ConfigurationProperty.SPARQL_SERVER_MAX_RUNTIME.key()); if (value != null) { try { final Integer maxRuntimeSeconds = Integer.parseInt(value); if (maxRuntimeSeconds > 0) { SparqlServer.getInstance().setMaxRuntimeSeconds(maxRuntimeSeconds); } else { LOGGER.warn( "Configured maximum runtime for the SPARQL Server must be greater than zero seconds. Was set to " + maxRuntimeSeconds); } } catch (Throwable throwable) { LOGGER.warn( "Configured maximum runtime for the SPARQL Server must be a number greater than zero. Was set to " + value); } } // SPARQL server remote updates permitted SparqlServer.getInstance().setRemoteUpdatesPermitted( properties.getProperty(ConfigurationProperty.SPARQL_SERVER_ALLOW_REMOTE_UPDATE.key(), "N") .toUpperCase().startsWith("Y")); // Proxy proxyServer = properties.getProperty(ConfigurationProperty.PROXY_SERVER.key()); value = properties.getProperty(ConfigurationProperty.PROXY_PORT.key()); if (value != null) { try { proxyPort = Integer.parseInt(value); } catch (Throwable throwable) { LOGGER.warn("Illegal proxy port number in the properties file: " + value); } } proxyProtocolHttp = properties.getProperty(ConfigurationProperty.PROXY_HTTP.key(), "N").toUpperCase() .startsWith("Y"); proxyProtocolSocks = properties.getProperty(ConfigurationProperty.PROXY_SOCKS.key(), "N").toUpperCase() .startsWith("Y"); proxyEnabled = properties.getProperty(ConfigurationProperty.PROXY_ENABLED.key(), "N").toUpperCase() .startsWith("Y"); setupProxy(); populateSparqlServiceUrls(); extractXsdFormatsFromProperties(); }
From source file:org.broad.igv.track.TrackMenuUtils.java
/** * Return popup menu with items applicable to data tracks * * @return//from w ww.java 2 s .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(); }// ww w .ja v a 2s. com }); 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); 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); }//from w w w.j a v a 2 s. c o m 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 . j av 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; }