List of usage examples for javax.swing JMenuItem addActionListener
public void addActionListener(ActionListener l)
ActionListener
to the button. From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Creates a popup menu for the panel.// www .j a v a2 s . co m * * @param properties * include a menu item for the chart property editor. * @param save * include a menu item for saving the chart. * @param print * include a menu item for printing the chart. * @param zoom * include menu items for zooming. * @return The popup menu. */ protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) { JPopupMenu result = new JPopupMenu("Chart:"); boolean separator = false; if (properties) { JMenuItem propertiesItem = new JMenuItem(localizationResources.getString("Properties...")); propertiesItem.setActionCommand(PROPERTIES_COMMAND); propertiesItem.addActionListener(this); result.add(propertiesItem); separator = true; } if (save) { if (separator) { result.addSeparator(); separator = false; } JMenuItem saveItem = new JMenuItem(localizationResources.getString("Save_as...")); saveItem.setActionCommand(SAVE_COMMAND); saveItem.addActionListener(this); result.add(saveItem); separator = true; } if (print) { if (separator) { result.addSeparator(); separator = false; } JMenuItem printItem = new JMenuItem(localizationResources.getString("Print...")); printItem.setActionCommand(PRINT_COMMAND); printItem.addActionListener(this); result.add(printItem); separator = true; } if (zoom) { if (separator) { result.addSeparator(); separator = false; } JMenu zoomInMenu = new JMenu(localizationResources.getString("Zoom_In")); this.zoomInBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); this.zoomInBothMenuItem.setActionCommand(ZOOM_IN_BOTH_COMMAND); this.zoomInBothMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInBothMenuItem); zoomInMenu.addSeparator(); this.zoomInDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis")); this.zoomInDomainMenuItem.setActionCommand(ZOOM_IN_DOMAIN_COMMAND); this.zoomInDomainMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInDomainMenuItem); this.zoomInRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis")); this.zoomInRangeMenuItem.setActionCommand(ZOOM_IN_RANGE_COMMAND); this.zoomInRangeMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInRangeMenuItem); result.add(zoomInMenu); JMenu zoomOutMenu = new JMenu(localizationResources.getString("Zoom_Out")); this.zoomOutBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); this.zoomOutBothMenuItem.setActionCommand(ZOOM_OUT_BOTH_COMMAND); this.zoomOutBothMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutBothMenuItem); zoomOutMenu.addSeparator(); this.zoomOutDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis")); this.zoomOutDomainMenuItem.setActionCommand(ZOOM_OUT_DOMAIN_COMMAND); this.zoomOutDomainMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutDomainMenuItem); this.zoomOutRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis")); this.zoomOutRangeMenuItem.setActionCommand(ZOOM_OUT_RANGE_COMMAND); this.zoomOutRangeMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutRangeMenuItem); result.add(zoomOutMenu); JMenu autoRangeMenu = new JMenu(localizationResources.getString("Auto_Range")); this.zoomResetBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); this.zoomResetBothMenuItem.setActionCommand(ZOOM_RESET_BOTH_COMMAND); this.zoomResetBothMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetBothMenuItem); autoRangeMenu.addSeparator(); this.zoomResetDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis")); this.zoomResetDomainMenuItem.setActionCommand(ZOOM_RESET_DOMAIN_COMMAND); this.zoomResetDomainMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetDomainMenuItem); this.zoomResetRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis")); this.zoomResetRangeMenuItem.setActionCommand(ZOOM_RESET_RANGE_COMMAND); this.zoomResetRangeMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetRangeMenuItem); result.addSeparator(); result.add(autoRangeMenu); } return result; }
From source file:de.dmarcini.submatix.pclogger.gui.MainCommGUI.java
/** * verfgbare Sprachen in Men eintragen Project: SubmatixBTConfigPC Package: de.dmarcini.submatix.pclogger.gui * // ww w . jav a 2s .c om * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 18.12.2011 * @param programLocale */ private void initLanuageMenu(Locale programLocale) { ResourceBundle rb; Enumeration<String> enu; String key = null; String cmd = null; try { lg.debug("try init language menu..."); ignoreAction = true; // Lies die Resource aus rb = ResourceBundle.getBundle("de.dmarcini.submatix.pclogger.lang.languages"); // Alle KEYS lesen enu = rb.getKeys(); try { lg.debug("try init language menuitems..."); while (enu.hasMoreElements()) { JMenuItem menuItem = new JMenuItem(); key = enu.nextElement(); cmd = rb.getString(key); menuItem.setText(key); menuItem.addActionListener(this); menuItem.setActionCommand(cmd); menuItem.addMouseMotionListener(this); mnLanguages.add(menuItem); } lg.debug("try init language menuitems...done"); } catch (NullPointerException ex) { lg.error("NULL POINTER EXCEPTION <" + ex.getMessage() + ">"); statusTextField.setText("ERROR set language strings"); System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!"); System.exit(-1); } catch (MissingResourceException ex) { lg.error("MISSING RESOURCE EXCEPTION <" + ex.getMessage() + ">"); statusTextField.setText("ERROR set language strings"); System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!"); System.exit(-1); } catch (ClassCastException ex) { lg.error("CLASS CAST EXCEPTION <" + ex.getMessage() + ">"); statusTextField.setText("ERROR set language strings"); System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!"); System.exit(-1); } finally { ignoreAction = false; } } catch (NullPointerException ex) { lg.error("NULL POINTER EXCEPTION <" + ex.getMessage() + ">"); statusTextField.setText("ERROR set language strings"); System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!"); System.exit(-1); } catch (MissingResourceException ex) { lg.error("MISSING RESOURCE EXCEPTION <" + ex.getMessage() + ">"); statusTextField.setText("ERROR set language strings - the given key can be found"); System.out.println( "ERROR set language strings - the given key can be found <" + ex.getMessage() + "> ABORT!"); System.exit(-1); } catch (ClassCastException ex) { lg.error("CLASS CAST EXCEPTION <" + ex.getMessage() + ">"); statusTextField.setText("ERROR set language strings"); System.out.println("ERROR set language strings <" + ex.getMessage() + "> ABORT!"); System.exit(-1); } finally { ignoreAction = false; } lg.debug("try init language menu...done"); }
From source file:search2go.UIFrame.java
public UIFrame() throws IOException, ParseException { topLevels = new TopLevelGTermSet[] { CCs, MFs, BPs }; this.addWindowListener(new WindowAdapter() { @Override/*from www .j ava 2s .c o m*/ public void windowClosing(WindowEvent et) { try { if (os.isWindows()) { Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F"); Runtime.getRuntime().exec("cmd /C TaskKill -IM python.exe -F"); } else { Runtime.getRuntime().exec("killAll -KILL blastx"); Runtime.getRuntime().exec("killAll -KILL blastn"); Runtime.getRuntime().exec("killAll -KILL blastp"); Runtime.getRuntime().exec("killAll -KILL python"); } } catch (IOException ex) { System.out.println("Error closing child processes"); } } }); initComponents(); txtBlastOutput.getDocument().addDocumentListener(new BufferEnforcer(txtBlastOutput)); txtFullOutput.getDocument().addDocumentListener(new BufferEnforcer(txtFullOutput)); txtMapOutput.getDocument().addDocumentListener(new BufferEnforcer(txtMapOutput)); ((DefaultCaret) txtBlastOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtMapOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); ((DefaultCaret) txtFullOutput.getCaret()).setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); webSaveMenu = new JPopupMenu(); JMenuItem saveWeb = new JMenuItem(); saveWeb.setText("Save"); saveWeb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { webSaveDialogue.showSaveDialog(pnlChartHolder); File saveFile = webSaveDialogue.getSelectedFile(); if (!saveFile.getPath().contains(".png")) saveFile = new File(saveFile.getPath() + ".png"); try { BufferedImage webChartImage = new BufferedImage(pnlChartHolder.getWidth(), pnlChartHolder.getHeight(), BufferedImage.TYPE_INT_RGB); pnlChartHolder.print(webChartImage.getGraphics()); ImageIO.write(webChartImage, "png", saveFile); } catch (Exception ex) { javax.swing.JOptionPane.showMessageDialog(pnlChartHolder, "Error saving chart. Please try again."); } } }); webSaveMenu.add(saveWeb); pnlChartHolder.add(webSaveMenu); pnlChartHolder.setLayout(new java.awt.BorderLayout()); try { currentProj = Workspace.open(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); txtQuery.setText(currentProj.getQueryPath()); txtQueryFP.setText(currentProj.getQueryPath()); txtDatabase.setText(currentProj.getPathToDB()); txtDatabaseFP.setText(currentProj.getPathToDB()); txtThreads.setValue(currentProj.getThreadNo()); txtThreadsFP.setValue(currentProj.getThreadNo()); cbxNXP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxNXPFP.setSelectedIndex(currentProj.getBlastTypeIndex()); cbxDBID.setSelectedIndex(currentProj.getSelectedDBIndex()); cbxDBIDFP.setSelectedIndex(currentProj.getSelectedDBIndex()); txtBitScore.setValue(currentProj.getBitScoreThreshold()); txtBitScoreFP.setValue(currentProj.getBitScoreThreshold()); txtBlastE.setValue(currentProj.getEThreshold()); txtMapE.setValue(currentProj.getEThreshold()); txtEFP.setValue(currentProj.getEThreshold()); } catch (FileNotFoundException e) { currentProj = Workspace.create(new Path("Search2GO_Data")); chkDoCCs.setState(currentProj.willDoCC()); chkDoBPs.setState(currentProj.willDoBP()); chkDoMFs.setState(currentProj.willDoMF()); } this.setTitle("Search2GO " + currentProj.getPath().toString()); GTermTableModel = new DefaultTableModel(); GTermTableModel.setColumnCount(2); GTermTableModel.setColumnIdentifiers(new String[] { "GO ID", "Frequency" }); ListSelectionModel GTermSelector = tblGOFreq.getSelectionModel(); GTermSelector.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { if (tblGOFreq.getSelectedRow() > -1) { DefaultListModel emptyModel = new DefaultListModel(); lstQueries.setModel(emptyModel); txtTermInfo.setText(""); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); JTextArea tempHolderInfo = new JTextArea(); JTextArea tempHolderQueries = new JTextArea(); if (tblGOFreq.getSelectedRow() != -1) { ResetGTermInfoGetter(tempHolderInfo, tempHolderQueries); gTermInfoGetter.getProcess(0).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("id", selectedID.substring(0, selectedID.indexOf("["))); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); gTermInfoGetter.getProcess(1).addParameter("db", currentGTerm.getTopLevel().getCode()); gTermInfoGetter.setTail(new ProcessSequenceEnd() { @Override public void run() { tempHolderInfo.setText("id: " + selectedID + "\n" + tempHolderInfo.getText()); txtTermInfo.setText(tempHolderInfo.getText()); DefaultListModel queryList = new DefaultListModel(); for (String str : tempHolderQueries.getText().split(";")) { queryList.addElement(str.replaceAll("Query: ", "")); } lstQueries.setModel(queryList); prgIdentification.setIndeterminate(false); } }); try { gTermInfoGetter.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } } } }); lstQueries.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting() && !e.toString().contains("invalid") && lstQueries.getSelectedValue() != null) { JTextArea tempHolder = new JTextArea(); ProcessSequence fetchLocusSequence = new ProcessSequence(new ProcessSequenceEnd() { @Override public void run() { if (txtTermInfo.getText().contains("Score")) { txtTermInfo.setText( txtTermInfo.getText().substring(0, txtTermInfo.getText().indexOf("Score"))); } txtTermInfo.append(tempHolder.getText()); prgIdentification.setIndeterminate(false); } }); Path fetchLocusPath = new Path("Processes"); fetchLocusPath.append("fetchLocus.py"); Process fetchLocus = new Process(tempHolder); fetchLocus.setScriptCommand(fetchLocusPath.toEscString()); fetchLocus.addParameter("dir", currentProj.getPath().toEscString()); fetchLocus.addParameter("q", new ParameterString(lstQueries.getSelectedValue().replace("\n", "")).toString()); String selectedID = (String) tblGOFreq.getValueAt(tblGOFreq.getSelectedRow(), 0); GTerm currentGTerm = gTerms.getGTerm(selectedID.substring(0, selectedID.indexOf("["))); fetchLocus.addParameter("db", currentGTerm.getTopLevel().getCode()); fetchLocus.addParameter("id", currentGTerm.getID()); fetchLocusSequence.addProcess(fetchLocus); try { fetchLocusSequence.start(); prgIdentification.setIndeterminate(true); } catch (IOException ex) { Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex); } } } }); DocumentListener filterListener = new DocumentListener() { private void anyUpdate() { gTerms.getFilter().setFilterString(txtSearchTerms.getText()); if (!txtMinFreqFilter.getText().equals("")) gTerms.getFilter().setMinFreq(Integer.parseInt(txtMinFreqFilter.getText())); else gTerms.getFilter().setMinFreq(0); if (!txtMaxFreqFilter.getText().equals("")) gTerms.getFilter().setMaxFreq(Integer.parseInt(txtMaxFreqFilter.getText())); else gTerms.getFilter().setMaxFreq(-1); fillIdentTable(gTerms.stringFilter(), false); } @Override public void insertUpdate(DocumentEvent e) { anyUpdate(); } @Override public void removeUpdate(DocumentEvent e) { anyUpdate(); } @Override public void changedUpdate(DocumentEvent e) { anyUpdate(); } }; txtSearchTerms.getDocument().addDocumentListener(filterListener); txtMinFreqFilter.getDocument().addDocumentListener(filterListener); txtMaxFreqFilter.getDocument().addDocumentListener(filterListener); NumberFormat numberMask = NumberFormat.getIntegerInstance(); numberMask.setGroupingUsed(false); NumberFormatter numberMasker = new NumberFormatter(numberMask); NumberFormatter numberMaskerAndBlank = new NumberFormatter(numberMask) { @Override public Object stringToValue(String s) throws ParseException { if (s == null || s.length() == 0) return null; return super.stringToValue(s); } }; DefaultFormatterFactory numberMaskFactory = new DefaultFormatterFactory(numberMasker); DefaultFormatterFactory numberMaskAndBlankFactory = new DefaultFormatterFactory(numberMaskerAndBlank); txtThreads.setFormatterFactory(numberMaskFactory); txtThreadsFP.setFormatterFactory(numberMaskFactory); txtBitScore.setFormatterFactory(numberMaskAndBlankFactory); txtBitScoreFP.setFormatterFactory(numberMaskAndBlankFactory); txtMinFreqFilter.setFormatterFactory(numberMaskFactory); txtMaxFreqFilter.setFormatterFactory(numberMaskFactory); txtBlastE.setFormatterFactory(numberMaskAndBlankFactory); txtMapE.setFormatterFactory(numberMaskAndBlankFactory); txtEFP.setFormatterFactory(numberMaskAndBlankFactory); blastButton = new StopButton(btnBlast); mapButton = new StopButton(btnMapIDs); identButton = new StopButton(btnGTermIdent); fullButton = new StopButton(btnProcessFP); if (currentProj.getStage() >= 2) identify(false); }
From source file:com.declarativa.interprolog.gui.ListenerWindow.java
protected void addToHistory() { JMenuItem item; String goal = prologInput.getText(); if (goal.equals(";")) { return; // not worthy remembering }// www .j av a2 s . com if (goal.length() > 20) { historyMenu.add(item = new JMenuItem(goal.substring(0, 19) + "...")); } else { historyMenu.add(item = new JMenuItem(goal.substring(0, goal.length()))); } item.addActionListener(new HistoryListener(prologInput, goal)); }
From source file:org.rdv.viz.chart.ChartPanel.java
/** * Creates a popup menu for the panel./*from w ww .j a v a 2 s . com*/ * * @param properties include a menu item for the chart property editor. * @param save include a menu item for saving the chart. * @param print include a menu item for printing the chart. * @param zoom include menu items for zooming. * * @return The popup menu. */ protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) { JPopupMenu result = new JPopupMenu("Chart:"); boolean separator = false; if (properties) { JMenuItem propertiesItem = new JMenuItem(localizationResources.getString("Properties...")); propertiesItem.setActionCommand(PROPERTIES_COMMAND); propertiesItem.addActionListener(this); result.add(propertiesItem); separator = true; } if (save) { if (separator) { result.addSeparator(); separator = false; } JMenuItem saveItem = new JMenuItem(localizationResources.getString("Save_as...")); saveItem.setActionCommand(SAVE_COMMAND); saveItem.addActionListener(this); result.add(saveItem); separator = true; } if (print) { if (separator) { result.addSeparator(); separator = false; } JMenuItem printItem = new JMenuItem(localizationResources.getString("Print...")); printItem.setActionCommand(PRINT_COMMAND); printItem.addActionListener(this); result.add(printItem); separator = true; } if (zoom) { if (separator) { result.addSeparator(); separator = false; } JMenu zoomInMenu = new JMenu(localizationResources.getString("Zoom_In")); this.zoomInBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); this.zoomInBothMenuItem.setActionCommand(ZOOM_IN_BOTH_COMMAND); this.zoomInBothMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInBothMenuItem); zoomInMenu.addSeparator(); this.zoomInDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis")); this.zoomInDomainMenuItem.setActionCommand(ZOOM_IN_DOMAIN_COMMAND); this.zoomInDomainMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInDomainMenuItem); this.zoomInRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis")); this.zoomInRangeMenuItem.setActionCommand(ZOOM_IN_RANGE_COMMAND); this.zoomInRangeMenuItem.addActionListener(this); zoomInMenu.add(this.zoomInRangeMenuItem); result.add(zoomInMenu); JMenu zoomOutMenu = new JMenu(localizationResources.getString("Zoom_Out")); this.zoomOutBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); this.zoomOutBothMenuItem.setActionCommand(ZOOM_OUT_BOTH_COMMAND); this.zoomOutBothMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutBothMenuItem); zoomOutMenu.addSeparator(); this.zoomOutDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis")); this.zoomOutDomainMenuItem.setActionCommand(ZOOM_OUT_DOMAIN_COMMAND); this.zoomOutDomainMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutDomainMenuItem); this.zoomOutRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis")); this.zoomOutRangeMenuItem.setActionCommand(ZOOM_OUT_RANGE_COMMAND); this.zoomOutRangeMenuItem.addActionListener(this); zoomOutMenu.add(this.zoomOutRangeMenuItem); result.add(zoomOutMenu); JMenu autoRangeMenu = new JMenu(localizationResources.getString("Auto_Range")); this.zoomResetBothMenuItem = new JMenuItem(localizationResources.getString("All_Axes")); this.zoomResetBothMenuItem.setActionCommand(ZOOM_RESET_BOTH_COMMAND); this.zoomResetBothMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetBothMenuItem); autoRangeMenu.addSeparator(); this.zoomResetDomainMenuItem = new JMenuItem(localizationResources.getString("Domain_Axis")); this.zoomResetDomainMenuItem.setActionCommand(ZOOM_RESET_DOMAIN_COMMAND); this.zoomResetDomainMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetDomainMenuItem); this.zoomResetRangeMenuItem = new JMenuItem(localizationResources.getString("Range_Axis")); this.zoomResetRangeMenuItem.setActionCommand(ZOOM_RESET_RANGE_COMMAND); this.zoomResetRangeMenuItem.addActionListener(this); autoRangeMenu.add(this.zoomResetRangeMenuItem); result.addSeparator(); result.add(autoRangeMenu); } return result; }
From source file:edu.ku.brc.ui.UIHelper.java
/** * Creates a JMenuItem./*from w w w .j a va 2 s.c o m*/ * @param key the label key of the menu item * @param mnemonic the mnemonic * @param accessibleDescription the accessible Description * @param enabled enabled * @param action the aciton * @return menu item */ public static JMenuItem createLocalizedMenuItem(final String key, final String mnemonic, final String accessibleDescription, final boolean enabled, final ActionListener al) { JMenuItem mi = new JMenuItem(getResourceString(key)); if (isNotEmpty(mnemonic)) { String mnu = getResourceString(mnemonic); mi.setMnemonic(mnu.charAt(0)); } if (isNotEmpty(accessibleDescription)) { String desc = getResourceString(accessibleDescription); mi.getAccessibleContext().setAccessibleDescription(desc); } mi.addActionListener(al); mi.setEnabled(enabled); return mi; }
From source file:com.emental.mindraider.ui.frames.MindRaiderMainWindow.java
/** * Build main menu.//from w w w .j a va 2s . 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:fi.hoski.remote.ui.Admin.java
private JMenuItem menuItemEditQuery() { ActionListener queryAction = new ActionListener() { @Override/*from w w w. j a v a 2 s. c om*/ public void actionPerformed(ActionEvent e) { startQuery(true, true); } }; queryAction = createActionListener(frame, queryAction); JMenuItem queryItem = new JMenuItem(); TextUtil.populate(queryItem, "EDIT QUERY"); queryItem.addActionListener(queryAction); return queryItem; }
From source file:fi.hoski.remote.ui.Admin.java
private JMenuItem menuItemQuery() { ActionListener queryAction = new ActionListener() { @Override/*from w ww. j a v a 2s .c o m*/ public void actionPerformed(ActionEvent e) { startQuery(true, false); } }; queryAction = createActionListener(frame, queryAction); JMenuItem queryItem = new JMenuItem(); TextUtil.populate(queryItem, "START QUERY"); queryItem.addActionListener(queryAction); return queryItem; }
From source file:fi.hoski.remote.ui.Admin.java
private JMenuItem menuItemSwapPatrolShift() { ActionListener swapAction = new ActionListener() { @Override//from w ww . j a v a2 s. c om public void actionPerformed(ActionEvent e) { AnyDataObject member = chooseMember(TextUtil.getText("CHOOSE MEMBER")); if (member != null) { swapPatrolShift(member); } else { JOptionPane.showMessageDialog(frame, TextUtil.getText("NO SELECTION"), TextUtil.getText("MESSAGE"), JOptionPane.INFORMATION_MESSAGE); } } }; swapAction = createActionListener(frame, swapAction); JMenuItem swapItem = new JMenuItem(); TextUtil.populate(swapItem, "SWAP PATROL SHIFT"); swapItem.addActionListener(swapAction); return swapItem; }