List of usage examples for javax.swing JMenu addSeparator
public void addSeparator()
From source file:edu.ku.brc.ui.UIRegistry.java
public JMenu createEditMenu() { JMenu menu = new JMenu(getResourceString("EDIT")); menu.setMnemonic(KeyEvent.VK_E); // Undo and redo are actions of our own creation. undoAction = (UndoAction) makeAction(UndoAction.class, this, "Undo", null, null, new Integer(KeyEvent.VK_Z), KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); register(UNDO, menu.add(undoAction)); actionMap.put(UNDO, undoAction);// ww w . jav a2 s . c o m redoAction = (RedoAction) makeAction(RedoAction.class, this, "Redo", null, null, new Integer(KeyEvent.VK_Y), KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); register(REDO, menu.add(redoAction)); actionMap.put(REDO, redoAction); menu.addSeparator(); // These actions come from the default editor kit. Get the ones we want // and stick them in the menu. Action cutAction = makeAction(DefaultEditorKit.CutAction.class, null, "Cut", null, "Cut selection to clipboard", // I18N ???? new Integer(KeyEvent.VK_X), KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); register(CUT, menu.add(cutAction)); cutAction.setEnabled(false); actionMap.put(CUT, cutAction); Action copyAction = makeAction(DefaultEditorKit.CopyAction.class, null, "Copy", null, "Copy selection to clipboard", new Integer(KeyEvent.VK_C), KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); register(COPY, menu.add(copyAction)); copyAction.setEnabled(false); actionMap.put(COPY, copyAction); Action pasteAction = makeAction(DefaultEditorKit.PasteAction.class, null, "Paste", null, "Paste contents of clipboard", new Integer(KeyEvent.VK_V), KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); pasteAction.setEnabled(false); register(PASTE, menu.add(pasteAction)); actionMap.put(PASTE, pasteAction); /* menu.addSeparator(); Action selectAllAction = makeAction(SelectAllAction.class, this, "Select All", null, "Select all text", new Integer(KeyEvent.VK_A), KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu.add(selectAllAction); */ launchFindReplaceAction = (LaunchFindReplaceAction) makeAction(LaunchFindReplaceAction.class, this, "Find", null, null, new Integer(KeyEvent.VK_F), KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); //menu.add(launchFindReplaceAction); // launchFindReplaceAction.setEnabled(false); // register(FIND, menu.add(launchFindReplaceAction)); // actionMap.put(FIND, launchFindReplaceAction); launchFindReplaceAction.setEnabled(false); register(FIND, menu.add(launchFindReplaceAction)); actionMap.put(FIND, launchFindReplaceAction); return menu; }
From source file:fi.hoski.remote.ui.Admin.java
private void menuRace() { JMenu raceMenu = new JMenu(); TextUtil.populate(raceMenu, "RACES"); menuBar.add(raceMenu);//from w ww . j a v a 2s . c om if (isRaceAdmin) { raceMenu.add(menuItemUploadRaceSeries()); raceMenu.add(menuItemEditRaceSeries()); raceMenu.add(menuItemRemoveRaceSeries()); } raceMenu.add(menuItemDownloadCompetitorsForSailwave()); raceMenu.add(menuItemInsertCompetitorsToSailwave()); raceMenu.add(menuItemDownloadCompetitorsAsCSV()); raceMenu.addSeparator(); if (isRaceAdmin) { raceMenu.add(menuItemUploadRanking()); raceMenu.add(menuItemEditRanking()); raceMenu.add(menuItemRemoveRanking()); } raceMenu.addSeparator(); raceMenu.add(menuItemRaceEmail()); if (serverProperties.isZonerSMSSupported()) { raceMenu.add(menuItemRaceSMS()); } raceMenu.addSeparator(); raceMenu.add(menuItemAttachRaceSeries()); raceMenu.add(menuItemRemoveRaceSeriesAttachment()); raceMenu.addSeparator(); raceMenu.add(menuItemAddReferencePayments()); raceMenu.add(menuItemAddOtherPayments()); }
From source file:gdt.jgui.entity.contact.JContactEditor.java
@Override public JMenu getContextMenu() { final JMenu menu = new JMenu("Context"); menu.addMenuListener(new MenuListener() { @Override/*from w w w. j av a 2s . co m*/ public void menuSelected(MenuEvent e) { // System.out.println("EntityEditor:getConextMenu:menu selected"); menu.removeAll(); JMenuItem facetsItem = new JMenuItem("Facets"); facetsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); JEntityFacetPanel erm = new JEntityFacetPanel(); String locator$ = erm.getLocator(); locator$ = Locator.append(locator$, Entigrator.ENTIHOME, entihome$); locator$ = Locator.append(locator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, locator$); } }); menu.add(facetsItem); JMenuItem digestItem = new JMenuItem("Digest"); digestItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); String locator$ = getLocator(); JEntityDigestDisplay edd = new JEntityDigestDisplay(); edd.instantiate(console, locator$); String eddLocator$ = edd.getLocator(); eddLocator$ = Locator.append(eddLocator$, Entigrator.ENTIHOME, entihome$); eddLocator$ = Locator.append(eddLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, eddLocator$); } }); menu.add(digestItem); JMenuItem structureItem = new JMenuItem("Structure"); structureItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); String locator$ = getLocator(); JEntityStructurePanel esp = new JEntityStructurePanel(); esp.instantiate(console, locator$); String espLocator$ = esp.getLocator(); espLocator$ = Locator.append(espLocator$, Entigrator.ENTIHOME, entihome$); espLocator$ = Locator.append(espLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, espLocator$); } }); menu.add(structureItem); menu.addSeparator(); JMenuItem doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Entigrator entigrator = console.getEntigrator(entihome$); Sack contact = entigrator.getEntityAtKey(entityKey$); String entityLabel$ = contact.getProperty("label"); String title$ = title.getText(); if (!entityLabel$.equals(title$)) { contact = entigrator.ent_assignLabel(contact, title$); contact = entigrator.ent_assignProperty(contact, "contact", contact.getProperty("label")); } contact = entigrator.ent_assignProperty(contact, "phone", phone.getText()); contact = entigrator.ent_assignProperty(contact, "email", email.getText()); if (requesterResponseLocator$ != null) { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); // System.out.println("TextEditor:done:response locator="+responseLocator$); JConsoleHandler.execute(console, responseLocator$); } else console.back(); } catch (Exception ee) { Logger.getLogger(JContactEditor.class.getName()).severe(ee.toString()); } } }); menu.add(doneItem); JMenuItem cancelItem = new JMenuItem("Cancel"); cancelItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { console.back(); } }); menu.add(cancelItem); } @Override public void menuDeselected(MenuEvent e) { // TODO Auto-generated method stub } @Override public void menuCanceled(MenuEvent e) { // TODO Auto-generated method stub } }); return menu; }
From source file:com.gele.tools.wow.wdbearmanager.WDBearManager.java
public void init(String[] args) { // copy ARGs//from www.j a va 2s . com this.parseCommandLine(args); // Usefull for debugging this.myLogger.debug("java.version: " + System.getProperty("java.version")); this.myLogger.debug("java.vendor: " + System.getProperty("java.vendor")); this.myLogger.debug("java.vendor.url: " + System.getProperty("java.vendor.url")); this.myLogger.debug("os.name: " + System.getProperty("os.name")); this.myLogger.debug("os.arch: " + System.getProperty("os.arch")); this.myLogger.debug("os.version: " + System.getProperty("os.version")); if (this.paramDBconfig.length() != 0) { this.WDB_DB_CONFIG_FILE = this.paramDBconfig; } WDBearManager_API myAPI = new WDBearManager_API(this.WDB_DB_CONFIG_FILE); // Create all tables // -> Needed for the updata script <- // -> Otherwise it may crash with an empty database try { myAPI.getCountOfTable("creaturecache"); myAPI.getCountOfTable("gameobjectcache"); myAPI.getCountOfTable("itemcache"); myAPI.getCountOfTable("itemnamecache"); myAPI.getCountOfTable("itemtextchaxhe"); myAPI.getCountOfTable("npccache"); myAPI.getCountOfTable("pagetextcache"); myAPI.getCountOfTable("questcache"); } catch (Exception ex) { // ignore ex.printStackTrace(); System.exit(0); } // Check, if database must be re-newed DBUpdater myDBU = new DBUpdater(); myDBU.checkForUpdate(myAPI); WDBearManager_I myWoWWDBearManager_API = myAPI; // // print out some statistics // if (this.useGUI == false) { boolean paramSpec = false; // ASSERT DTO_Interface myDTO = null; if (this.paramWdbfile.length() != 0) { paramSpec = true; // Open WDB try { this.items = myWoWWDBearManager_API.readWDBfile(this.paramWdbfile); } catch (Exception ex) { this.myLogger.error("Error reading the WDB file"); return; } // first dto -> to identify the data Iterator itWDBS = this.items.iterator(); if (itWDBS.hasNext()) { myDTO = (DTO_Interface) itWDBS.next(); } } // Create CSV? if (this.paramCSVFolder.length() != 0) { if (myDTO == null) { // NO WDB specified -> exit this.myLogger.error("Error: You did not specify -" + this.PARAM_WDBFILE + "\n"); usage(this.options); return; } File csvFile = new File(this.paramCSVFolder, myDTO.getTableName() + ".csv"); if (this.useVerbose) { this.myLogger.info("Creating CSV file: " + csvFile.getAbsolutePath()); } try { WriteCSV.writeCSV(new File(this.paramCSVFolder), this.items); this.myLogger.info("CSV file written: " + csvFile.getAbsolutePath()); } catch (Exception ex) { ex.printStackTrace(); this.myLogger.error("Error writing the CSV file"); return; } } // Create TXT? if (this.paramTXTFolder.length() != 0) { if (myDTO == null) { // NO WDB specified -> exit this.myLogger.error("Error: You did not specify -" + this.PARAM_WDBFILE + "\n"); usage(this.options); return; } if (this.useVerbose) { String table = myDTO.getTableName(); File txtFile = new File(this.paramTXTFolder, table + ".txt"); this.myLogger.info("Creating TXT file: " + txtFile.getAbsolutePath()); } try { WriteTXT.writeTXT(new File(this.paramTXTFolder), this.items); } catch (Exception ex) { //ex.printStackTrace(); this.myLogger.error("Error writing the TXT file: " + ex.getMessage()); return; } } // Store inside SQL database? if (this.writeSQL == true) { paramSpec = true; if (myDTO == null) { // NO WDB specified -> exit this.myLogger.error("Error: You did not specify -" + this.PARAM_WDBFILE + "\n"); usage(this.options); return; } if (this.useVerbose) { this.myLogger.info("Storing data inside SQL database"); } SQLManager myWriteSQL = null; try { myWriteSQL = new SQLManager(this.WDB_DB_CONFIG_FILE); ObjectsWritten myOWr = myWriteSQL.insertOrUpdateToSQLDB(this.items, this.doUpdate); this.myLogger.info("Operation successfull"); if (this.useVerbose) { this.myLogger.info("DB statistics"); this.myLogger.info("INSERT: " + myOWr.getNumInsert()); this.myLogger.info("UPDATE: " + myOWr.getNumUpdate()); this.myLogger.info("Error INSERT: " + myOWr.getNumErrorInsert()); this.myLogger.info("Error UPDATE: " + myOWr.getNumErrorUpdate()); if (this.doUpdate == false) { this.myLogger.info("Objects skipped: " + myOWr.getNumSkipped()); System.out.println("If you want to overwrite/update objects, use 'update' param"); } this.myLogger.info(WDBearManager.VERSION_INFO); } } catch (Exception ex) { ex.printStackTrace(); this.myLogger.error("Error importing to database"); this.myLogger.error(ex.getMessage()); return; } } // writeSQL // Patch *.SCP with contents of database if (this.paramSCPname.length() != 0) { if (this.paramPatchSCP.length() == 0) { this.myLogger.error("Error: You did not specify -" + WDBearManager.PATCH_SCP + "\n"); usage(this.options); return; } paramSpec = true; this.myLogger.info("Patch scp file with the contents of the database"); try { SCPWritten mySCPW = myWoWWDBearManager_API.patchSCP(this.paramSCPname, this.paramPatchSCP, this.patchUTF8, this.paramLocale); if (this.useVerbose) { this.myLogger.info("Merge statistics"); System.out.println("Entries in database: " + mySCPW.getNumInDB()); this.myLogger.info("Merged with SCP: " + mySCPW.getNumPatched()); this.myLogger.info("Patched IDs: " + mySCPW.getPatchedIDs()); } this.myLogger.info("Patched file: " + this.paramSCPname + "_patch"); } catch (WDBMgr_IOException ex) { this.myLogger.error("The destination SCP file could not be created"); this.myLogger.error(ex.getMessage()); return; } catch (WDBMgr_NoDataAvailableException ex) { this.myLogger.info("Merging impossible"); this.myLogger.info("There are no entries inside the database"); } catch (Exception ex) { this.myLogger.error("Error while merging quests.scp with database"); this.myLogger.error(ex.getMessage()); return; } } // PatchSCP // Call jython script? if (this.paramScript.length() != 0) { paramSpec = true; this.myLogger.info("Calling Jython script"); this.myLogger.info("---"); PythonInterpreter interp = new PythonInterpreter(); interp.set("wdbmgrapi", myWoWWDBearManager_API); // set parameters Set setKeys = this.paramJython.keySet(); Iterator itKeys = setKeys.iterator(); String jyParam = ""; while (itKeys.hasNext()) { jyParam = (String) itKeys.next(); interp.set(jyParam, (String) this.paramJython.get(jyParam)); } interp.execfile(this.paramScript); this.myLogger.info("---"); System.out.println("Jython script executed, " + WDBearManager.VERSION_INFO); return; } // paramScript if (paramSpec == false) { usage(this.options); return; } // Exit return; } // Command Line Version // // GUI // PlasticLookAndFeel.setMyCurrentTheme(new DesertBlue()); try { UIManager.put("ClassLoader", LookUtils.class.getClassLoader()); UIManager.setLookAndFeel(new Plastic3DLookAndFeel()); } catch (Exception e) { } // try { // com.incors.plaf.kunststoff.KunststoffLookAndFeel kunststoffLnF = new com.incors.plaf.kunststoff.KunststoffLookAndFeel(); // KunststoffLookAndFeel // .setCurrentTheme(new com.incors.plaf.kunststoff.KunststoffTheme()); // UIManager.setLookAndFeel(kunststoffLnF); // } catch (javax.swing.UnsupportedLookAndFeelException ex) { // // handle exception or not, whatever you prefer // } // this line needs to be implemented in order to make JWS work properly UIManager.getLookAndFeelDefaults().put("ClassLoader", getClass().getClassLoader()); this.setTitle(WDBearManager.VERSION_INFO); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.getContentPane().setLayout(new BorderLayout()); // construct GUI to display the stuff // Menu // Where the GUI is created: JMenuBar menuBar; JMenu menu; //, submenu; JMenuItem menuItem; //JRadioButtonMenuItem rbMenuItem; //JCheckBoxMenuItem cbMenuItem; // Create the menu bar. menuBar = new JMenuBar(); // Build the first menu. menu = new JMenu("File"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("Process WDB files"); menuBar.add(menu); // Exit menuItem = new JMenuItem(MENU_EXIT, KeyEvent.VK_T); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Exit program"); menuItem.addActionListener(this); menu.add(menuItem); // Build the first menu. menu = new JMenu("About"); menu.setMnemonic(KeyEvent.VK_A); menu.getAccessibleContext().setAccessibleDescription("Whassup?"); menuBar.add(menu); // Help menuItem = new JMenuItem(MENU_HELP, KeyEvent.VK_H); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Help me..."); menuItem.addActionListener(this); menu.add(menuItem); // JavaDocs menuItem = new JMenuItem(MENU_JDOCS, KeyEvent.VK_J); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Show API docs..."); menuItem.addActionListener(this); menu.add(menuItem); // separator menu.addSeparator(); // CheckForUpdate menuItem = new JMenuItem(MENU_CHECKUPDATE, KeyEvent.VK_U); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Check for update..."); menuItem.addActionListener(this); menu.add(menuItem); // separator menu.addSeparator(); // ABOUT menuItem = new JMenuItem(MENU_ABOUT, KeyEvent.VK_T); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.ALT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Ueber..."); menuItem.addActionListener(this); menu.add(menuItem); this.setJMenuBar(menuBar); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new GridLayout(0, 1)); JTabbedPane tabbedPane = new JTabbedPane(); ImageIcon wowIcon = createImageIcon("images/fromdisk.gif"); JComponent panel1 = new WDB_Panel(myWoWWDBearManager_API); tabbedPane.addTab("WDB-Module", wowIcon, panel1, "Handle WDB files"); tabbedPane.setMnemonicAt(0, KeyEvent.VK_1); ImageIcon panelIcon = createImageIcon("images/hsql.gif"); JComponent panel2 = null; try { panel2 = new SQL_Panel(myWoWWDBearManager_API); } catch (Throwable ex) { System.err.println("Error while instantiating SQL Panel: "); System.err.println(ex.getMessage()); ex.printStackTrace(); System.exit(0); } tabbedPane.addTab("DB-Module", panelIcon, panel2, "Handle database"); tabbedPane.setMnemonicAt(1, KeyEvent.VK_2); panelIcon = createImageIcon("images/pythonpoweredsmall.gif"); JComponent panel3 = new Python_Panel(myWoWWDBearManager_API); tabbedPane.addTab("Scripts", panelIcon, panel3, "Scripting"); tabbedPane.setMnemonicAt(2, KeyEvent.VK_3); // maybe user PLUGIN availabe // -> check for folders below "plugins" File filUserPanels = new File("plugins"); // 1) find user plugins (scan for directories) // 2) scan for <name>.properties, where <name> is the name of the directory // 3) load the properties file and get the plugin running String[] strUserPlugins = filUserPanels.list(new FilenameFilter() { public boolean accept(File dir, String name) { return (new File(dir, name).isDirectory()); } }); if (strUserPlugins != null) { ArrayList urlJars = new ArrayList(); //URL[] urlJars = new URL[strUserPlugins.length]; String strCurrJar = ""; String strPlugins[] = new String[strUserPlugins.length]; try { for (int i = 0; i < strUserPlugins.length; i++) { File baseFile = new File("plugins", strUserPlugins[i]); File filProperties = new File(baseFile, strUserPlugins[i] + ".properties"); if (filProperties.exists()) { // set plugin folder and .properties name strPlugins[i] = strUserPlugins[i]; this.myLogger.info("Found 'plugin' : " + baseFile.getAbsolutePath()); this.myLogger.info(" Trying to load .jar file"); // Scan for JAR files and include them //System.out.println(baseFile.getAbsolutePath()); String[] strJars = baseFile.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".jar"); } }); for (int j = 0; j < strJars.length; j++) { File filJAR = new File(baseFile, strJars[j]); strCurrJar = filJAR.getAbsolutePath(); this.myLogger.info("Loading external 'plugin' JAR: " + strCurrJar); URL jarfile = new URL("jar", "", "file:" + strCurrJar + "!/"); urlJars.add(jarfile); } } else { // print warning - a directory inside plugins, but there is no plugin this.myLogger.warn("Found directory inside plugins folder, but no .properties file"); this.myLogger.warn(" Name of directory: " + strUserPlugins[i]); this.myLogger.warn(" Please review the directory!"); } } // for... all user plugins } catch (Exception ex) { this.myLogger.error("Plugin: Error loading " + strCurrJar); this.myLogger.error("Please check your 'plugin' folder"); } URLClassLoader cl = null; try { // File file = new File("plugins", strUserJars[i]); // this.myLogger.info("Lade externes JAR: " + file.getAbsolutePath()); // URL jarfile = new URL("jar", "", "file:" + file.getAbsolutePath() + "!/"); URL[] loadURLs = new URL[urlJars.toArray().length]; for (int j = 0; j < urlJars.toArray().length; j++) { loadURLs[j] = (URL) urlJars.get(j); } cl = URLClassLoader.newInstance(loadURLs); Thread.currentThread().setContextClassLoader(cl); // String lcStr = "Test"; // Class loadedClass = cl.loadClass(lcStr); // this.myLogger.info("Smooth..."); } catch (Exception ex) { ex.printStackTrace(); } // 2) load properties and instantiate the plugin // String[] strPlugins = filUserPanels.list(new FilenameFilter() { // public boolean accept(File dir, String name) { // return (name.endsWith("_plugin.properties")); // } // }); String strPluginName = ""; String strPluginClass = ""; String strPluginImage = ""; WDBearPlugin pluginPanel = null; for (int i = 0; i < strPlugins.length; i++) { //this.myLogger.info(strPlugins[i]); Properties prpPlugin = null; try { prpPlugin = ReadPropertiesFile.readProperties( new File("plugins", strPlugins[i] + "/" + strPlugins[i]).getAbsolutePath() + ".properties"); } catch (Exception ex) { this.myLogger.error("Error with plugin: " + strPlugins[i]); this.myLogger.error("Could not load properties file"); continue; } if ((strPluginClass = prpPlugin.getProperty(this.PLUGIN_CLASS)) == null) { this.myLogger.error("Error with plugin: " + strPlugins[i]); this.myLogger.error("Property '" + this.PLUGIN_CLASS + "' not found"); continue; } if ((strPluginName = prpPlugin.getProperty(this.PLUGIN_NAME)) == null) { this.myLogger.error("Error with plugin: " + strPlugins[i]); this.myLogger.error("Property '" + this.PLUGIN_NAME + "' not found"); continue; } if ((strPluginImage = prpPlugin.getProperty(this.PLUGIN_IMAGE)) == null) { this.myLogger.error("Error with plugin: " + strPlugins[i]); this.myLogger.error("Property '" + this.PLUGIN_IMAGE + "' not found"); continue; } File filPlgImg = new File("plugins", strPlugins[i] + "/" + strPluginImage); panelIcon = createImageIcon(filPlgImg.getAbsolutePath()); if (panelIcon == null) { this.myLogger.error("Error with plugin: " + strPlugins[i]); this.myLogger.error("Could not read image '" + strPluginImage + "'"); continue; } try { pluginPanel = (WDBearPlugin) (cl.loadClass(strPluginClass).newInstance()); pluginPanel.runPlugin(myAPI); } catch (Exception ex) { this.myLogger.error("Error with plugin: " + strPlugins[i]); this.myLogger.error("Could not instantiate '" + strPluginClass + "'"); ex.printStackTrace(); continue; } tabbedPane.addTab(strPluginName, panelIcon, pluginPanel, strPluginName); } // Plugins } // plugins folder found mainPanel.add(tabbedPane); this.getContentPane().add(mainPanel, BorderLayout.CENTER); this.setSize(1024, 768); //this.pack(); this.show(); }
From source file:fi.hoski.remote.ui.Admin.java
private void menuFile() { JMenu fileMenu = new JMenu(); TextUtil.populate(fileMenu, "FILE"); menuBar.add(fileMenu);//from www .j av a2 s .co m if (accessUser) { fileMenu.add(menuItemSync()); } if (privileged || isRaceAdmin) { fileMenu.add(menuItemTextMaintenence()); } if (privileged) { fileMenu.add(menuItemTextUpload()); fileMenu.add(menuItemTextDownload()); fileMenu.add(menuItemAttach()); fileMenu.add(menuItemRemoveAttachment()); } if (serverProperties.isZonerSMSSupported()) { fileMenu.add(menuItemSMSCredits()); } fileMenu.addSeparator(); if (privileged) { fileMenu.add(menuItemRemoveEntity()); fileMenu.add(menuItemRemoveYear()); fileMenu.addSeparator(); fileMenu.add(menuItemBackupEntity()); fileMenu.add(menuItemBackupYear()); fileMenu.addSeparator(); fileMenu.add(menuItemRestoreEntity()); fileMenu.add(menuItemRestore()); fileMenu.add(menuItemAddYear()); } fileMenu.addSeparator(); if (accessUser) { fileMenu.add(menuItemInspectAllLightBoats()); fileMenu.add(menuItemInspectionFix1()); fileMenu.add(menuItemSql()); fileMenu.add(menuItemUninspectedBoats()); } fileMenu.addSeparator(); JMenuItem exitItem = new JMenuItem(); TextUtil.populate(exitItem, "EXIT"); ActionListener exitAction = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { confirmSaveReservations(); System.exit(0); } }; exitAction = createActionListener(frame, exitAction); exitItem.addActionListener(exitAction); fileMenu.add(exitItem); }
From source file:com.emental.mindraider.ui.frames.MindRaiderMainWindow.java
/** * Build main menu./*from w w w .ja v a2 s . c o m*/ * * @param spiders */ private void buildMenu(final SpidersGraph spiders) { JMenuBar menuBar; JMenu menu, submenu; JMenuItem menuItem, subMenuItem; JRadioButtonMenuItem rbMenuItem; // create the menu bar menuBar = new JMenuBar(); setJMenuBar(menuBar); // - main menu ------------------------------------------------------- menu = new JMenu(MindRaiderConstants.MR_TITLE); menu.setMnemonic(KeyEvent.VK_M); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.setActiveNotebookAsHome")); menuItem.setMnemonic(KeyEvent.VK_H); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.profile.setHomeNotebook(); } }); menu.add(menuItem); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.preferences")); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new PreferencesJDialog(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.exit"), KeyEvent.VK_X); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { exitMindRaider(); } }); menu.add(menuItem); menuBar.add(menu); // - Find ---------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.search")); menu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchNotebooks")); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new OpenOutlineJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchFulltext")); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new FtsJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchConceptsInNotebook")); menuItem.setMnemonic(KeyEvent.VK_C); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutlineUri() != null) { new OpenNoteJDialog(); } } }); menu.add(menuItem); // search by tag menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchConceptsByTag")); menuItem.setEnabled(true); menuItem.setMnemonic(KeyEvent.VK_T); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new OpenConceptByTagJDialog(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.previousNote")); menuItem.setEnabled(true); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.recentConcepts.moveOneNoteBack(); } }); menu.add(menuItem); // global RDF search // menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchRdql")); // menuItem.setEnabled(false); // menuItem.setMnemonic(KeyEvent.VK_R); // menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, // ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); // menuItem.addActionListener(new ActionListener() { // // public void actionPerformed(ActionEvent e) { // // TODO rdql to be implemented // } // }); // menu.add(menuItem); menuBar.add(menu); // - view ------------------------------------------------------------ menu = new JMenu(Messages.getString("MindRaiderJFrame.view")); menu.setMnemonic(KeyEvent.VK_V); // TODO localize L&F menu ButtonGroup lfGroup = new ButtonGroup(); submenu = new JMenu(Messages.getString("MindRaiderJFrame.lookAndFeel")); logger.debug("Look and feel is: " + MindRaider.profile.getLookAndFeel()); // {{debug}} submenu.setMnemonic(KeyEvent.VK_L); subMenuItem = new JRadioButtonMenuItem(Messages.getString("MindRaiderJFrame.lookAndFeelNative")); if (MindRaider.LF_NATIVE.equals(MindRaider.profile.getLookAndFeel())) { subMenuItem.setSelected(true); } subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel(MindRaider.LF_NATIVE); } }); submenu.add(subMenuItem); lfGroup.add(subMenuItem); subMenuItem = new JRadioButtonMenuItem(Messages.getString("MindRaiderJFrame.lookAndFeelJava")); if (MindRaider.LF_JAVA_DEFAULT.equals(MindRaider.profile.getLookAndFeel())) { subMenuItem.setSelected(true); } subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel(MindRaider.LF_JAVA_DEFAULT); } }); submenu.add(subMenuItem); lfGroup.add(subMenuItem); menu.add(submenu); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.leftSideBar")); menuItem.setMnemonic(KeyEvent.VK_L); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (leftSidebarSplitPane.getDividerLocation() == 1) { leftSidebarSplitPane.resetToPreferredSizes(); } else { closeLeftSidebar(); } } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rightSideBar")); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().toggleRightSidebar(); } }); menu.add(menuItem); // TODO tips to be implemented // JCheckBoxMenuItem helpCheckbox=new JCheckBoxMenuItem("Tips",true); // menu.add(helpCheckbox); // TODO localize menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.toolbar")); menuItem.setMnemonic(KeyEvent.VK_T); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.masterToolBar.toggleVisibility(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rdfNavigatorDashboard")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.spidersGraph.getGlPanel().toggleControlPanel(); } }); menu.add(menuItem); JCheckBoxMenuItem checkboxMenuItem; ButtonGroup colorSchemeGroup; // if (!MindRaider.OUTLINER_PERSPECTIVE.equals(MindRaider.profile // .getUiPerspective())) { menu.addSeparator(); // Facets submenu = new JMenu(Messages.getString("MindRaiderJFrame.facet")); submenu.setMnemonic(KeyEvent.VK_F); colorSchemeGroup = new ButtonGroup(); String[] facetLabels = FacetCustodian.getInstance().getFacetLabels(); if (!ArrayUtils.isEmpty(facetLabels)) { for (String facetLabel : facetLabels) { rbMenuItem = new JRadioButtonMenuItem(facetLabel); rbMenuItem.addActionListener(new FacetActionListener(facetLabel)); colorSchemeGroup.add(rbMenuItem); submenu.add(rbMenuItem); if (BriefFacet.LABEL.equals(facetLabel)) { rbMenuItem.setSelected(true); } } } menu.add(submenu); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.graphLabelAsUri")); checkboxMenuItem.setMnemonic(KeyEvent.VK_G); checkboxMenuItem.setState(MindRaider.spidersGraph.isUriLabels()); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); MindRaider.spidersGraph.setUriLabels(j.getState()); MindRaider.spidersGraph.renderModel(); MindRaider.profile.setGraphShowLabelsAsUris(j.getState()); MindRaider.profile.save(); } } }); menu.add(checkboxMenuItem); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.predicateNodes")); checkboxMenuItem.setMnemonic(KeyEvent.VK_P); checkboxMenuItem.setState(!MindRaider.spidersGraph.getHidePredicates()); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); MindRaider.spidersGraph.hidePredicates(!j.getState()); MindRaider.spidersGraph.renderModel(); MindRaider.profile.setGraphHidePredicates(!j.getState()); MindRaider.profile.save(); } } }); menu.add(checkboxMenuItem); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.multilineLabels")); checkboxMenuItem.setMnemonic(KeyEvent.VK_M); checkboxMenuItem.setState(MindRaider.spidersGraph.isMultilineNodes()); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); MindRaider.spidersGraph.setMultilineNodes(j.getState()); MindRaider.spidersGraph.renderModel(); MindRaider.profile.setGraphMultilineLabels(j.getState()); MindRaider.profile.save(); } } }); menu.add(checkboxMenuItem); // } menu.addSeparator(); // Antialias checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.antiAliased"), true); checkboxMenuItem.setMnemonic(KeyEvent.VK_A); checkboxMenuItem.setState(SpidersGraph.antialiased); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); SpidersGraph.antialiased = j.getState(); MindRaider.spidersGraph.renderModel(); } } }); menu.add(checkboxMenuItem); // Enable hyperbolic checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.hyperbolic"), true); checkboxMenuItem.setMnemonic(KeyEvent.VK_H); checkboxMenuItem.setState(SpidersGraph.hyperbolic); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); SpidersGraph.hyperbolic = j.getState(); MindRaider.spidersGraph.renderModel(); } } }); menu.add(checkboxMenuItem); // Show FPS checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.fps"), true); checkboxMenuItem.setMnemonic(KeyEvent.VK_F); checkboxMenuItem.setState(SpidersGraph.fps); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); SpidersGraph.fps = j.getState(); MindRaider.spidersGraph.renderModel(); } } }); menu.add(checkboxMenuItem); // Graph color scheme submenu = new JMenu(Messages.getString("MindRaiderJFrame.colorScheme")); submenu.setMnemonic(KeyEvent.VK_C); String[] allProfilesUris = MindRaider.spidersColorProfileRegistry.getAllProfilesUris(); colorSchemeGroup = new ButtonGroup(); for (int i = 0; i < allProfilesUris.length; i++) { rbMenuItem = new UriJRadioButtonMenuItem( MindRaider.spidersColorProfileRegistry.getColorProfileByUri(allProfilesUris[i]).getLabel(), allProfilesUris[i]); rbMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof UriJRadioButtonMenuItem) { MindRaider.spidersColorProfileRegistry .setCurrentProfile(((UriJRadioButtonMenuItem) e.getSource()).uri); MindRaider.spidersGraph .setRenderingProfile(MindRaider.spidersColorProfileRegistry.getCurrentProfile()); MindRaider.spidersGraph.renderModel(); } } }); colorSchemeGroup.add(rbMenuItem); submenu.add(rbMenuItem); } menu.add(submenu); // Annotation color scheme submenu = new JMenu(Messages.getString("MindRaiderJFrame.colorSchemeAnnotation")); submenu.setMnemonic(KeyEvent.VK_A); allProfilesUris = MindRaider.annotationColorProfileRegistry.getAllProfilesUris(); colorSchemeGroup = new ButtonGroup(); for (int i = 0; i < allProfilesUris.length; i++) { rbMenuItem = new UriJRadioButtonMenuItem( MindRaider.annotationColorProfileRegistry.getColorProfileByUri(allProfilesUris[i]).getLabel(), allProfilesUris[i]); rbMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof UriJRadioButtonMenuItem) { MindRaider.annotationColorProfileRegistry .setCurrentProfile(((UriJRadioButtonMenuItem) e.getSource()).uri); OutlineJPanel.getInstance().conceptJPanel.refresh(); } } }); colorSchemeGroup.add(rbMenuItem); submenu.add(rbMenuItem); } menu.add(submenu); menu.addSeparator(); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.fullScreen")); checkboxMenuItem.setMnemonic(KeyEvent.VK_U); checkboxMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0)); checkboxMenuItem.setState(false); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); if (j.getState()) { Gfx.toggleFullScreen(MindRaiderMainWindow.this); } else { Gfx.toggleFullScreen(null); } } } }); menu.add(checkboxMenuItem); menuBar.add(menu); // - outline // ---------------------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.notebook")); menu.setMnemonic(KeyEvent.VK_N); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.newNotebook")); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO clear should be optional - only if creation finished // MindRider.spidersGraph.clear(); new NewOutlineJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.open")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new OpenOutlineJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.close")); menuItem.setMnemonic(KeyEvent.VK_C); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.outlineCustodian.close(); OutlineJPanel.getInstance().refresh(); MindRaider.spidersGraph.renderModel(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.discard")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.setEnabled(false); // TODO discard method must be implemented menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int result = JOptionPane.showConfirmDialog(MindRaiderMainWindow.this, Messages.getString( "MindRaiderJFrame.confirmDiscardNotebook", MindRaider.profile.getActiveOutline())); if (result == JOptionPane.YES_OPTION) { if (MindRaider.profile.getActiveOutlineUri() != null) { try { MindRaider.labelCustodian .discardOutline(MindRaider.profile.getActiveOutlineUri().toString()); MindRaider.outlineCustodian.close(); } catch (Exception e1) { logger.error(Messages.getString("MindRaiderJFrame.unableToDiscardNotebook"), e1); } } } } }); menu.add(menuItem); menu.addSeparator(); // export submenu = new JMenu(Messages.getString("MindRaiderJFrame.export")); submenu.setMnemonic(KeyEvent.VK_E); // Atom subMenuItem = new JMenuItem("Atom"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exportActiveOutlineToAtom(); } }); submenu.add(subMenuItem); // OPML subMenuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.opml")); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutline() == null) { JOptionPane.showMessageDialog(MindRaiderMainWindow.this, Messages.getString("MindRaiderJFrame.exportNotebookWarning"), Messages.getString("MindRaiderJFrame.exportError"), JOptionPane.ERROR_MESSAGE); return; } JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export" + File.separator + "opml"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { String dstFileName = fc.getSelectedFile().getAbsolutePath() + File.separator + "OPML-EXPORT-" + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".xml"; logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName)); MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_OPML, dstFileName); Launcher.launchViaStart(dstFileName); } else { logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser")); } } }); submenu.add(subMenuItem); // TWiki subMenuItem = new JMenuItem("TWiki"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutline() == null) { JOptionPane.showMessageDialog(MindRaiderMainWindow.this, Messages.getString("MindRaiderJFrame.exportNotebookWarning"), Messages.getString("MindRaiderJFrame.exportError"), JOptionPane.ERROR_MESSAGE); return; } JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export" + File.separator + "twiki"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final String dstFileName = fc.getSelectedFile().getAbsolutePath() + File.separator + "TWIKI-EXPORT-" + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".txt"; logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName)); MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_TWIKI, dstFileName); } else { logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser")); } } }); submenu.add(subMenuItem); menu.add(submenu); // import submenu = new JMenu(Messages.getString("MindRaiderJFrame.import")); submenu.setMnemonic(KeyEvent.VK_I); subMenuItem = new JMenuItem("Atom"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { importFromAtom(); } }); submenu.add(subMenuItem); // TWiki subMenuItem = new JMenuItem("TWiki"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // choose file to be transformed OutlineJPanel.getInstance().clear(); MindRaider.profile.setActiveOutlineUri(null); JFileChooser fc = new JFileChooser(); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final File file = fc.getSelectedFile(); MindRaider.profile.deleteActiveModel(); logger.debug( Messages.getString("MindRaiderJFrame.importingTWikiTopic", file.getAbsolutePath())); // perform it async final SwingWorker worker = new SwingWorker() { public Object construct() { ProgressDialogJFrame progressDialogJFrame = new ProgressDialogJFrame( Messages.getString("MindRaiderJFrame.twikiImport"), Messages.getString("MindRaiderJFrame.processingTopicTWiki")); try { MindRaider.outlineCustodian.importNotebook(OutlineCustodian.FORMAT_TWIKI, (file != null ? file.getAbsolutePath() : null), progressDialogJFrame); } finally { if (progressDialogJFrame != null) { progressDialogJFrame.dispose(); } } return null; } }; worker.start(); } else { logger.debug(Messages.getString("MindRaiderJFrame.openCommandCancelledByUser")); } } }); submenu.add(subMenuItem); menu.add(submenu); menuBar.add(menu); // - note // ---------------------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.concept")); menu.setMnemonic(KeyEvent.VK_C); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.new")); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().newConcept(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.open")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutlineUri() != null) { new OpenNoteJDialog(); } } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.discard")); // do not accelerate this command with DEL - it's already handled // elsewhere menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptDiscard(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.up")); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptUp(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.promote")); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptPromote(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.demote")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptDemote(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.down")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptDown(); } }); menu.add(menuItem); menuBar.add(menu); // - Tools ----------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.tools")); menu.setMnemonic(KeyEvent.VK_T); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.checkAndFix")); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Checker.checkAndFixRepositoryAsync(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.backupRepository")); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Installer.backupRepositoryAsync(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rebuildSearchIndex")); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SearchCommander.rebuildSearchAndTagIndices(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.captureScreen")); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.screenshot")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseScreenshotDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "Screenshots"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final String filename = fc.getSelectedFile().getAbsolutePath() + File.separator + "screenshot.jpg"; // do it in async (redraw screen) Thread thread = new Thread() { public void run() { OutputStream file = null; try { file = new FileOutputStream(filename); Robot robot = new Robot(); robot.delay(1000); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(file); encoder.encode(robot.createScreenCapture( new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()))); } catch (Exception e1) { logger.error("Unable to capture screen!", e1); } finally { if (file != null) { try { file.close(); } catch (IOException e1) { logger.error("Unable to close stream", e1); } } } } }; thread.setDaemon(true); thread.start(); } } }); menu.add(menuItem); menuBar.add(menu); // - MindForger ----------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderMainWindow.menuMindForger")); menu.setMnemonic(KeyEvent.VK_O); //menu.setIcon(IconsRegistry.getImageIcon("tasks-internet.png")); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerVideoTutorial")); menuItem.setMnemonic(KeyEvent.VK_G); menuItem.setToolTipText("http://mindraider.sourceforge.net/mindforger.html"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://mindraider.sourceforge.net/mindforger.html"); } }); menuItem.setEnabled(true); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.signUp")); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.setToolTipText("http://www.mindforger.com"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://www.mindforger.com"); } }); menuItem.setEnabled(true); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerUpload")); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // fork in order to enable status updates in the main window new MindForgerUploadOutlineJDialog(); } }); menuItem.setEnabled(true); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerDownload")); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { downloadAnOutlineFromMindForger(); } }); menuItem.setEnabled(true); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerMyOutlines")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setEnabled(true); menuItem.setToolTipText("http://web.mindforger.com"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://web.mindforger.com"); } }); menu.add(menuItem); menuBar.add(menu); // - align Help on right ------------------------------------------------------------- menuBar.add(Box.createHorizontalGlue()); // - help ------------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.help")); menu.setMnemonic(KeyEvent.VK_H); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.documentation")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { MindRaider.outlineCustodian.loadOutline(new URI(MindRaiderVocabulary .getNotebookUri(OutlineCustodian.MR_DOC_NOTEBOOK_DOCUMENTATION_LOCAL_NAME))); OutlineJPanel.getInstance().refresh(); } catch (Exception e1) { logger.error(Messages.getString("MindRaiderJFrame.unableToLoadHelp", e1.getMessage())); } } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.webHomepage")); menuItem.setMnemonic(KeyEvent.VK_H); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://mindraider.sourceforge.net"); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.reportBug")); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://sourceforge.net/forum/?group_id=128454"); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.updateCheck")); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // just open html page at: // http://mindraider.sourceforge.net/update-7.2.html // this page will either contain "you have the last version" or will ask user to // download the latest version from main page Launcher.launchInBrowser("http://mindraider.sourceforge.net/" + "update-" + MindRaiderConstants.majorVersion + "." + MindRaiderConstants.minorVersion + ".html"); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.about", MindRaiderConstants.MR_TITLE)); menuItem.setMnemonic(KeyEvent.VK_A); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AboutJDialog(); } }); menu.add(menuItem); menuBar.add(menu); }
From source file:net.sf.jabref.gui.JabRefFrame.java
private void fillMenu() { mb.setBorder(null);/*from ww w .j a va 2s . co m*/ JMenu file = JabRefFrame.subMenu(Localization.menuTitle("File")); JMenu edit = JabRefFrame.subMenu(Localization.menuTitle("Edit")); JMenu search = JabRefFrame.subMenu(Localization.menuTitle("Search")); JMenu groups = JabRefFrame.subMenu(Localization.menuTitle("Groups")); JMenu bibtex = JabRefFrame.subMenu("&BibTeX"); JMenu quality = JabRefFrame.subMenu(Localization.menuTitle("Quality")); JMenu view = JabRefFrame.subMenu(Localization.menuTitle("View")); JMenu tools = JabRefFrame.subMenu(Localization.menuTitle("Tools")); JMenu options = JabRefFrame.subMenu(Localization.menuTitle("Options")); JMenu newSpec = JabRefFrame.subMenu(Localization.menuTitle("New entry by type...")); JMenu helpMenu = JabRefFrame.subMenu(Localization.menuTitle("Help")); file.add(newBibtexDatabaseAction); file.add(newBiblatexDatabaseAction); file.add(getOpenDatabaseAction()); file.add(mergeDatabaseAction); file.add(save); file.add(saveAs); file.add(saveAll); file.add(saveSelectedAs); file.add(saveSelectedAsPlain); file.addSeparator(); file.add(importNew); file.add(importCurrent); file.add(exportAll); file.add(exportSelected); file.addSeparator(); file.add(dbConnect); file.add(dbImport); file.add(dbExport); file.addSeparator(); file.add(databaseProperties); file.add(editModeAction); file.addSeparator(); file.add(fileHistory); file.addSeparator(); file.add(closeDatabaseAction); file.add(quit); mb.add(file); edit.add(undo); edit.add(redo); edit.addSeparator(); edit.add(cut); edit.add(copy); edit.add(paste); edit.addSeparator(); edit.add(copyKey); edit.add(copyCiteKey); edit.add(copyKeyAndTitle); edit.add(exportToClipboard); edit.add(sendAsEmail); edit.addSeparator(); edit.add(mark); JMenu markSpecific = JabRefFrame.subMenu(Localization.menuTitle("Mark specific color")); for (int i = 0; i < EntryMarker.MAX_MARKING_LEVEL; i++) { markSpecific.add(new MarkEntriesAction(this, i).getMenuItem()); } edit.add(markSpecific); edit.add(unmark); edit.add(unmarkAll); edit.addSeparator(); if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED)) { JMenu m; if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING)) { m = new JMenu(); RightClickMenu.populateSpecialFieldMenu(m, Rank.getInstance(), this); edit.add(m); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE)) { edit.add(toggleRelevance); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY)) { edit.add(toggleQualityAssured); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY)) { m = new JMenu(); RightClickMenu.populateSpecialFieldMenu(m, Priority.getInstance(), this); edit.add(m); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRINTED)) { edit.add(togglePrinted); } if (Globals.prefs.getBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_READ)) { m = new JMenu(); RightClickMenu.populateSpecialFieldMenu(m, ReadStatus.getInstance(), this); edit.add(m); } edit.addSeparator(); } edit.add(getManageKeywords()); edit.add(getMassSetField()); edit.addSeparator(); edit.add(selectAll); mb.add(edit); search.add(normalSearch); search.add(replaceAll); search.addSeparator(); search.add(new JCheckBoxMenuItem(generalFetcher.getAction())); if (prefs.getBoolean(JabRefPreferences.WEB_SEARCH_VISIBLE)) { sidePaneManager.register(generalFetcher.getTitle(), generalFetcher); sidePaneManager.show(generalFetcher.getTitle()); } mb.add(search); groups.add(new JCheckBoxMenuItem(toggleGroups)); groups.addSeparator(); groups.add(addToGroup); groups.add(removeFromGroup); groups.add(moveToGroup); groups.addSeparator(); JRadioButtonMenuItem toggleHighlightAnyItem = new JRadioButtonMenuItem(toggleHighlightAny); groups.add(toggleHighlightAnyItem); JRadioButtonMenuItem toggleHighlightAllItem = new JRadioButtonMenuItem(toggleHighlightAll); groups.add(toggleHighlightAllItem); JRadioButtonMenuItem toggleHighlightDisableItem = new JRadioButtonMenuItem(toggleHighlightDisable); groups.add(toggleHighlightDisableItem); ButtonGroup highlightButtonGroup = new ButtonGroup(); highlightButtonGroup.add(toggleHighlightDisableItem); highlightButtonGroup.add(toggleHighlightAnyItem); highlightButtonGroup.add(toggleHighlightAllItem); HighlightMatchingGroupPreferences highlightMatchingGroupPreferences = new HighlightMatchingGroupPreferences( Globals.prefs); if (highlightMatchingGroupPreferences.isAll()) { toggleHighlightAllItem.setSelected(true); } else if (highlightMatchingGroupPreferences.isAny()) { toggleHighlightAnyItem.setSelected(true); } else { toggleHighlightDisableItem.setSelected(true); } mb.add(groups); view.add(getBackAction()); view.add(getForwardAction()); view.add(focusTable); view.add(nextTab); view.add(prevTab); view.add(sortTabs); view.addSeparator(); view.add(increaseFontSize); view.add(decreseFontSize); view.addSeparator(); view.add(new JCheckBoxMenuItem(toggleToolbar)); view.add(new JCheckBoxMenuItem(enableToggle(generalFetcher.getAction()))); view.add(new JCheckBoxMenuItem(toggleGroups)); view.add(new JCheckBoxMenuItem(togglePreview)); view.add(getSwitchPreviewAction()); mb.add(view); bibtex.add(newEntryAction); for (NewEntryAction a : newSpecificEntryAction) { newSpec.add(a); } bibtex.add(newSpec); bibtex.add(plainTextImport); bibtex.addSeparator(); bibtex.add(editEntry); bibtex.add(editPreamble); bibtex.add(editStrings); bibtex.addSeparator(); bibtex.add(customizeAction); bibtex.addSeparator(); bibtex.add(deleteEntry); mb.add(bibtex); quality.add(dupliCheck); quality.add(mergeEntries); quality.addSeparator(); quality.add(resolveDuplicateKeys); quality.add(checkIntegrity); quality.add(cleanupEntries); quality.add(makeKeyAction); quality.addSeparator(); quality.add(autoSetFile); quality.add(findUnlinkedFiles); quality.add(autoLinkFile); quality.add(downloadFullText); mb.add(quality); tools.add(newSubDatabaseAction); tools.add(writeXmpAction); OpenOfficePanel otp = OpenOfficePanel.getInstance(); otp.init(this, sidePaneManager); tools.add(otp.getMenuItem()); tools.add(pushExternalButton.getMenuAction()); tools.addSeparator(); tools.add(openFolder); tools.add(openFile); tools.add(openUrl); tools.add(openConsole); tools.addSeparator(); tools.add(abbreviateIso); tools.add(abbreviateMedline); tools.add(unabbreviate); mb.add(tools); options.add(showPrefs); AbstractAction genFieldsCustomization = new GenFieldsCustomizationAction(); options.add(genFieldsCustomization); options.add(customExpAction); options.add(customImpAction); options.add(customFileTypesAction); options.add(manageJournals); options.add(manageSelectors); options.add(selectKeys); mb.add(options); helpMenu.add(help); helpMenu.add(openForumAction); helpMenu.addSeparator(); helpMenu.add(errorConsole); helpMenu.addSeparator(); helpMenu.add(forkMeOnGitHubAction); helpMenu.add(donationAction); helpMenu.addSeparator(); helpMenu.add(new SearchForUpdateAction()); helpMenu.add(about); mb.add(helpMenu); createDisabledIconsForMenuEntries(mb); }
From source file:com.diversityarrays.kdxplore.curate.TrialDataEditor.java
@Override public JMenuBar getJMenuBar() { if (menuBar == null) { JMenuItem menuItem;//from w w w .j a v a 2s . c o m // JMenu windowsMenu = new JMenu("Graphs & Plots"); showAll.setEnabled(false); menuItem = windowsMenu.add(showAll); menuItem.setMnemonic('B'); menuItem.setAccelerator( KeyStroke.getKeyStroke('B', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); closeAll.setEnabled(false); windowsMenu.add(closeAll); windowsMenu.addSeparator(); JMenu fileMenu = new JMenu(Msg.MENU_FILE()); menuItem = fileMenu.add(saveChangesAction); menuItem.setMnemonic('S'); menuItem.setAccelerator( KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItem = fileMenu.add(exportCuratedData); // menuItem.setMnemonic('T'); // menuItem.setAccelerator(KeyStroke.getKeyStroke('T', // Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask())); fileMenu.addSeparator(); fileMenu.add(importCuratedData); importCuratedData.setEnabled(true); JMenu editMenu = new JMenu(Msg.MENU_EDIT()); menuItem = editMenu.add(undoAction); menuItem.setMnemonic('Z'); menuItem.setAccelerator( KeyStroke.getKeyStroke('Z', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItem = editMenu.add(redoAction); menuItem.setMnemonic('Y'); menuItem.setAccelerator( KeyStroke.getKeyStroke('Y', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); // undockMenuItem = viewMenu.add(undockViewAction); showWarnings.setEnabled(false); JMenu viewMenu = new JMenu(Msg.MENU_VIEW()); viewMenu.add(showWarnings); problemMenu.add(new ReportIssueAction(this)); menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(editMenu); menuBar.add(viewMenu); menuBar.add(windowsMenu); menuBar.add(problemMenu); } return menuBar; }
From source file:de.huxhorn.lilith.swing.ViewActions.java
public ViewActions(MainFrame mainFrame) { this.mainFrame = mainFrame; containerChangeListener = new ChangeListener() { /**// w w w . j a v a 2 s .c o m * Invoked when the target of the listener has changed its state. * * @param e a ChangeEvent object */ public void stateChanged(ChangeEvent e) { updateActions(); } }; containerPropertyChangeListener = new PropertyChangeListener() { /** * This method gets called when a bound property is changed. * * @param evt A PropertyChangeEvent object describing the event source * and the property that has changed. */ public void propertyChange(PropertyChangeEvent evt) { if (ViewContainer.SELECTED_EVENT_PROPERTY_NAME.equals(evt.getPropertyName())) { setEventWrapper((EventWrapper) evt.getNewValue()); } } }; keyStrokeActionMapping = new HashMap<KeyStroke, CopyToClipboardAction>(); // ##### Menu Actions ##### // File OpenMenuAction openMenuAction = new OpenMenuAction(); clearRecentFilesAction = new ClearRecentFilesAction(); OpenInactiveLogMenuAction openInactiveLogMenuAction = new OpenInactiveLogMenuAction(); ImportMenuAction importMenuAction = new ImportMenuAction(); exportMenuAction = new ExportMenuAction(); CleanAllInactiveLogsMenuAction cleanAllInactiveLogsMenuAction = new CleanAllInactiveLogsMenuAction(); preferencesMenuAction = new PreferencesMenuAction(); ExitMenuAction exitMenuAction = new ExitMenuAction(); // Edit showUnfilteredEventAction = new ShowUnfilteredEventAction(); gotoSourceAction = new GotoSourceAction(); copySelectionAction = new CopySelectionAction(); copyEventAction = new CopyToClipboardAction(new EventFormatter()); copyLoggingActions = new ArrayList<CopyToClipboardAction>(); copyLoggingActions.add(new CopyToClipboardAction(new EventJsonFormatter())); copyLoggingActions.add(new CopyToClipboardAction(new EventXmlFormatter())); copyLoggingActions.add(new CopyToClipboardAction(new LoggingMessageFormatter())); copyLoggingActions.add(new CopyToClipboardAction(new LoggingMessagePatternFormatter())); copyLoggingActions.add(new CopyToClipboardAction(new LoggingLoggerNameFormatter())); copyLoggingActions.add(new CopyToClipboardAction(new LoggingThrowableFormatter())); copyLoggingActions.add(new CopyToClipboardAction(new LoggingCallStackFormatter())); copyLoggingActions.add(new CopyToClipboardAction(new LoggingCallLocationFormatter())); copyLoggingActions.add(new CopyToClipboardAction(new LoggingMarkerFormatter())); copyLoggingActions.add(new CopyToClipboardAction(new LoggingMdcFormatter())); copyLoggingActions.add(new CopyToClipboardAction(new LoggingNdcFormatter())); copyAccessActions = new ArrayList<CopyToClipboardAction>(); copyAccessActions.add(new CopyToClipboardAction(new AccessUriFormatter())); prepareClipboardActions(copyLoggingActions, keyStrokeActionMapping); prepareClipboardActions(copyAccessActions, keyStrokeActionMapping); // Search findMenuAction = new FindMenuAction(); findPreviousAction = new FindPreviousAction(); findNextAction = new FindNextAction(); findPreviousActiveAction = new FindPreviousActiveAction(); findNextActiveAction = new FindNextActiveAction(); resetFindAction = new ResetFindAction(); // View scrollToBottomMenuAction = new ScrollToBottomMenuAction(); pauseMenuAction = new PauseMenuAction(); clearMenuAction = new ClearMenuAction(); attachMenuAction = new AttachMenuAction(); disconnectMenuAction = new DisconnectMenuAction(); focusMessageAction = new FocusMessageAction(); focusEventsAction = new FocusEventsAction(); //statisticsMenuAction = new StatisticsMenuAction(); editSourceNameMenuAction = new EditSourceNameMenuAction(); saveLayoutAction = new SaveLayoutAction(); resetLayoutAction = new ResetLayoutAction(); saveConditionMenuAction = new SaveConditionMenuAction(); zoomInMenuAction = new ZoomInMenuAction(); zoomOutMenuAction = new ZoomOutMenuAction(); resetZoomMenuAction = new ResetZoomMenuAction(); previousTabAction = new PreviousTabAction(); nextTabAction = new NextTabAction(); closeFilterAction = new CloseFilterAction(); closeOtherFiltersAction = new CloseOtherFiltersAction(); closeAllFiltersAction = new CloseAllFiltersAction(); // Window ShowTaskManagerAction showTaskManagerAction = new ShowTaskManagerAction(); closeAllAction = new CloseAllAction(); closeOtherAction = new CloseOtherAction(); minimizeAllAction = new MinimizeAllAction(); minimizeAllOtherAction = new MinimizeAllOtherAction(); removeInactiveAction = new RemoveInactiveAction(); //clearAndRemoveInactiveAction=new ClearAndRemoveInactiveAction(); // Help KeyboardHelpAction keyboardHelpAction = new KeyboardHelpAction(); ShowLoveMenuAction showLoveMenuAction = new ShowLoveMenuAction(); TipOfTheDayAction tipOfTheDayAction = new TipOfTheDayAction(); DebugAction debugAction = new DebugAction(); aboutAction = new AboutAction(); CheckForUpdateAction checkForUpdateAction = new CheckForUpdateAction(); TroubleshootingAction troubleshootingAction = new TroubleshootingAction(); // ##### ToolBar Actions ##### scrollToBottomToolBarAction = new ScrollToBottomToolBarAction(); pauseToolBarAction = new PauseToolBarAction(); clearToolBarAction = new ClearToolBarAction(); findToolBarAction = new FindToolBarAction(); //statisticsToolBarAction = new StatisticsToolBarAction(); attachToolBarAction = new AttachToolBarAction(); disconnectToolBarAction = new DisconnectToolBarAction(); showTaskManagerItem = new JMenuItem(showTaskManagerAction); closeAllItem = new JMenuItem(closeAllAction); closeAllOtherItem = new JMenuItem(closeOtherAction); minimizeAllItem = new JMenuItem(minimizeAllAction); minimizeAllOtherItem = new JMenuItem(minimizeAllOtherAction); removeInactiveItem = new JMenuItem(removeInactiveAction); //clearAndRemoveInactiveItem = new JMenuItem(clearAndRemoveInactiveAction); toolbar = new JToolBar(SwingConstants.HORIZONTAL); toolbar.setFloatable(false); scrollToBottomButton = new JToggleButton(scrollToBottomToolBarAction); toolbar.add(scrollToBottomButton); JButton pauseButton = new JButton(pauseToolBarAction); toolbar.add(pauseButton); JButton clearButton = new JButton(clearToolBarAction); toolbar.add(clearButton); JButton findButton = new JButton(findToolBarAction); toolbar.add(findButton); JButton disconnectButton = new JButton(disconnectToolBarAction); toolbar.add(disconnectButton); toolbar.addSeparator(); //JButton statisticsButton = new JButton(statisticsToolBarAction); //toolbar.add(statisticsButton); //toolbar.addSeparator(); JButton attachButton = new JButton(attachToolBarAction); toolbar.add(attachButton); toolbar.addSeparator(); PreferencesToolBarAction preferencesToolBarAction = new PreferencesToolBarAction(); JButton preferencesButton = new JButton(preferencesToolBarAction); toolbar.add(preferencesButton); toolbar.addSeparator(); ShowLoveToolbarAction showLoveToolbarAction = new ShowLoveToolbarAction(); JButton showLoveButton = new JButton(showLoveToolbarAction); toolbar.add(showLoveButton); recentFilesMenu = new JMenu("Recent Files"); Application app = mainFrame.getApplication(); menubar = new JMenuBar(); // File JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('f'); fileMenu.add(openMenuAction); fileMenu.add(recentFilesMenu); fileMenu.add(openInactiveLogMenuAction); fileMenu.add(cleanAllInactiveLogsMenuAction); fileMenu.add(importMenuAction); fileMenu.add(exportMenuAction); if (!app.isMac()) { fileMenu.addSeparator(); fileMenu.add(preferencesMenuAction); fileMenu.addSeparator(); fileMenu.add(exitMenuAction); } // Edit editMenu = new JMenu("Edit"); editMenu.setMnemonic('e'); editMenu.add(copySelectionAction); editMenu.addSeparator(); editMenu.add(copyEventAction); editMenu.addSeparator(); for (CopyToClipboardAction current : copyLoggingActions) { editMenu.add(current); } editMenu.addSeparator(); for (CopyToClipboardAction current : copyAccessActions) { editMenu.add(current); } editMenu.addSeparator(); customCopyMenu = new JMenu("Custom copy"); customCopyPopupMenu = new JMenu("Custom copy"); editMenu.add(customCopyMenu); editMenu.addSeparator(); PasteStackTraceElementAction pasteStackTraceElementAction = new PasteStackTraceElementAction(); editMenu.add(pasteStackTraceElementAction); // Search searchMenu = new JMenu("Search"); searchMenu.setMnemonic('s'); searchMenu.add(findMenuAction); searchMenu.add(resetFindAction); searchMenu.add(findPreviousAction); searchMenu.add(findNextAction); searchMenu.add(findPreviousActiveAction); searchMenu.add(findNextActiveAction); searchMenu.addSeparator(); searchMenu.add(saveConditionMenuAction); searchMenu.addSeparator(); focusMenu = new FocusMenu(mainFrame.getApplicationPreferences()); excludeMenu = new ExcludeMenu(mainFrame.getApplicationPreferences()); searchMenu.add(focusMenu); searchMenu.add(excludeMenu); // View viewMenu = new JMenu("View"); viewMenu.setMnemonic('v'); viewMenu.add(scrollToBottomMenuAction); viewMenu.add(pauseMenuAction); viewMenu.add(clearMenuAction); viewMenu.add(attachMenuAction); viewMenu.add(disconnectMenuAction); viewMenu.add(focusEventsAction); viewMenu.add(focusMessageAction); //viewMenu.add(statisticsMenuAction); viewMenu.add(editSourceNameMenuAction); viewMenu.addSeparator(); viewMenu.add(zoomInMenuAction); viewMenu.add(zoomOutMenuAction); viewMenu.add(resetZoomMenuAction); viewMenu.addSeparator(); JMenu layoutMenu = new JMenu("Layout"); columnsMenu = new JMenu("Columns"); layoutMenu.add(columnsMenu); layoutMenu.addSeparator(); layoutMenu.add(saveLayoutAction); layoutMenu.add(resetLayoutAction); viewMenu.add(layoutMenu); viewMenu.addSeparator(); viewMenu.add(previousTabAction); viewMenu.add(nextTabAction); viewMenu.addSeparator(); viewMenu.add(closeFilterAction); viewMenu.add(closeOtherFiltersAction); viewMenu.add(closeAllFiltersAction); // Window windowMenu = new JMenu("Window"); windowMenu.setMnemonic('w'); // Help JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('h'); helpMenu.add(keyboardHelpAction); helpMenu.add(showLoveMenuAction); helpMenu.add(tipOfTheDayAction); helpMenu.add(checkForUpdateAction); helpMenu.add(troubleshootingAction); helpMenu.addSeparator(); helpMenu.add(debugAction); if (!app.isMac()) { helpMenu.addSeparator(); helpMenu.add(aboutAction); } menubar.add(fileMenu); menubar.add(editMenu); menubar.add(searchMenu); menubar.add(viewMenu); menubar.add(windowMenu); menubar.add(helpMenu); updateWindowMenu(); updateRecentFiles(); updateActions(); }
From source file:corelyzer.ui.CorelyzerApp.java
private void setupMenuStuff() { menuBar = new JMenuBar(); // Create File Menu JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); JMenuItem createSessionMenuItem = new JMenuItem("Create a Session", KeyEvent.VK_N); createSessionMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, MENU_MASK)); createSessionMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.createSession();/* ww w . j a va 2s . c om*/ } }); createSessionMenuItem.setEnabled(true); fileMenu.add(createSessionMenuItem); createTrackMenuItem = new JMenuItem("Create a Track", KeyEvent.VK_T); createTrackMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, MENU_MASK)); createTrackMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.createTrack(); } }); createTrackMenuItem.setEnabled(false); fileMenu.add(createTrackMenuItem); fileMenu.addSeparator(); // Images JMenu loadImageMenu = new JMenu("Load Images"); loadImageMenuItem = new JMenuItem("Open Local Image Files...", KeyEvent.VK_M); loadImageMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, MENU_MASK)); loadImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.loadImageAction(); } }); loadImageMenu.add(loadImageMenuItem); // "Auto-load" 4/25/2012 brg JMenuItem autoLoadImageMenuItem = new JMenuItem("Open Image Listing..."); autoLoadImageMenuItem.setEnabled(true); autoLoadImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.loadImageListingAction(); } }); loadImageMenu.add(autoLoadImageMenuItem); // online image services JMenuItem chronosMenuItem = new JMenuItem("Online Image Services..."); loadImageMenu.add(chronosMenuItem); chronosMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisibleTab(1); d.setVisible(true); } }); fileMenu.add(loadImageMenu); // Numbercal data (plots) JMenu loadDataMenu = new JMenu("Load Data"); loadDataMenuItem = new JMenuItem("Open Local Dataset Files", KeyEvent.VK_D); loadDataMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, MENU_MASK)); loadDataMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { Runnable r = new Runnable() { public void run() { controller.loadData(); } }; new Thread(r).start(); } }); loadDataMenu.add(loadDataMenuItem); fileMenu.add(loadDataMenu); JMenuItem quickDataImportMenuItem = new JMenuItem("Quick Data Import..."); quickDataImportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.quickDataImport(); } }); loadDataMenu.add(quickDataImportMenuItem); JMenuItem importDataMenuItem = new JMenuItem("Custom Data Import..."); importDataMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.importData(); } }); loadDataMenu.add(importDataMenuItem); // LoggingDB JMenuItem loggingDBMenuItem = new JMenuItem("LDEO logging DB..."); loggingDBMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisibleTab(2); d.setVisible(true); } }); loadDataMenu.add(loggingDBMenuItem); fileMenu.addSeparator(); loadStateFileMenuItem = new JMenuItem("Open a Session File", KeyEvent.VK_O); loadStateFileMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MENU_MASK)); loadStateFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.loadStateFile(); } }); loadStateFileMenuItem.setEnabled(false); fileMenu.add(loadStateFileMenuItem); JMenuItem saveMenuItem = new JMenuItem("Save Session", KeyEvent.VK_S); saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_MASK)); saveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { controller.saveCurrentSession(); } }); fileMenu.add(saveMenuItem); JMenuItem saveStateToFileMenuItem = new JMenuItem("Save Session As...", KeyEvent.VK_S); saveStateToFileMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, MENU_MASK)); saveStateToFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.saveStateToFile(); } }); fileMenu.add(saveStateToFileMenuItem); // Session History recentSessionsMenu = new JMenu("Recent Sessions"); controller.refreshSessionHistoryMenu(); fileMenu.add(recentSessionsMenu); fileMenu.addSeparator(); JMenu packageMenu = new JMenu("Core Archive"); JMenuItem importMenuItem = new JMenuItem("Import..."); importMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.importPackage(); } }); packageMenu.add(importMenuItem); JMenuItem exportMenuItem = new JMenuItem("Export..."); exportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.exportTheWholeScene(); } }); packageMenu.add(exportMenuItem); fileMenu.add(packageMenu); JMenu limsMenu = new JMenu("IODP"); JMenuItem allIODPLists = new JMenuItem("All IODP lists..."); allIODPLists.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisible(true); } }); limsMenu.add(allIODPLists); JMenuItem loadLIMSTables = new JMenuItem("Load a section list..."); loadLIMSTables.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.loadLIMSTables(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisibleTab(0); d.setVisible(true); } }); limsMenu.add(loadLIMSTables); JMenuItem loadAffineTable = new JMenuItem("Load an affine table..."); loadAffineTable.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.loadAAffineTable(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisibleTab(3); d.setVisible(true); } }); limsMenu.add(loadAffineTable); JMenuItem loadSpliceTable = new JMenuItem("Load a splice table..."); loadSpliceTable.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.loadASpliceTable(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisibleTab(4); d.setVisible(true); } }); limsMenu.add(loadSpliceTable); fileMenu.add(limsMenu); JMenu disMenu = new JMenu("DIS"); JMenuItem disListMenuItem = new JMenuItem("Accessing DIS..."); disListMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { DISListsDialog d = new DISListsDialog(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisible(true); } }); JMenuItem disImport = new JMenuItem("Import..."); disImport.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.disImport(); } }); JMenuItem disExport = new JMenuItem("Export..."); disExport.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.disExport(); } }); JMenuItem disBatchDataLoad = new JMenuItem("Load Tab Delimited Data File..."); disBatchDataLoad.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.disBatchDataLoad(); } }); disMenu.add(disListMenuItem); disMenu.add(disImport); disMenu.add(disExport); disMenu.add(disBatchDataLoad); fileMenu.add(disMenu); JMenuItem saveOutputToFileMenuItem = new JMenuItem("Export Sheets...", KeyEvent.VK_A); saveOutputToFileMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.saveOutputToFile(); } }); fileMenu.add(saveOutputToFileMenuItem); fileMenu.addSeparator(); JMenuItem quitMenuItem = new JMenuItem("Quit"); fileMenu.add(quitMenuItem); quitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, MENU_MASK)); quitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.quit(); } }); menuBar.add(fileMenu); // Create Edit Menu JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); JMenuItem clearImageCacheMenuItem = new JMenuItem("Clear Image Cache...", KeyEvent.VK_I); clearImageCacheMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.clearImageCache(); } }); editMenu.add(clearImageCacheMenuItem); editMenu.addSeparator(); JMenuItem depthDirection = new JMenuItem("Switch Depth Direction", KeyEvent.VK_K); depthDirection.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, MENU_MASK)); depthDirection.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { boolean b = SceneGraph.getDepthOrientation(); SceneGraph.setDepthOrientation(!b); CorelyzerApp.getApp().updateGLWindows(); } }); editMenu.add(depthDirection); JMenuItem tour = new JMenuItem("Tour..."); tour.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { CRNavigationSetupDialog dlg = new CRNavigationSetupDialog(); dlg.pack(); dlg.setLocationRelativeTo(getApp().getMainFrame()); dlg.setAlwaysOnTop(true); dlg.setVisible(true); } }); editMenu.add(tour); editMenu.addSeparator(); JMenuItem preferencesMenuItem = new JMenuItem("Preferences..."); editMenu.add(preferencesMenuItem); preferencesMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.doPreferences(); } }); menuBar.add(editMenu); // Create Share Menu JMenu shareMenu = new JMenu("Share"); JMenuItem publishMenuItem = new JMenuItem("Publish..."); publishMenuItem.setEnabled(true); publishMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { controller.publishASession(); } }); shareMenu.add(publishMenuItem); JMenuItem listMenuItem = new JMenuItem("List..."); listMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { controller.listSessions(); } }); shareMenu.add(listMenuItem); shareMenu.addSeparator(); friendsMenu = new JMenu("Friends"); shareMenu.add(friendsMenu); menuBar.add(shareMenu); // Create Debug Menu JMenu debugMenu = new JMenu("Debug"); debugMenu.setMnemonic(KeyEvent.VK_D); JMenuItem matchTestMenuItem = new JMenuItem("Match-Test", KeyEvent.VK_B); matchTestMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.testAndMatch(); } }); debugMenu.add(matchTestMenuItem); if ((System.getenv("DEBUG") != null) && System.getenv("DEBUG").equals("YES")) { menuBar.add(shareMenu); } // Create the Plugin Menu pluginMenu = new JMenu("Plugins"); menuBar.add(pluginMenu); pluginMenuItemVec = new Vector<JMenuItem>(); // Lists JMenu listsMenu = new JMenu("Lists"); JMenuItem iodpLists = new JMenuItem("IODP lists..."); iodpLists.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { IODPListsDialog d = new IODPListsDialog(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisible(true); } }); listsMenu.add(iodpLists); JMenuItem disLists = new JMenuItem("DIS lists..."); disLists.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { DISListsDialog d = new DISListsDialog(getMainFrame()); d.pack(); d.setSize(800, 600); d.setLocationRelativeTo(getMainFrame()); d.setVisible(true); } }); listsMenu.add(disLists); JMenu annotLists = new JMenu("Annotation"); JMenuItem freeformsItem = new JMenuItem("Default"); freeformsItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { FreeformAnnotationListDialog dlg = new FreeformAnnotationListDialog(getApp().getMainFrame()); dlg.pack(); dlg.setLocationRelativeTo(getApp().getMainFrame()); dlg.onRefresh(); dlg.setAlwaysOnTop(true); dlg.setVisible(true); } }); annotLists.add(freeformsItem); JMenuItem clastListItem = new JMenuItem("Clast"); clastListItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { ClastStatisticsDialog dlg = new ClastStatisticsDialog(getApp().getMainFrame()); dlg.pack(); dlg.setLocationRelativeTo(getApp().getMainFrame()); dlg.onRefresh(); dlg.setAlwaysOnTop(true); dlg.setVisible(true); } }); annotLists.add(clastListItem); JMenuItem sampleReqsItem = new JMenuItem("Sample"); sampleReqsItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { SampleRequestListDialog dlg = new SampleRequestListDialog(getApp().getMainFrame()); dlg.pack(); dlg.setLocationRelativeTo(getApp().getMainFrame()); dlg.onRefresh(); dlg.setAlwaysOnTop(true); dlg.setVisible(true); } }); annotLists.add(sampleReqsItem); listsMenu.add(annotLists); menuBar.add(listsMenu); // Create Tools Menu JMenu toolsMenu = new JMenu("Tools"); JMenuItem wholeCoreViewerMenuItem = new JMenuItem("Get 3D Whole Core Imagery Viewer..."); wholeCoreViewerMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { try { String app; String url = "http://www.evl.uic.edu/cavern/corewall/SciVizCore/"; if (System.getProperty("os.name").toLowerCase().contains("windows")) { app = "cmd.exe /c explorer " + url; Runtime.getRuntime().exec(app); } else { app = "open"; String[] cmd = { app, url }; Runtime.getRuntime().exec(cmd); } } catch (IOException ex) { System.err.println("IOException in opening SciVizCore link"); } } }); toolsMenu.add(wholeCoreViewerMenuItem); // DEBUG String debug = System.getProperty("DEBUG"); if ((debug != null) && System.getProperty("DEBUG").equals("true")) { JMenuItem gcItem = new JMenuItem("GC"); gcItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { long mem0 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); System.out.println("- B4 mem:\t" + mem0 / 1000000.0f); int trials = 10000; for (int i = 0; i < trials; i++) { updateGLWindows(); } long mem1 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); System.out.println("- " + trials + " mem:\t" + mem1 / 1000000.0f); System.gc(); System.gc(); System.gc(); long mem2 = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); System.out.println("- AferGC mem:\t" + mem2 / 1000000.0f); } }); toolsMenu.add(gcItem); } menuBar.add(toolsMenu); // Create Help Menu // Create JavaHelp hooks File helpSet = new File("help/jhelpset.hs"); HelpSet hs = null; try { URL hsURL = helpSet.toURI().toURL(); hs = new HelpSet(null, hsURL); } catch (HelpSetException e) { JOptionPane.showMessageDialog(getMainFrame(), "Cannot find help: format error."); e.printStackTrace(); } catch (MalformedURLException e) { JOptionPane.showMessageDialog(getMainFrame(), "Cannot find help: malformed URL."); e.printStackTrace(); } // Help UI JMenu helpMenu = new JMenu("Help"); JMenuItem helpMenuItem = new JMenuItem("Help", KeyEvent.VK_H); if (hs != null) { HelpBroker hb = hs.createHelpBroker(); helpActionListener = new CSH.DisplayHelpFromSource(hb); helpMenuItem.addActionListener(helpActionListener); } else { helpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.helpAction(); } }); } helpMenu.add(helpMenuItem); helpMenu.addSeparator(); JMenuItem aboutMenuItem = new JMenuItem("About Corelyzer"); helpMenu.add(aboutMenuItem); aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent event) { controller.about(); } }); menuBar.add(helpMenu); mainFrame.setJMenuBar(menuBar); }