List of usage examples for javax.swing JCheckBoxMenuItem JCheckBoxMenuItem
public JCheckBoxMenuItem(Action a)
From source file:org.esa.nest.dat.views.polarview.PolarView.java
private JCheckBoxMenuItem createCheckedMenuItem(String name, JMenu parent, boolean state) { final JCheckBoxMenuItem item = new JCheckBoxMenuItem(name); item.setHorizontalTextPosition(JMenuItem.RIGHT); item.addActionListener(this); parent.add(item);//w ww .j a va 2s .c o m return item; }
From source file:org.f2o.absurdum.puck.gui.PuckFrame.java
/** * Instances and shows Puck's main frame. *//*from www . ja v a2 s. c o m*/ public PuckFrame() { super(); setLookAndFeel(PuckConfiguration.getInstance().getProperty("look")); /* LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels(); for ( int i = 0 ; i < lfs.length ; i++ ) { if ( lfs[i].getName().toLowerCase().contains("nimbus") ) { try { UIManager.setLookAndFeel(lfs[i].getClassName()); } catch (Exception e) //class not found, instantiation exception, etc. (shouldn't happen) { e.printStackTrace(); } } } */ setSize(PuckConfiguration.getInstance().getIntegerProperty("windowWidth"), PuckConfiguration.getInstance().getIntegerProperty("windowHeight")); setLocation(PuckConfiguration.getInstance().getIntegerProperty("windowLocationX"), PuckConfiguration.getInstance().getIntegerProperty("windowLocationY")); //setSize(600,600); if (PuckConfiguration.getInstance().getBooleanProperty("windowMaximized")) maximizeIfPossible(); //setTitle(Messages.getInstance().getMessage("frame.title")); refreshTitle(); left = new JPanel(); right = new JPanel(); JScrollPane rightScroll = new JScrollPane(right); rightScroll.getVerticalScrollBar().setUnitIncrement(16); //faster scrollbar (by default it was very slow, maybe because component inside is not text component!) split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, rightScroll) { //dynamic resizing of right panel /* public void setDividerLocation ( int pixels ) { if ( propPanel != null ) { double rightPartSize = getContentPane().getWidth() - pixels - 15; System.out.println("rps=" + rightPartSize); System.out.println("mnw=" + this.getMinimumSize().getWidth()); Dimension propPanSize = propPanel.getSize(); int propPanHeight = 0; if (propPanSize != null) propPanHeight = (int) propPanSize.getHeight(); //propPanel.revalidate(); System.out.println("h " + propPanHeight); //if ( rightPartSize >= propPanel.getMinimumSize().getWidth() ) propPanel.setPreferredSize(new Dimension((int)rightPartSize,propPanHeight)); //propPanel.setMinimumSize(new Dimension((int)rightPartSize,propPanHeight)); //propPanel.setMaximumSize(new Dimension((int)rightPartSize,propPanHeight)); //propPanel.setSize(new Dimension((int)rightPartSize,propPanHeight)); propPanel.revalidate(); } super.setDividerLocation(pixels); } */ }; split.setContinuousLayout(true); split.setResizeWeight(0.60); final int dividerLoc = PuckConfiguration.getInstance().getIntegerProperty("dividerLocation", 0); /* SwingUtilities.invokeLater(new Runnable(){ public void run() { */ /* } }); */ split.setOneTouchExpandable(true); getContentPane().add(split); System.out.println(Toolkit.getDefaultToolkit().getBestCursorSize(20, 20)); //it's 32x32. Will have to do it. //Image img = Toolkit.getDefaultToolkit().createImage( getClass().getResource("addCursor32.png") ); //Image img = Toolkit.getDefaultToolkit().createImage("addCursor32.png"); left.setLayout(new BorderLayout()); //right.setLayout(new BoxLayout(right,BoxLayout.LINE_AXIS)); if (PuckConfiguration.getInstance().getBooleanProperty("dynamicFormResizing")) right.setLayout(new BorderLayout()); else right.setLayout(new FlowLayout()); propPanel = new PropertiesPanel(); right.add(propPanel); graphPanel = new GraphEditingPanel(propPanel); graphPanel.setGrid(Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue()); graphPanel.setSnapToGrid( Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue()); propPanel.setGraphEditingPanel(graphPanel); tools = new PuckToolBar(graphPanel, propPanel, this); left.add(tools, BorderLayout.WEST); left.add(graphPanel, BorderLayout.CENTER); /* Action testAction = new AbstractAction() { public void actionPerformed ( ActionEvent evt ) { System.out.println("Puck!"); } } ; testAction.putValue(Action.NAME,"Print Puck"); tools.add(testAction); */ /* public void saveChanges ( ) { if ( editingFileName == null ) { //save as... code } else { File f = new File(editingFileName); try { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d)); Transformer t = TransformerFactory.newInstance().newTransformer(); Source s = new DOMSource(d); Result r = new StreamResult(f); t.transform(s,r); editingFileName = f.toString(); refreshTitle(); } catch ( Exception e ) { JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } } */ JMenuBar mainMenuBar = new JMenuBar(); JMenu fileMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file")); fileMenu.setMnemonic(KeyEvent.VK_F); saveMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.save")); saveMenuItem.setMnemonic(KeyEvent.VK_S); saveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (editingFileName == null) JOptionPane.showMessageDialog(PuckFrame.this, "File has no name!", "Whoops!", JOptionPane.ERROR_MESSAGE); /* File f = new File(editingFileName); try { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d)); Transformer t = TransformerFactory.newInstance().newTransformer(); Source s = new DOMSource(d); Result r = new StreamResult(f); t.transform(s,r); editingFileName = f.toString(); refreshTitle(); } catch ( Exception e ) { JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } */ try { saveChangesInCurrentFile(); } catch (Exception e) { JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }); JMenu newMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.new")); JMenuItem newBlankMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.new.blank")); //newBlankMenuItem.setMnemonic(KeyEvent.VK_N); newBlankMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { GraphElementPanel.emptyQueue(); //stop deferred loads graphPanel.clear(); propPanel.clear(); JSyntaxBSHCodeFrame.closeAllInstances(); WorldPanel wp = new WorldPanel(graphPanel); WorldNode wn = new WorldNode(wp); graphPanel.setWorldNode(wn); propPanel.show(graphPanel.getWorldNode()); resetCurrentlyEditingFile(); refreshTitle(); //revalidate(); //only since java 1.7 //invalidate(); //validate(); split.revalidate(); //JComponents do have it before java 1.7 (not JFrame) } }); newMenu.add(newBlankMenuItem); JMenu templateMenus = new WorldTemplateMenuBuilder(this).getMenu(); if (templateMenus != null) { for (int i = 0; i < templateMenus.getItemCount(); i++) { if (i == 0) newMenu.add(new JSeparator()); newMenu.add(templateMenus.getItem(i)); } } JMenuItem saveAsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.saveas")); saveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { /* JFileChooser jfc = new JFileChooser("."); int opt = jfc.showSaveDialog(PuckFrame.this); if ( opt == JFileChooser.APPROVE_OPTION ) { File f = jfc.getSelectedFile(); try { Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); d.appendChild(graphPanel.getWorldNode().getAssociatedPanel().getXML(d)); Transformer t = TransformerFactory.newInstance().newTransformer(); Source s = new DOMSource(d); Result r = new StreamResult(f); t.transform(s,r); editingFileName = f.toString(); saveMenuItem.setEnabled(true); refreshTitle(); } catch ( Exception e ) { JOptionPane.showMessageDialog(PuckFrame.this,e,"Whoops!",JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } */ try { saveAs(); saveMenuItem.setEnabled(true); } catch (Exception e) { JOptionPane.showMessageDialog(PuckFrame.this, e.getLocalizedMessage(), "Whoops!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } //saveAs(saveMenuItem); } }); JMenuItem openMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.open")); openMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { //graphPanel.setVisible(false); //propPanel.setVisible(false); JFileChooser jfc = new JFileChooser("."); jfc.setFileFilter(new FiltroFicheroMundo()); int opt = jfc.showOpenDialog(PuckFrame.this); if (opt == JFileChooser.APPROVE_OPTION) { File f = jfc.getSelectedFile(); openFileOrShowError(f); } //graphPanel.setVisible(true); //propPanel.setVisible(true); } }); openRecentMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.recent")); JMenuItem exitMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.file.exit")); exitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { /* int opt = JOptionPane.showConfirmDialog(PuckFrame.this,Messages.getInstance().getMessage("exit.sure.text"),Messages.getInstance().getMessage("exit.sure.title"),JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE); if ( opt == JOptionPane.YES_OPTION ) System.exit(0); */ userExit(); } }); JMenu exportMenu = new JMenu(UIMessages.getInstance().getMessage("menu.file.export")); JMenuItem exportAppletMenuItem = new JMenuItem( UIMessages.getInstance().getMessage("menu.file.export.applet")); exportAppletMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { ExportAppletDialog dial = new ExportAppletDialog(PuckFrame.this); dial.setVisible(true); } }); exportMenu.add(exportAppletMenuItem); fileMenu.add(newMenu); fileMenu.add(openMenuItem); fileMenu.add(openRecentMenu); updateRecentMenu(); fileMenu.add(new JSeparator()); saveMenuItem.setEnabled(false); fileMenu.add(saveMenuItem); fileMenu.add(saveAsMenuItem); fileMenu.add(exportMenu); fileMenu.add(new JSeparator()); fileMenu.add(exitMenuItem); mainMenuBar.add(fileMenu); /** * Create an Edit menu to support cut/copy/paste. */ JMenu editMenu = new JMenu(UIMessages.getInstance().getMessage("menu.edit")); editMenu.setMnemonic(KeyEvent.VK_E); JMenuItem findMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.find.entity")); findMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showFindEntityDialog(); } }); editMenu.add(findMenuItem); editMenu.add(new JSeparator()); JMenuItem aMenuItem = new JMenuItem(new CutAction()); aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.cut")); aMenuItem.setMnemonic(KeyEvent.VK_T); editMenu.add(aMenuItem); aMenuItem = new JMenuItem(new CopyAction()); aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.copy")); aMenuItem.setMnemonic(KeyEvent.VK_C); editMenu.add(aMenuItem); aMenuItem = new JMenuItem(new PasteAction()); aMenuItem.setText(UIMessages.getInstance().getMessage("menuaction.paste")); aMenuItem.setMnemonic(KeyEvent.VK_P); editMenu.add(aMenuItem); mainMenuBar.add(editMenu); JMenu optionsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options")); JMenu gridMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.grid")); optionsMenu.add(gridMenu); final JCheckBoxMenuItem showGridItem = new JCheckBoxMenuItem( UIMessages.getInstance().getMessage("menu.options.grid.show")); showGridItem.setSelected( Boolean.valueOf(PuckConfiguration.getInstance().getProperty("showGrid")).booleanValue()); gridMenu.add(showGridItem); showGridItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { graphPanel.setGrid(true); PuckConfiguration.getInstance().setProperty("showGrid", "true"); } else if (e.getStateChange() == ItemEvent.DESELECTED) { graphPanel.setGrid(false); PuckConfiguration.getInstance().setProperty("showGrid", "false"); } graphPanel.repaint(); } }); final JCheckBoxMenuItem snapToGridItem = new JCheckBoxMenuItem( UIMessages.getInstance().getMessage("menu.options.grid.snap")); snapToGridItem.setSelected( Boolean.valueOf(PuckConfiguration.getInstance().getProperty("snapToGrid")).booleanValue()); gridMenu.add(snapToGridItem); snapToGridItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { graphPanel.setSnapToGrid(true); PuckConfiguration.getInstance().setProperty("snapToGrid", "true"); } else if (e.getStateChange() == ItemEvent.DESELECTED) { graphPanel.setSnapToGrid(false); PuckConfiguration.getInstance().setProperty("snapToGrid", "false"); } graphPanel.repaint(); } }); JMenuItem translationModeMenu = new JMenu(UIMessages.getInstance().getMessage("menu.options.translation")); ButtonGroup translationGroup = new ButtonGroup(); final JRadioButtonMenuItem holdMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.translation.hold")); final JRadioButtonMenuItem pushMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.translation.push")); pushMenuItem.setSelected("push".equals(PuckConfiguration.getInstance().getProperty("translateMode"))); if (!pushMenuItem.isSelected()) holdMenuItem.setSelected(true); translationGroup.add(holdMenuItem); translationGroup.add(pushMenuItem); holdMenuItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { if (holdMenuItem.isSelected()) PuckConfiguration.getInstance().setProperty("translateMode", "hold"); else PuckConfiguration.getInstance().setProperty("translateMode", "push"); } }); translationModeMenu.add(holdMenuItem); translationModeMenu.add(pushMenuItem); optionsMenu.add(translationModeMenu); JMenuItem toolSelectionModeMenu = new JMenu( UIMessages.getInstance().getMessage("menu.options.toolselection")); ButtonGroup toolSelectionGroup = new ButtonGroup(); final JRadioButtonMenuItem oneUseMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.toolselection.oneuse")); final JRadioButtonMenuItem multipleUseMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.options.toolselection.multipleuse")); multipleUseMenuItem.setSelected( "multipleUse".equalsIgnoreCase(PuckConfiguration.getInstance().getProperty("toolSelectionMode"))); if (!multipleUseMenuItem.isSelected()) oneUseMenuItem.setSelected(true); toolSelectionGroup.add(oneUseMenuItem); toolSelectionGroup.add(multipleUseMenuItem); oneUseMenuItem.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent arg0) { if (oneUseMenuItem.isSelected()) PuckConfiguration.getInstance().setProperty("toolSelectionMode", "oneUse"); else PuckConfiguration.getInstance().setProperty("toolSelectionMode", "multipleUse"); } }); toolSelectionModeMenu.add(oneUseMenuItem); toolSelectionModeMenu.add(multipleUseMenuItem); optionsMenu.add(toolSelectionModeMenu); JMenuItem sizesMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.iconsizes")); sizesMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { IconSizesDialog dial = new IconSizesDialog(PuckFrame.this, true); dial.setVisible(true); } }); optionsMenu.add(sizesMenuItem); JMenuItem showHideMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.showhide")); showHideMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ShowHideDialog dial = new ShowHideDialog(PuckFrame.this, true); dial.setVisible(true); } }); optionsMenu.add(showHideMenuItem); JMenuItem mapColorsMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.options.mapcolors")); mapColorsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MapColorsDialog dial = new MapColorsDialog(PuckFrame.this, true); dial.setVisible(true); } }); optionsMenu.add(mapColorsMenuItem); String skinList = PuckConfiguration.getInstance().getProperty("availableSkins"); if (skinList != null && skinList.trim().length() > 0) { JMenu skinsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.skins")); StringTokenizer st = new StringTokenizer(skinList, ", "); ButtonGroup skinButtons = new ButtonGroup(); while (st.hasMoreTokens()) { final String nextSkin = st.nextToken(); final JRadioButtonMenuItem skinMenuItem = new JRadioButtonMenuItem(nextSkin); skinMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setSkin(nextSkin); skinMenuItem.setSelected(true); } }); if (nextSkin.equals(PuckConfiguration.getInstance().getProperty("skin"))) skinMenuItem.setSelected(true); skinsMenu.add(skinMenuItem); skinButtons.add(skinMenuItem); } optionsMenu.add(skinsMenu); } JMenu lookFeelMenu = new JMenu(UIMessages.getInstance().getMessage("menu.looks")); ButtonGroup lookButtons = new ButtonGroup(); final JRadioButtonMenuItem defaultLookMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.looks.default")); if ("default".equals(PuckConfiguration.getInstance().getProperty("look"))) { defaultLookMenuItem.setSelected(true); } lookFeelMenu.add(defaultLookMenuItem); lookButtons.add(defaultLookMenuItem); defaultLookMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel("default"); defaultLookMenuItem.setSelected(true); } }); final JRadioButtonMenuItem systemLookMenuItem = new JRadioButtonMenuItem( UIMessages.getInstance().getMessage("menu.looks.system")); if ("system".equals(PuckConfiguration.getInstance().getProperty("look"))) { systemLookMenuItem.setSelected(true); } lookFeelMenu.add(systemLookMenuItem); lookButtons.add(systemLookMenuItem); systemLookMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel("system"); systemLookMenuItem.setSelected(true); } }); String additionalLookList = PuckConfiguration.getInstance().getProperty("additionalLooks"); if (additionalLookList != null && additionalLookList.trim().length() > 0) { StringTokenizer st = new StringTokenizer(additionalLookList, ", "); while (st.hasMoreTokens()) { final String nextLook = st.nextToken(); final JRadioButtonMenuItem lookMenuItem = new JRadioButtonMenuItem(nextLook); lookMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel(nextLook); lookMenuItem.setSelected(true); } }); if (nextLook.equals(PuckConfiguration.getInstance().getProperty("look"))) { lookMenuItem.setSelected(true); } lookFeelMenu.add(lookMenuItem); lookButtons.add(lookMenuItem); } } optionsMenu.add(lookFeelMenu); optionsMenu.add(new UILanguageSelectionMenu(this)); mainMenuBar.add(optionsMenu); JMenu toolsMenu = new JMenu(UIMessages.getInstance().getMessage("menu.tools")); final JMenuItem verbListMenuItem = new JMenuItem( UIMessages.getInstance().getMessage("menu.tools.verblist")); verbListMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { WorldPanel wp = (WorldPanel) graphPanel.getWorldNode().getAssociatedPanel(); VerbListFrame vlf = VerbListFrame.getInstance(wp.getSelectedLanguageCode()); vlf.setVisible(true); } }); toolsMenu.add(verbListMenuItem); final JMenuItem validateMenuItem = new JMenuItem( UIMessages.getInstance().getMessage("menu.tools.validatebsh")); validateMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { BeanShellCodeValidator bscv = new BeanShellCodeValidator(graphPanel); if (!bscv.validate()) { BeanShellErrorsDialog bsed = new BeanShellErrorsDialog(PuckFrame.this, bscv.getErrorText()); bsed.setVisible(true); //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText()); } else { JOptionPane.showMessageDialog(PuckFrame.this, UIMessages.getInstance().getMessage("bsh.code.ok"), "OK!", JOptionPane.INFORMATION_MESSAGE); //JOptionPane.showMessageDialog(PuckFrame.this, bscv.getErrorText()); } } }); toolsMenu.add(validateMenuItem); mainMenuBar.add(toolsMenu); JMenu helpMenu = new JMenu(UIMessages.getInstance().getMessage("menu.help")); //JHelpAction.startHelpWorker("help/PUCKHelp.hs"); //JHelpAction helpTocAction = JHelpAction.getShowHelpInstance(Messages.getInstance().getMessage("menu.help.toc")); //JHelpAction helpContextSensitiveAction = JHelpAction.getTrackInstance(Messages.getInstance().getMessage("menu.help.context")); //final JMenuItem helpTocMenuItem = new JMenuItem(helpTocAction); //final JMenuItem helpContextSensitiveMenuItem = new JMenuItem(helpContextSensitiveAction); //helpMenu.add(helpTocMenuItem); //helpMenu.add(helpContextSensitiveMenuItem); final JMenuItem helpMenuItem = new JMenuItem(UIMessages.getInstance().getMessage("menu.help.toc")); helpMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DocumentationLinkDialog dial = new DocumentationLinkDialog(PuckFrame.this, true); dial.setVisible(true); } }); helpMenu.add(helpMenuItem); mainMenuBar.add(helpMenu); MenuMnemonicOnTheFly.setMnemonics(mainMenuBar); this.setJMenuBar(mainMenuBar); //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { userExit(); } }); propPanel.show(graphPanel.getWorldNode()); setVisible(true); SwingUtilities.invokeLater(new Runnable() { public void run() { if (dividerLoc > 0) split.setDividerLocation(dividerLoc); else split.setDividerLocation(0.60); } }); }
From source file:org.gtdfree.GTDFree.java
private JCheckBoxMenuItem getShowAllActionsMenuItem() { if (showAllActions == null) { showAllActions = new JCheckBoxMenuItem(getActionMap().get(GlobalProperties.SHOW_ALL_ACTIONS)); showAllActions//from w w w.j a va 2 s . c o m .setSelected(getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_ALL_ACTIONS)); getEngine().getGlobalProperties().addPropertyChangeListener(GlobalProperties.SHOW_ALL_ACTIONS, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { showAllActions.setSelected(getEngine().getGlobalProperties() .getBoolean(GlobalProperties.SHOW_ALL_ACTIONS)); } }); } return showAllActions; }
From source file:org.gtdfree.GTDFree.java
private JCheckBoxMenuItem getShowClosedFoldersMenuItem() { if (showClosedFolders == null) { showClosedFolders = new JCheckBoxMenuItem(getActionMap().get(GlobalProperties.SHOW_CLOSED_FOLDERS)); showClosedFolders.setSelected(//from w ww. j a va 2 s .c om getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_CLOSED_FOLDERS)); getEngine().getGlobalProperties().addPropertyChangeListener(GlobalProperties.SHOW_CLOSED_FOLDERS, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { showClosedFolders.setSelected(getEngine().getGlobalProperties() .getBoolean(GlobalProperties.SHOW_CLOSED_FOLDERS)); } }); } return showClosedFolders; }
From source file:org.gtdfree.GTDFree.java
private JCheckBoxMenuItem getShowEmptyFoldersMenuItem() { if (showEmptyFolders == null) { showEmptyFolders = new JCheckBoxMenuItem(getActionMap().get(GlobalProperties.SHOW_EMPTY_FOLDERS)); showEmptyFolders.setSelected(//from ww w. java 2 s .c om getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_EMPTY_FOLDERS, true)); getEngine().getGlobalProperties().addPropertyChangeListener(GlobalProperties.SHOW_EMPTY_FOLDERS, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { showEmptyFolders.setSelected(getEngine().getGlobalProperties() .getBoolean(GlobalProperties.SHOW_EMPTY_FOLDERS, true)); } }); } return showEmptyFolders; }
From source file:org.gtdfree.GTDFree.java
private JCheckBoxMenuItem getShowOverviewTabMenuItem() { if (showOverviewTab == null) { showOverviewTab = new JCheckBoxMenuItem(getActionMap().get(GlobalProperties.SHOW_OVERVIEW_TAB)); showOverviewTab.setSelected(// w w w . j ava2 s . c o m getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_OVERVIEW_TAB, true)); getEngine().getGlobalProperties().addPropertyChangeListener(GlobalProperties.SHOW_OVERVIEW_TAB, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { showOverviewTab.setSelected(getEngine().getGlobalProperties() .getBoolean(GlobalProperties.SHOW_OVERVIEW_TAB)); if (getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_OVERVIEW_TAB)) { if (tabbedPane.getComponentAt(0) != getOverviewPane()) { tabbedPane.insertTab(Messages.getString("GTDFree.Overview"), //$NON-NLS-1$ ApplicationHelper.getIcon(ApplicationHelper.icon_name_small_overview), getOverviewPane(), "", 0); //$NON-NLS-1$ } } else { if (tabbedPane.getComponentAt(0) == getOverviewPane()) { tabbedPane.remove(0); } } } }); } return showOverviewTab; }
From source file:org.gtdfree.GTDFree.java
private JCheckBoxMenuItem getShowQuickCollectBarMenuItem() { if (showQuickCollectBar == null) { showQuickCollectBar = new JCheckBoxMenuItem(getActionMap().get(GlobalProperties.SHOW_QUICK_COLLECT)); showQuickCollectBar/*from w w w .j av a 2 s .co m*/ .setSelected(getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_QUICK_COLLECT)); getEngine().getGlobalProperties().addPropertyChangeListener(GlobalProperties.SHOW_QUICK_COLLECT, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { showQuickCollectBar.setSelected(getEngine().getGlobalProperties() .getBoolean(GlobalProperties.SHOW_QUICK_COLLECT)); enableQuickCollectPanel(); } }); } return showQuickCollectBar; }
From source file:org.gtdfree.GTDFree.java
private JCheckBoxMenuItem getShowTrayIconMenuItem() { if (showTrayIcon == null) { showTrayIcon = new JCheckBoxMenuItem(getActionMap().get(GlobalProperties.SHOW_TRAY_ICON)); showTrayIcon.setSelected(getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_TRAY_ICON)); getEngine().getGlobalProperties().addPropertyChangeListener(GlobalProperties.SHOW_TRAY_ICON, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { showTrayIcon.setSelected( getEngine().getGlobalProperties().getBoolean(GlobalProperties.SHOW_TRAY_ICON)); }/*w w w . j av a 2 s. c o m*/ }); } return showTrayIcon; }
From source file:org.interreg.docexplore.authoring.AuthoringMenu.java
public AuthoringMenu(final AuthoringToolFrame authoringTool) { this.tool = authoringTool; this.recent = new LinkedList<String>(); readRecent();//from w ww .j av a 2s . c o m this.file = new JMenu(XMLResourceBundle.getBundledString("generalMenuFile")); add(file); newItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuNew")) { public void actionPerformed(ActionEvent arg0) { newFile(); } }); loadItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuLoad")) { public void actionPerformed(ActionEvent arg0) { load(); } }); saveItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuSave")) { public void actionPerformed(ActionEvent arg0) { save(); } }); saveAsItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuSaveAs")) { public void actionPerformed(ActionEvent arg0) { saveAs(); } }); exportItem = new JMenuItem( new AbstractAction(XMLResourceBundle.getBundledString("generalMenuExport") + "...") { public void actionPerformed(ActionEvent arg0) { GuiUtils.blockUntilComplete(new ProgressRunnable() { public void run() { try { authoringTool.readerExporter.doExport(authoringTool.editor.link); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } public float getProgress() { return (float) authoringTool.readerExporter.progress[0]; } }, authoringTool.editor); } }); webExportItem = new JMenuItem( new AbstractAction(XMLResourceBundle.getBundledString("generalMenuWebExport") + "...") { public void actionPerformed(ActionEvent arg0) { GuiUtils.blockUntilComplete(new ProgressRunnable() { public void run() { try { authoringTool.webExporter.doExport(authoringTool.editor.link); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } public float getProgress() { return (authoringTool.webExporter.copyComplete ? .5f : 0f) + (float) (.5 * authoringTool.webExporter.progress[0]); } }, authoringTool.editor); } }); // webExportItem = new JMenuItem(new AbstractAction("Web export") {public void actionPerformed(ActionEvent arg0) // { // GuiUtils.blockUntilComplete(new Runnable() {public void run() // { // try // { // new WebStaticExporter().doExport(authoringTool.editor.link.getBook(authoringTool.editor.link.getLink().getAllBookIds().get(0))); // } // catch (Exception ex) {ErrorHandler.defaultHandler.submit(ex);} // }}, authoringTool.editor); // }}); // webExportItem.setEnabled(false); quitItem = new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("generalMenuQuit")) { public void actionPerformed(ActionEvent arg0) { authoringTool.quit(); } }); buildFileMenu(); JMenu edit = new JMenu(XMLResourceBundle.getBundledString("generalMenuEdit")); this.undoItem = new JMenuItem(); undoItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { authoringTool.historyManager.undo(); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } }); edit.add(undoItem); this.redoItem = new JMenuItem(); redoItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { authoringTool.historyManager.redo(); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } }); edit.add(redoItem); JMenuItem viewHistory = new JMenuItem(XMLResourceBundle.getBundledString("generalMenuEditViewHistory")); viewHistory.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { authoringTool.historyDialog.setVisible(true); } }); edit.add(viewHistory); edit.addSeparator(); edit.add(new JMenuItem(new AbstractAction(XMLResourceBundle.getBundledString("fixChars")) { public void actionPerformed(ActionEvent arg0) { Object res = JOptionPane.showInputDialog(tool, XMLResourceBundle.getBundledString("fixCharsMsg"), XMLResourceBundle.getBundledString("fixChars"), JOptionPane.QUESTION_MESSAGE, null, new Object[] { XMLResourceBundle.getBundledString("fixCharsWin"), XMLResourceBundle.getBundledString("fixCharsMac") }, XMLResourceBundle.getBundledString("fixCharsWin")); if (res == null) return; try { convertPresentation(tool.defaultFile, res.equals(XMLResourceBundle.getBundledString("fixCharsWin")) ? "ISO-8859-1" : "x-MacRoman"); } catch (Exception e) { ErrorHandler.defaultHandler.submit(e); } try { tool.editor.reset(); } catch (Exception e) { e.printStackTrace(); } } })); //TODO: remove! // edit.add(new JMenuItem(new AbstractAction("hack!") // { // public void actionPerformed(ActionEvent e) {try // { // BookEditorView be = null; // for (ExplorerView view : tool.editor.views) // if (view instanceof BookEditorView) // be = (BookEditorView)view; // Book book = be.curBook; // int lastPage = book.getLastPageNumber(); // for (int pageNum = 1;pageNum <= lastPage;pageNum++) // { // Page page = book.getPage(pageNum); // Set<Region> regions = page.getRegions(); // if (regions.size() > 2) // { // Region highest = null; // int max = -1; // for (Region region : regions) // for (Point point : region.getOutline()) // if (max < 0 || point.y < max) // {max = point.y; highest = region;} // Region middle = null; // max = -1; // for (Region region : regions) // if (region != highest) // for (Point point : region.getOutline()) // if (max < 0 || point.y < max) // {max = point.y; middle = region;} // if (regions.size() > 3) // { // max = -1; // Region newMiddle = null; // for (Region region : regions) // if (region != highest && region != middle) // for (Point point : region.getOutline()) // if (max < 0 || point.y < max) // {max = point.y; newMiddle = region;} // middle = newMiddle; // } // MetaDataKey display = book.getLink().getKey("display", ""); // for (Map.Entry<MetaDataKey, List<MetaData>> entry : highest.getMetaData().entrySet()) // for (MetaData md : entry.getValue()) // if (md.getType().equals(MetaData.textType)) // { // String val = "<b>"+md.getString()+"</b>\n"; // for (Map.Entry<MetaDataKey, List<MetaData>> entry2 : middle.getMetaData().entrySet()) // for (MetaData md2 : entry2.getValue()) // if (md2.getType().equals(MetaData.textType) && TextElement.getStyle(md, tool.styleManager) == TextElement.getStyle(md2, tool.styleManager)) // val = val+"\n"+md2.getString(); // md.setString(val); // } // boolean hasImage = false; // for (Map.Entry<MetaDataKey, List<MetaData>> entry2 : middle.getMetaData().entrySet()) // for (MetaData md2 : entry2.getValue()) // if (md2.getType().equals(MetaData.imageType)) // { // MetaData imageMd = new MetaData(book.getLink(), display, md2.getType(), md2.getValue()); // if (!hasImage) // BookImporter.insert(imageMd, highest, 0); // else BookImporter.insert(imageMd, highest, BookImporter.getHighestRank(highest)+1); // hasImage = true; // } // page.removeRegion(middle); // } // } // } // catch (Exception ex) {ex.printStackTrace();}System.out.println("done");} // })); // edit.add(new JMenuItem(new AbstractAction("hack!") // { // public void actionPerformed(ActionEvent e) {try // { // BookEditorView be = null; // for (ExplorerView view : tool.editor.views) // if (view instanceof BookEditorView) // be = (BookEditorView)view; // Book book = be.curBook; // int lastPage = book.getLastPageNumber(); // MetaDataKey display = book.getLink().getKey("display", ""); // for (int pageNum = 1;pageNum <= lastPage;pageNum++) // { // Page page = book.getPage(pageNum); // Set<Region> regions = page.getRegions(); // for (Region region : regions) // { // List<MetaData> mds = region.getMetaDataListForKey(display); // for (MetaData md : mds) // if (md.getType().equals(MetaData.textType)) // { // String val = md.getString().trim(); // if (!val.startsWith("<i>") || !val.endsWith("</i>")) // continue; // TextElement.getStyleMD(md).setString("4"); // md.setString(val.substring(3, val.length()-4)); // System.out.println(md.getString()); // } // } // } // } // catch (Exception ex) {ex.printStackTrace();}System.out.println("done");} // })); // edit.add(new JMenuItem(new AbstractAction("hack!") // { // public void actionPerformed(ActionEvent e) {try // { // BookEditorView be = null; // for (ExplorerView view : tool.editor.views) // if (view instanceof BookEditorView) // be = (BookEditorView)view; // Book book = be.curBook; // int lastPage = book.getLastPageNumber(); // MetaDataKey display = book.getLink().getKey("display", ""); // for (int pageNum = 1;pageNum <= lastPage;pageNum++) // { // Page page = book.getPage(pageNum); // Set<Region> regions = page.getRegions(); // for (Region region : regions) // { // int max = BookImporter.getHighestRank(region); // for (int i=0;i<max;i++) // { // MetaData md1 = BookImporter.getAtRank(region, i); // if (md1 == null || !md1.getType().equals(MetaData.textType)) // continue; // MetaData style1 = TextElement.getStyleMD(md1); // if (!style1.getString().equals("0")) // continue; // MetaData md2 = BookImporter.getAtRank(region, i+1); // if (md2 == null || !md2.getType().equals(MetaData.textType)) // continue; // MetaData style2 = TextElement.getStyleMD(md2); // if (!style2.getString().equals("1")) // continue; // BookImporter.setRank(md1, i+1); // BookImporter.setRank(md2, i); // i++; // } // } // } // } // catch (Exception ex) {ex.printStackTrace();}System.out.println("done");} // })); // edit.add(new JMenuItem(new AbstractAction("hack!") // { // public void actionPerformed(ActionEvent e) {try // { // BookEditorView be = null; // for (ExplorerView view : tool.editor.views) // if (view instanceof BookEditorView) // be = (BookEditorView)view; // Book book = be.curBook; // MetaDataKey mini = book.getLink().getOrCreateKey("mini", ""); // MetaDataKey dim = book.getLink().getOrCreateKey("dimension", ""); // int lastPage = book.getLastPageNumber(); // for (int pageNum = 1;pageNum <= lastPage;pageNum++) // { // Page page = book.getPage(pageNum); // List<MetaData> mds = page.getMetaDataListForKey(mini); // if (mds != null) // for (MetaData md : mds) // page.removeMetaData(md); // mds = page.getMetaDataListForKey(dim); // if (mds != null) // for (MetaData md : mds) // page.removeMetaData(md); // DocExploreDataLink.getImageDimension(page, true); // DocExploreDataLink.getImageMini(page, false); // } // } // catch (Exception ex) {ex.printStackTrace();}System.out.println("done");} // })); add(edit); JMenu view = new JMenu(XMLResourceBundle.getBundledString("generalMenuView")); add(view); JMenuItem styles = new JMenuItem(XMLResourceBundle.getBundledString("styleEdit") + "...", ImageUtils.getIcon("pencil-24x24.png")); styles.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { authoringTool.styleManager.styleDialog.setVisible(true); } }); view.add(styles); helpToggle = new JCheckBoxMenuItem( new AbstractAction(XMLResourceBundle.getBundledString("viewHelpToggle")) { public void actionPerformed(ActionEvent arg0) { authoringTool.displayHelp = helpToggle.isSelected(); authoringTool.repaint(); } }); helpToggle.setSelected(tool.startup.showHelp); view.add(helpToggle); JMenu helpMenu = new JMenu(XMLResourceBundle.getString("management-lrb", "generalMenuHelp")); if (Desktop.isDesktopSupported()) { final Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { helpMenu.add(new AbstractAction( XMLResourceBundle.getString("management-lrb", "generalMenuHelpContents")) { public void actionPerformed(ActionEvent e) { try { File doc = new File(DocExploreTool.getExecutableDir(), "MMT documentation.htm"); desktop.open(doc); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex, true); } } }); helpMenu.add(new AbstractAction( XMLResourceBundle.getString("management-lrb", "generalMenuHelpWebsite")) { public void actionPerformed(ActionEvent e) { try { File link = new File(DocExploreTool.getExecutableDir(), "website.url"); desktop.open(link); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex, true); } } }); } } helpMenu.add(new AbstractAction(XMLResourceBundle.getString("management-lrb", "generalMenuHelpAbout")) { public void actionPerformed(ActionEvent e) { final JDialog splash = new JDialog(tool, true); splash.setLayout(new BorderLayout()); SplashScreen screen = new SplashScreen("logoAT.png"); splash.add(screen, BorderLayout.NORTH); screen.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { splash.setVisible(false); } }); splash.setUndecorated(true); screen.setText( "<html>DocExplore 2009-2014" + "<br/>Released under the CeCILL v2.1 license" + "</html>"); splash.pack(); splash.setAlwaysOnTop(true); GuiUtils.centerOnScreen(splash); splash.setVisible(true); } }); add(helpMenu); historyChanged(authoringTool.historyManager); authoringTool.historyManager.addHistoryListener(this); }
From source file:org.jajuk.ui.widgets.JajukJMenuBar.java
/** * Instantiates a new jajuk j menu bar.//from ww w . j a v a 2s . c om */ private JajukJMenuBar() { setAlignmentX(0.0f); // File menu file = new JMenu(Messages.getString("JajukJMenuBar.0")); jmiFileExit = new JMenuItem(ActionManager.getAction(JajukActions.EXIT)); file.add(jmiFileExit); // Properties menu properties = new JMenu(Messages.getString("JajukJMenuBar.5")); jmiNewProperty = new JMenuItem(ActionManager.getAction(CUSTOM_PROPERTIES_ADD)); jmiRemoveProperty = new JMenuItem(ActionManager.getAction(CUSTOM_PROPERTIES_REMOVE)); jmiActivateTags = new JMenuItem(ActionManager.getAction(EXTRA_TAGS_WIZARD)); properties.add(jmiNewProperty); properties.add(jmiRemoveProperty); properties.add(jmiActivateTags); // View menu views = new JMenu(Messages.getString("JajukJMenuBar.8")); jmiRestoreDefaultViews = new JMenuItem(ActionManager.getAction(VIEW_RESTORE_DEFAULTS)); jmiRestoreDefaultViewsAllPerpsectives = new JMenuItem( ActionManager.getAction(JajukActions.ALL_VIEW_RESTORE_DEFAULTS)); views.add(jmiRestoreDefaultViews); views.add(jmiRestoreDefaultViewsAllPerpsectives); views.addSeparator(); // Add the list of available views parsed in XML files at startup JMenu jmViews = new JMenu(Messages.getString("JajukJMenuBar.25")); for (final Class<? extends IView> view : ViewFactory.getKnownViews()) { JMenuItem jmi = null; try { jmi = new JMenuItem(view.newInstance().getDesc(), IconLoader.getIcon(JajukIcons.LOGO_FRAME)); } catch (Exception e1) { Log.error(e1); continue; } jmi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // Simply add the new view in the current perspective PerspectiveAdapter current = (PerspectiveAdapter) PerspectiveManager.getCurrentPerspective(); IView newView = ViewFactory.createView(view, current, Math.abs(UtilSystem.getRandom().nextInt())); newView.initUI(); newView.setPopulated(); current.addDockable(newView); } }); jmViews.add(jmi); } views.add(jmViews); // Mode menu String modeText = Messages.getString("JajukJMenuBar.9"); mode = new JMenu(ActionUtil.strip(modeText)); jcbmiRepeat = new JCheckBoxMenuItem(ActionManager.getAction(REPEAT_MODE)); jcbmiRepeat.setSelected(Conf.getBoolean(Const.CONF_STATE_REPEAT)); jcbmiRepeatAll = new JCheckBoxMenuItem(ActionManager.getAction(REPEAT_ALL_MODE)); jcbmiRepeatAll.setSelected(Conf.getBoolean(Const.CONF_STATE_REPEAT_ALL)); jcbmiShuffle = new JCheckBoxMenuItem(ActionManager.getAction(SHUFFLE_MODE)); jcbmiShuffle.setSelected(Conf.getBoolean(Const.CONF_STATE_SHUFFLE)); jcbmiContinue = new JCheckBoxMenuItem(ActionManager.getAction(CONTINUE_MODE)); jcbmiContinue.setSelected(Conf.getBoolean(Const.CONF_STATE_CONTINUE)); jcbmiIntro = new JCheckBoxMenuItem(ActionManager.getAction(INTRO_MODE)); jcbmiIntro.setSelected(Conf.getBoolean(Const.CONF_STATE_INTRO)); jcbmiKaraoke = new JCheckBoxMenuItem(ActionManager.getAction(JajukActions.KARAOKE_MODE)); if (Conf.getBoolean(Const.CONF_BIT_PERFECT)) { jcbmiKaraoke.setEnabled(false); jcbmiKaraoke.setSelected(false); Conf.setProperty(Const.CONF_STATE_KARAOKE, Const.FALSE); } else { jcbmiKaraoke.setSelected(Conf.getBoolean(Const.CONF_STATE_KARAOKE)); } mode.add(jcbmiRepeat); mode.add(jcbmiRepeatAll); mode.add(jcbmiShuffle); mode.add(jcbmiContinue); mode.add(jcbmiIntro); mode.add(jcbmiKaraoke); // Smart Menu smart = new JMenu(Messages.getString("JajukJMenuBar.29")); jmiShuffle = new SizedJMenuItem(ActionManager.getAction(JajukActions.SHUFFLE_GLOBAL)); jmiBestof = new SizedJMenuItem(ActionManager.getAction(JajukActions.BEST_OF)); jmiNovelties = new SizedJMenuItem(ActionManager.getAction(JajukActions.NOVELTIES)); jmiFinishAlbum = new SizedJMenuItem(ActionManager.getAction(JajukActions.FINISH_ALBUM)); smart.add(jmiShuffle); smart.add(jmiBestof); smart.add(jmiNovelties); smart.add(jmiFinishAlbum); // Tools Menu tools = new JMenu(Messages.getString("JajukJMenuBar.28")); jmiduplicateFinder = new JMenuItem(ActionManager.getAction(JajukActions.FIND_DUPLICATE_FILES)); jmialarmClock = new JMenuItem(ActionManager.getAction(JajukActions.ALARM_CLOCK)); jmiprepareParty = new JMenuItem(ActionManager.getAction(JajukActions.PREPARE_PARTY)); tools.add(jmiduplicateFinder); tools.add(jmialarmClock); tools.add(jmiprepareParty); // tools.addSeparator(); // Configuration menu configuration = new JMenu(Messages.getString("JajukJMenuBar.21")); jmiDJ = new JMenuItem(ActionManager.getAction(CONFIGURE_DJS)); // Overwrite default icon jmiDJ.setIcon(IconLoader.getIcon(JajukIcons.DIGITAL_DJ_16X16)); jmiAmbience = new JMenuItem(ActionManager.getAction(CONFIGURE_AMBIENCES)); jmiWizard = new JMenuItem(ActionManager.getAction(SIMPLE_DEVICE_WIZARD)); jmiOptions = new JMenuItem(ActionManager.getAction(OPTIONS)); jmiUnmounted = new JCheckBoxMenuItem(ActionManager.getAction(JajukActions.UNMOUNTED)); jmiUnmounted.setSelected(Conf.getBoolean(Const.CONF_OPTIONS_HIDE_UNMOUNTED)); jmiUnmounted.putClientProperty(Const.DETAIL_ORIGIN, jmiUnmounted); jcbShowPopups = new JCheckBoxMenuItem(Messages.getString("ParameterView.228")); jcbShowPopups.setSelected(Conf.getBoolean(Const.CONF_SHOW_POPUPS)); jcbShowPopups.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Conf.setProperty(Const.CONF_SHOW_POPUPS, Boolean.toString(jcbShowPopups.isSelected())); // force parameter view to take this into account ObservationManager.notify(new JajukEvent(JajukEvents.PARAMETERS_CHANGE)); } }); jcbNoneInternetAccess = new JCheckBoxMenuItem(Messages.getString("ParameterView.264")); jcbNoneInternetAccess.setToolTipText(Messages.getString("ParameterView.265")); jcbNoneInternetAccess.setSelected(Conf.getBoolean(Const.CONF_NETWORK_NONE_INTERNET_ACCESS)); jcbNoneInternetAccess.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Conf.setProperty(Const.CONF_NETWORK_NONE_INTERNET_ACCESS, Boolean.toString(jcbNoneInternetAccess.isSelected())); // force parameter view to take this into account ObservationManager.notify(new JajukEvent(JajukEvents.PARAMETERS_CHANGE)); } }); configuration.add(jmiUnmounted); configuration.add(jcbShowPopups); configuration.add(jcbNoneInternetAccess); configuration.addSeparator(); configuration.add(jmiDJ); configuration.add(jmiAmbience); configuration.add(jmiWizard); configuration.add(jmiOptions); // Help menu String helpText = Messages.getString("JajukJMenuBar.14"); help = new JMenu(ActionUtil.strip(helpText)); jmiHelp = new JMenuItem(ActionManager.getAction(HELP_REQUIRED)); jmiDonate = new JMenuItem(ActionManager.getAction(SHOW_DONATE)); jmiAbout = new JMenuItem(ActionManager.getAction(SHOW_ABOUT)); jmiTraces = new JMenuItem(ActionManager.getAction(SHOW_TRACES)); jmiTraces = new JMenuItem(ActionManager.getAction(SHOW_TRACES)); jmiCheckforUpdates = new JMenuItem(ActionManager.getAction(JajukActions.CHECK_FOR_UPDATES)); jmiTipOfTheDay = new JMenuItem(ActionManager.getAction(TIP_OF_THE_DAY)); help.add(jmiHelp); help.add(jmiTipOfTheDay); // Install this action only if Desktop class is supported, it is used to // open default mail client if (UtilSystem.isBrowserSupported()) { jmiQualityAgent = new JMenuItem(ActionManager.getAction(QUALITY)); help.add(jmiQualityAgent); } help.add(jmiTraces); help.add(jmiCheckforUpdates); help.add(jmiDonate); help.add(jmiAbout); mainmenu = new JMenuBar(); mainmenu.add(file); mainmenu.add(views); mainmenu.add(properties); mainmenu.add(mode); mainmenu.add(smart); mainmenu.add(tools); mainmenu.add(configuration); mainmenu.add(help); // Apply mnemonics (Alt + first char of the menu keystroke) applyMnemonics(); if (SessionService.isTestMode()) { jbGC = new JajukButton(ActionManager.getAction(JajukActions.GC)); } jbSlim = new JajukButton(ActionManager.getAction(JajukActions.SLIM_JAJUK)); jbFull = new JajukButton(ActionManager.getAction(JajukActions.FULLSCREEN_JAJUK)); JMenuBar eastmenu = new JMenuBar(); // only show GC-button in test-mode if (SessionService.isTestMode()) { eastmenu.add(jbGC); } eastmenu.add(jbSlim); eastmenu.add(jbFull); setLayout(new BorderLayout()); add(mainmenu, BorderLayout.WEST); add(eastmenu, BorderLayout.EAST); // Check for new release and display the icon if a new release is available SwingWorker<Void, Void> sw = new SwingWorker<Void, Void>() { @Override public Void doInBackground() { UpgradeManager.checkForUpdate(); return null; } @Override public void done() { // add the new release label if required if (UpgradeManager.getNewVersionName() != null) { jlUpdate = new JLabel(" ", IconLoader.getIcon(JajukIcons.UPDATE_MANAGER), SwingConstants.RIGHT); String newRelease = UpgradeManager.getNewVersionName(); if (newRelease != null) { jlUpdate.setToolTipText(Messages.getString("UpdateManager.0") + newRelease + Messages.getString("UpdateManager.1")); } add(Box.createHorizontalGlue()); add(jlUpdate); } } }; // Search online for upgrade if the option is set and if the none Internet // access option is not set if (Conf.getBoolean(Const.CONF_CHECK_FOR_UPDATE) && !Conf.getBoolean(Const.CONF_NETWORK_NONE_INTERNET_ACCESS)) { sw.execute(); } ObservationManager.register(this); }