List of usage examples for java.awt.event KeyEvent VK_I
int VK_I
To view the source code for java.awt.event KeyEvent VK_I.
Click Source Link
From source file:org.tinymediamanager.ui.MainWindow.java
/** * Create the application./*from w ww. j a v a 2s . com*/ * * @param name * the name */ public MainWindow(String name) { super(name); setName("mainWindow"); setMinimumSize(new Dimension(1000, 700)); instance = this; JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); JMenu mnTmm = new JMenu("tinyMediaManager"); mnTmm.setMnemonic(KeyEvent.VK_T); menuBar.add(mnTmm); if (!Globals.isDonator()) { mnTmm.add(new RegisterDonatorVersionAction()); } mnTmm.add(new SettingsAction()); mnTmm.addSeparator(); mnTmm.add(new LaunchUpdaterAction()); mnTmm.addSeparator(); mnTmm.add(new ExitAction()); initialize(); // tools menu JMenu tools = new JMenu(BUNDLE.getString("tmm.tools")); //$NON-NLS-1$ tools.setMnemonic(KeyEvent.VK_O); tools.add(new ClearDatabaseAction()); JMenu cache = new JMenu(BUNDLE.getString("tmm.cache")); //$NON-NLS-1$ cache.setMnemonic(KeyEvent.VK_C); tools.add(cache); JMenuItem clearImageCache = new JMenuItem(new ClearImageCacheAction()); clearImageCache.setMnemonic(KeyEvent.VK_I); cache.add(clearImageCache); JMenuItem rebuildImageCache = new JMenuItem(new RebuildImageCacheAction()); rebuildImageCache.setMnemonic(KeyEvent.VK_R); cache.add(rebuildImageCache); JMenuItem tmmFolder = new JMenuItem(BUNDLE.getString("tmm.gotoinstalldir")); //$NON-NLS-1$ tmmFolder.setMnemonic(KeyEvent.VK_I); tools.add(tmmFolder); tmmFolder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Path path = Paths.get(System.getProperty("user.dir")); try { // check whether this location exists if (Files.exists(path)) { TmmUIHelper.openFile(path); } } catch (Exception ex) { LOGGER.error("open filemanager", ex); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path, "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() })); } } }); JMenuItem tmmLogs = new JMenuItem(BUNDLE.getString("tmm.errorlogs")); //$NON-NLS-1$ tmmLogs.setMnemonic(KeyEvent.VK_L); tools.add(tmmLogs); tmmLogs.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JDialog logDialog = new LogDialog(); logDialog.setLocationRelativeTo(MainWindow.getActiveInstance()); logDialog.setVisible(true); } }); JMenuItem tmmMessages = new JMenuItem(BUNDLE.getString("tmm.messages")); //$NON-NLS-1$ tmmMessages.setMnemonic(KeyEvent.VK_L); tools.add(tmmMessages); tmmMessages.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { JDialog messageDialog = MessageHistoryDialog.getInstance(); messageDialog.setVisible(true); } }); tools.addSeparator(); final JMenu menuWakeOnLan = new JMenu(BUNDLE.getString("tmm.wakeonlan")); //$NON-NLS-1$ menuWakeOnLan.setMnemonic(KeyEvent.VK_W); menuWakeOnLan.addMenuListener(new MenuListener() { @Override public void menuCanceled(MenuEvent arg0) { } @Override public void menuDeselected(MenuEvent arg0) { } @Override public void menuSelected(MenuEvent arg0) { menuWakeOnLan.removeAll(); for (final WolDevice device : Globals.settings.getWolDevices()) { JMenuItem item = new JMenuItem(device.getName()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Utils.sendWakeOnLanPacket(device.getMacAddress()); } }); menuWakeOnLan.add(item); } } }); tools.add(menuWakeOnLan); // activate/deactivate WakeOnLan menu item tools.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { if (Globals.settings.getWolDevices().size() > 0) { menuWakeOnLan.setEnabled(true); } else { menuWakeOnLan.setEnabled(false); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); if (Globals.isDebug()) { final JMenu debugMenu = new JMenu("Debug"); //$NON-NLS-1$ JMenuItem trace = new JMenuItem("set Logger to TRACE"); //$NON-NLS-1$ trace.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); lc.getLogger("org.tinymediamanager").setLevel(Level.TRACE); MessageManager.instance.pushMessage(new Message("Trace levels set!", "")); LOGGER.trace("if you see that, we're now on TRACE logging level ;)"); } }); debugMenu.add(trace); tools.add(debugMenu); } menuBar.add(tools); mnTmm = new JMenu(BUNDLE.getString("tmm.contact")); //$NON-NLS-1$ mnTmm.setMnemonic(KeyEvent.VK_C); mnTmm.add(new FeedbackAction()).setMnemonic(KeyEvent.VK_F); mnTmm.add(new BugReportAction()).setMnemonic(KeyEvent.VK_B); menuBar.add(mnTmm); mnTmm = new JMenu(BUNDLE.getString("tmm.help")); //$NON-NLS-1$ mnTmm.setMnemonic(KeyEvent.VK_H); menuBar.add(mnTmm); mnTmm.add(new WikiAction()).setMnemonic(KeyEvent.VK_W); mnTmm.add(new FaqAction()).setMnemonic(KeyEvent.VK_F); mnTmm.add(new ForumAction()).setMnemonic(KeyEvent.VK_O); mnTmm.addSeparator(); mnTmm.add(new AboutAction()).setMnemonic(KeyEvent.VK_A); menuBar.add(Box.createGlue()); if (!Globals.isDonator()) { JButton btnDonate = new JButton(new DonateAction()); btnDonate.setBorderPainted(false); btnDonate.setFocusPainted(false); btnDonate.setContentAreaFilled(false); menuBar.add(btnDonate); } checkForUpdate(); }
From source file:org.jannocessor.ui.RenderPreviewDialog.java
private void initialize() { logger.debug("Initializing UI..."); DefaultSyntaxKit.initKit();/*from w ww . j a v a2 s .c o m*/ JEditorPane.registerEditorKitForContentType("text/java_template", "org.jannocessor.syntax.JavaTemplateKit", getClass().getClassLoader()); JEditorPane.registerEditorKitForContentType("text/java_output", "org.jannocessor.syntax.JavaOutputKit", getClass().getClassLoader()); setTitle("JAnnocessor - Java Annotation Processor"); setLayout(new BorderLayout(5, 5)); listFiles(); Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize = tk.getScreenSize(); double width = screenSize.getWidth() * 0.9; double height = screenSize.getHeight() * 0.8; // Font font = new Font("Courier New", Font.PLAIN, 14); input = createInput(); JScrollPane scroll1 = new JScrollPane(input, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); input.setContentType("text/java_template"); input.setText(""); scroll1.setMinimumSize(new Dimension(200, 200)); scroll1.setPreferredSize(new Dimension((int) (width * 0.5), (int) height)); add(scroll1, BorderLayout.CENTER); output = Box.createVerticalBox(); scroll2 = new JScrollPane(output, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll2.setMinimumSize(new Dimension(200, 200)); scroll2.setPreferredSize(new Dimension((int) (width * 0.5), (int) height)); add(scroll2, BorderLayout.EAST); combo = createCombo(); combo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { load((File) combo.getSelectedItem()); } }); add(combo, BorderLayout.NORTH); JLabel help = new JLabel( " Choose a template from the drop-down box to edit it. Navigation: Alt + Left & Alt + Right; Refresh = F5, Close = Esc", JLabel.CENTER); help.setForeground(Color.WHITE); help.setBackground(Color.BLACK); help.setOpaque(true); help.setFont(new Font("Courier New", Font.BOLD, 14)); add(help, BorderLayout.SOUTH); keyListener = new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F5) { e.consume(); processElements(); refresh(); } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { e.consume(); dispose(); } else if (e.getKeyCode() == KeyEvent.VK_LEFT && e.isAltDown()) { e.consume(); moveBackward(); } else if (e.getKeyCode() == KeyEvent.VK_RIGHT && e.isAltDown()) { e.consume(); moveForward(); } else if (e.getKeyCode() == KeyEvent.VK_S && e.isControlDown()) { e.consume(); save(); } else if (e.getKeyCode() == KeyEvent.VK_I && e.isControlDown()) { e.consume(); increase(); } else if (e.getKeyCode() == KeyEvent.VK_D && e.isControlDown()) { e.consume(); decrease(); } } }; input.addKeyListener(keyListener); combo.addKeyListener(keyListener); setActive(0); pack(); setModal(true); setLocationRelativeTo(null); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); input.requestFocus(); logger.debug("Initialized UI."); }
From source file:org.ngrinder.recorder.ui.RecordingControlPanel.java
private JPopupMenu createFilterTablePopUp() { final JPopupMenu result = new JPopupMenu(); JMenuItem excludeSelectedHosts = new JMenuItem("Exclude selected hosts", KeyEvent.VK_U); result.add(excludeSelectedHosts);/*ww w. ja v a2s. c om*/ excludeSelectedHosts.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selectedRows = createFilterTables.getSelectedRows(); ((FilterTableModel) createFilterTables.getModel()).setSelection(selectedRows, false); } }); JMenuItem includeSelectedHost = new JMenuItem("Include selected hosts", KeyEvent.VK_I); result.add(includeSelectedHost); includeSelectedHost.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selectedRows = createFilterTables.getSelectedRows(); ((FilterTableModel) createFilterTables.getModel()).setSelection(selectedRows, true); } }); result.addSeparator(); JMenuItem deleteSelectedHost = new JMenuItem("Deleted selected hosts", KeyEvent.VK_D); result.add(deleteSelectedHost); deleteSelectedHost.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selectedRows = createFilterTables.getSelectedRows(); ((FilterTableModel) createFilterTables.getModel()).removeRows(selectedRows); } }); return result; }
From source file:org.geopublishing.atlasStyler.swing.AtlasStylerGUI.java
/** * Creates a nre {@link JMenuBar} instance *///from w w w.j av a 2s . c o m private JMenuBar createMenuBar() { JMenuBar jMenuBar = new JMenuBar(); JMenu fileMenu = new JMenu(AsSwingUtil.R("MenuBar.FileMenu")); jMenuBar.add(fileMenu); { // Import WIzard JMenuItem mi = new JMenuItem(new AbstractAction(AsSwingUtil.R("MenuBar.FileMenu.ImportWizard")) { @Override public void actionPerformed(ActionEvent e) { ImportWizard.showWizard(AtlasStylerGUI.this, AtlasStylerGUI.this); } }); mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, Event.CTRL_MASK, true)); fileMenu.add(mi); } fileMenu.add(SwingUtil.createChangeLog4JLevelJMenu()); /** * MenuItem to create a new language */ JMenuItem manageLanguageJMenuitem = new JMenuItem( new AbstractAction(ASUtil.R("TranslateSoftwareDialog.Title"), Icons.ICON_FLAGS_SMALL) { @Override public void actionPerformed(ActionEvent e) { String resPath = IOUtil .escapePath(System.getProperty("user.home") + File.separator + ".Geopublishing"); ResourceProviderManagerFrame manLanguagesFrame = new ResourceProviderManagerFrame( AtlasStylerGUI.this, true, AsSwingUtil.R("TranslateSoftwareDialog.Explanation.Html", resPath, SystemUtils.IS_OS_WINDOWS ? "bat" : "sh")); manLanguagesFrame.setRootPath(new File(resPath)); manLanguagesFrame.setTitle(ASUtil.R("TranslateSoftwareDialog.Title")); manLanguagesFrame.setPreferredSize(new Dimension(780, 450)); manLanguagesFrame.setVisible(true); } }); fileMenu.add(manageLanguageJMenuitem); AbstractAction optionsButton = new AbstractAction(AtlasStylerVector.R("Options.ButtonLabel")) { @Override public void actionPerformed(ActionEvent e) { new ASOptionsDialog(AtlasStylerGUI.this, AtlasStylerGUI.this); } }; fileMenu.add(optionsButton); { // Exit JMenuItem mi = new JMenuItem(new AbstractAction( GpCoreUtil.R("AtlasViewer.FileMenu.ExitMenuItem.exit_application"), Icons.ICON_EXIT_SMALL) { @Override public void actionPerformed(ActionEvent e) { exitAS(0); } }); fileMenu.add(mi); } return jMenuBar; }
From source file:org.rimudb.editor.RimuDBEditor.java
public JMenuBar buildJMenuBar() { log.debug("buildJMenuBar()"); JMenuBar menuBar = new JMenuBar(); // File menu/* ww w . jav a 2 s . c o m*/ JMenu menu = new JMenu("File"); menu.setMnemonic(KeyEvent.VK_F); openMenuItem = new JMenuItem( new OpenDescriptorAction(this, "Open...", loadIcon("/images/famfamfam/folder.png"))); openMenuItem.setName("OpenMenuItem"); openMenuItem.setMnemonic(KeyEvent.VK_O); openMenuItem.setAccelerator( KeyStroke.getKeyStroke('O', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); menu.add(openMenuItem); saveMenuItem = new JMenuItem( new SaveDescriptorAction(this, "Save", loadIcon("/images/famfamfam/disk.png"))); saveMenuItem.setName("SaveMenuItem"); saveMenuItem.setMnemonic(KeyEvent.VK_S); saveMenuItem.setAccelerator( KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); menu.add(saveMenuItem); saveAsMenuItem = new JMenuItem(new SaveAsDescriptorAction(this, "Save as...")); saveAsMenuItem.setName("SaveAsMenuItem"); menu.add(saveAsMenuItem); menu.addSeparator(); clearMenuItem = new JMenuItem( new ClearTableAction(this, "Clear...", loadIcon("/images/famfamfam/bin_closed.png"))); clearMenuItem.setName("ClearMenuItem"); clearMenuItem.setMnemonic(KeyEvent.VK_C); menu.add(clearMenuItem); preferencesMenuItem = new JMenuItem( new PreferencesAction(this, "Preferences...", loadIcon("/images/famfamfam/text_list_bullets.png"))); preferencesMenuItem.setName("PreferencesMenuItem"); preferencesMenuItem.setEnabled(false); preferencesMenuItem.setMnemonic(KeyEvent.VK_P); menu.add(preferencesMenuItem); menu.addSeparator(); exitMenuItem = new JMenuItem(new ExitAction(this, "Exit")); exitMenuItem.setName("ExitMenuItem"); exitMenuItem.setMnemonic(KeyEvent.VK_E); menu.add(exitMenuItem); menuBar.add(menu); JMenu toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic(KeyEvent.VK_T); dbImportMenuItem = new JMenuItem( new ImportAction(this, "Import from database...", loadIcon("/images/famfamfam/database_go.png"))); dbImportMenuItem.setName("DbImportMenuItem"); dbImportMenuItem.setEnabled(false); dbImportMenuItem.setMnemonic(KeyEvent.VK_I); dbImportMenuItem.setAccelerator( KeyStroke.getKeyStroke('I', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false)); toolsMenu.add(dbImportMenuItem); createClassesMenuItem = new JMenuItem(new GenerateJavaAction(this, "Create classes...", loadIcon("/images/famfamfam/page_white_cup.png"))); createClassesMenuItem.setName("CreateClassesMenuItem"); createClassesMenuItem.setMnemonic(KeyEvent.VK_C); toolsMenu.add(createClassesMenuItem); ddsExportMenuItem = new JMenuItem("Export as DDS..."); ddsExportMenuItem.setName("DdsExportMenuItem"); ddsExportMenuItem.setMnemonic(KeyEvent.VK_D); ddsExportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { actionExportToDDS(); } }); toolsMenu.add(ddsExportMenuItem); sqlExportMenuItem = new JMenuItem("Export as SQL..."); sqlExportMenuItem.setIcon(loadIcon("/images/famfamfam/page_white_database.png")); sqlExportMenuItem.setName("SqlExportMenuItem"); sqlExportMenuItem.setMnemonic(KeyEvent.VK_Q); sqlExportMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { actionExportToSQL(); } }); toolsMenu.add(sqlExportMenuItem); toolsMenu.addSeparator(); propertyRenameMenuItem = new JMenuItem("Rename Properties..."); propertyRenameMenuItem.setName("PropertyRenameMenuItem"); propertyRenameMenuItem.setMnemonic(KeyEvent.VK_R); propertyRenameMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { actionRenameProperties(); } }); toolsMenu.add(propertyRenameMenuItem); copyCodeMenuItem = new JMenuItem(new GenerateCopyCodeAction(this, "Create Java DO Copy Code...", null)); copyCodeMenuItem.setName("CopyCodeMenuItem"); toolsMenu.add(copyCodeMenuItem); convertFinderMenuItem = new JMenuItem(new ConvertFinderAction(this, "Convert Finders (pre 1.1)...", null)); convertFinderMenuItem.setName("ConvertFinderMenuItem"); toolsMenu.add(convertFinderMenuItem); convertCDBMenuItem = new JMenuItem(new ConvertCDBAction(this, "Convert CDB Configs (pre 1.2)...", null)); convertCDBMenuItem.setName("ConvertCDBMenuItem"); toolsMenu.add(convertCDBMenuItem); menuBar.add(toolsMenu); JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic(KeyEvent.VK_H); aboutMenuItem = new JMenuItem(new AboutAction(this, "About...")); aboutMenuItem.setName("AboutMenuItem"); helpMenu.add(aboutMenuItem); menuBar.add(helpMenu); return menuBar; }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java
private void createActions() { //file//from w ww . j av a2s. co m theActionManager.add("print", FileUtils.defaultThemeManager.getImageIcon("print"), "Print...", KeyEvent.VK_P, "ctrl P", this); //edit theActionManager.add("undo", FileUtils.defaultThemeManager.getImageIcon("undo"), "Undo", KeyEvent.VK_U, "ctrl Z", this); theActionManager.add("redo", FileUtils.defaultThemeManager.getImageIcon("redo"), "Redo", KeyEvent.VK_R, "ctrl Y", this); theActionManager.add("cut", FileUtils.defaultThemeManager.getImageIcon("cut"), "Cut", KeyEvent.VK_T, "ctrl X", this); theActionManager.add("copy", FileUtils.defaultThemeManager.getImageIcon("copy"), "Copy", KeyEvent.VK_C, "ctrl C", this); theActionManager.add("delete", FileUtils.defaultThemeManager.getImageIcon("delete"), "Delete", KeyEvent.VK_DELETE, "", this); theActionManager.add("screenshot", FileUtils.defaultThemeManager.getImageIcon("screenshot"), "Screenshot", KeyEvent.VK_PRINTSCREEN, "PRINTSCREEN", this); theActionManager.add("selectall", FileUtils.defaultThemeManager.getImageIcon("selectall"), "Select all", KeyEvent.VK_A, "ctrl A", this); theActionManager.add("selectnone", FileUtils.defaultThemeManager.getImageIcon("selectnone"), "Select none", KeyEvent.VK_E, "ESCAPE", this); theActionManager.add("enlarge", FileUtils.defaultThemeManager.getImageIcon("enlarge"), "Enlarge selected structures", -1, "", this); theActionManager.add("resetsize", FileUtils.defaultThemeManager.getImageIcon("resetsize"), "Reset size of selected structures to default value", -1, "", this); theActionManager.add("shrink", FileUtils.defaultThemeManager.getImageIcon("shrink"), "Shrink selected structures", -1, "", this); theActionManager.add("ungroup", FileUtils.defaultThemeManager.getImageIcon("ungroup"), "Ungroup selected structures", -1, "", this); theActionManager.add("group", FileUtils.defaultThemeManager.getImageIcon("group"), "Group selected structures", -1, "", this); theActionManager.add("placestructures", FileUtils.defaultThemeManager.getImageIcon("placestructures"), "Automatic place all structures", -1, "", this); // view theActionManager.add("zoomnone", FileUtils.defaultThemeManager.getImageIcon("zoomnone"), "Reset zoom", -1, "", this); theActionManager.add("zoomin", FileUtils.defaultThemeManager.getImageIcon("zoomin"), "Zoom in", -1, "", this); theActionManager.add("zoomout", FileUtils.defaultThemeManager.getImageIcon("zoomout"), "Zoom out", -1, "", this); theActionManager.add("notation=" + GraphicOptions.NOTATION_CFG, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "CFG notation", KeyEvent.VK_C, "", this); theActionManager.add("notation=" + GraphicOptions.NOTATION_CFGBW, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "CFG black and white notation", KeyEvent.VK_B, "", this); theActionManager.add("notation=" + GraphicOptions.NOTATION_CFGLINK, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "CFG with linkage placement notation", KeyEvent.VK_L, "", this); theActionManager.add("notation=" + GraphicOptions.NOTATION_UOXF, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "UOXF notation", KeyEvent.VK_O, "", this); theActionManager.add("notation=" + GraphicOptions.NOTATION_TEXT, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "Text only notation", KeyEvent.VK_T, "", this); theActionManager.add("display=" + GraphicOptions.DISPLAY_COMPACT, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "compact view", KeyEvent.VK_O, "", this); theActionManager.add("display=" + GraphicOptions.DISPLAY_NORMAL, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "normal view", KeyEvent.VK_N, "", this); theActionManager.add("display=" + GraphicOptions.DISPLAY_NORMALINFO, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "normal view with linkage info", KeyEvent.VK_I, "", this); theActionManager.add("display=" + GraphicOptions.DISPLAY_CUSTOM, ThemeManager.getResizableEmptyIcon(ICON_SIZE.L3), "custom view with user settings", KeyEvent.VK_K, "", this); theActionManager.add("orientation", getOrientationIcon(), "Change orientation", -1, "", this); theActionManager.add("displaysettings", ThemeManager.getEmptyIcon(ICON_SIZE.TINY), "Change structure display settings", KeyEvent.VK_S, "", this); theActionManager.add("reportsettings", ThemeManager.getEmptyIcon(ICON_SIZE.TINY), "Change report display settings", KeyEvent.VK_R, "", this); }
From source file:userinterface.properties.GUIGraphHandler.java
private void initComponents() { theTabs = new JTabbedPane() { @Override/*from ww w . j a va 2 s. c o m*/ public String getTitleAt(int index) { try { TabClosePanel panel = (TabClosePanel) getTabComponentAt(index); return panel.getTitle(); } catch (Exception e) { return ""; } } @Override public String getToolTipTextAt(int index) { return ((TabClosePanel) getTabComponentAt(index)).getToolTipText(); } @Override public void setTitleAt(int index, String title) { if (((TabClosePanel) getTabComponentAt(index)) == null) { return; } ((TabClosePanel) getTabComponentAt(index)).setTitle(title); } @Override public void setIconAt(int index, Icon icon) { ((TabClosePanel) getTabComponentAt(index)).setIcon(icon); } @Override public void setToolTipTextAt(int index, String toolTipText) { ((TabClosePanel) getTabComponentAt(index)).setToolTip(toolTipText); } }; theTabs.addMouseListener(this); theTabs.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.getPreciseWheelRotation() > 0.0) { if (theTabs.getSelectedIndex() != (theTabs.getTabCount() - 1)) theTabs.setSelectedIndex(theTabs.getSelectedIndex() + 1); } else { if (theTabs.getSelectedIndex() != 0) theTabs.setSelectedIndex(theTabs.getSelectedIndex() - 1); } } }); setLayout(new BorderLayout()); add(theTabs, BorderLayout.CENTER); graphOptions = new AbstractAction() { public void actionPerformed(ActionEvent e) { GraphOptions graphOptions = options.get(theTabs.getSelectedIndex()); graphOptions.setVisible(true); } }; graphOptions.putValue(Action.NAME, "Graph options"); graphOptions.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_G)); graphOptions.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallOptions.png")); graphOptions.putValue(Action.LONG_DESCRIPTION, "Displays the options dialog for the graph."); zoomIn = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) ((ChartPanel) mgm).zoomInBoth(-1, -1); else if (mgm instanceof Graph3D) { double rho = ((Graph3D) mgm).getChart3DPanel().getViewPoint().getRho(); ((Graph3D) mgm).getChart3DPanel().getViewPoint().setRho(rho - 5); ((Graph3D) mgm).getChart3DPanel().repaint(); } } }; zoomIn.putValue(Action.NAME, "In"); zoomIn.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_I)); zoomIn.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerFwd.png")); zoomIn.putValue(Action.LONG_DESCRIPTION, "Zoom in on the graph."); zoomOut = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) ((ChartPanel) mgm).zoomOutBoth(-1, -1); else if (mgm instanceof Graph3D) { double rho = ((Graph3D) mgm).getChart3DPanel().getViewPoint().getRho(); ((Graph3D) mgm).getChart3DPanel().getViewPoint().setRho(rho + 5); ((Graph3D) mgm).getChart3DPanel().repaint(); } } }; zoomOut.putValue(Action.NAME, "Out"); zoomOut.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_O)); zoomOut.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerRew.png")); zoomOut.putValue(Action.LONG_DESCRIPTION, "Zoom out of the graph."); zoomDefault = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) ((ChartPanel) mgm).restoreAutoBounds(); else if (mgm instanceof Graph3D) { ((Graph3D) mgm).getChart3DPanel().zoomToFit(); ((Graph3D) mgm).getChart3DPanel().getDrawable() .setViewPoint(new ViewPoint3D(-Math.PI / 2, Math.PI * 1.124, 70.0, 0.0)); ((Graph3D) mgm).getChart3DPanel().repaint(); } } }; zoomDefault.putValue(Action.NAME, "Default"); zoomDefault.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); zoomDefault.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPlayerStart.png")); zoomDefault.putValue(Action.LONG_DESCRIPTION, "Set the default zoom for the graph."); importXML = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (plug.showOpenFileDialog(graFilter) != JFileChooser.APPROVE_OPTION) return; try { Graph mgm = Graph.load(plug.getChooserFile()); addGraph(mgm); } catch (GraphException ex) { plug.error("Could not import PRISM graph file:\n" + ex.getMessage()); } } }; importXML.putValue(Action.NAME, "PRISM graph (*.gra)"); importXML.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_I)); importXML.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileGraph.png")); importXML.putValue(Action.LONG_DESCRIPTION, "Imports a saved PRISM graph from a file."); addFunction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { plotNewFunction(); } }; addFunction.putValue(Action.NAME, "Plot function"); addFunction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); addFunction.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFunction.png")); addFunction.putValue(Action.LONG_DESCRIPTION, "Plots a new specified function on the current graph"); exportXML = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (plug.showSaveFileDialog(graFilter) != JFileChooser.APPROVE_OPTION) return; Graph mgm = (Graph) models.get(theTabs.getSelectedIndex()); try { mgm.save(plug.getChooserFile()); } catch (PrismException ex) { plug.error("Could not export PRISM graph file:\n" + ex.getMessage()); } } }; exportXML.putValue(Action.NAME, "PRISM graph (*.gra)"); exportXML.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_X)); exportXML.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileGraph.png")); exportXML.putValue(Action.LONG_DESCRIPTION, "Export graph as a PRISM graph file."); exportImageJPG = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel model = getModel(theTabs.getSelectedIndex()); GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), model, GUIImageExportDialog.JPEG); saveImage(imageDialog); } }; exportImageJPG.putValue(Action.NAME, "JPEG Interchange Format (*.jpg, *.jpeg)"); exportImageJPG.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_J)); exportImageJPG.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileImage.png")); exportImageJPG.putValue(Action.LONG_DESCRIPTION, "Export graph as a JPEG file."); exportImagePNG = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel model = getModel(theTabs.getSelectedIndex()); GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), model, GUIImageExportDialog.PNG); saveImage(imageDialog); } }; exportImagePNG.putValue(Action.NAME, "Portable Network Graphics (*.png)"); exportImagePNG.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); exportImagePNG.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileImage.png")); exportImagePNG.putValue(Action.LONG_DESCRIPTION, "Export graph as a Portable Network Graphics file."); exportPDF = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (plug.showSaveFileDialog(pdfFilter) != JFileChooser.APPROVE_OPTION) return; JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) Graph.exportToPDF(plug.getChooserFile(), ((ChartPanel) mgm).getChart()); else if (mgm instanceof Graph3D) { Graph3D.exportToPDF(plug.getChooserFile(), ((Graph3D) mgm).getChart3DPanel()); } } }; exportPDF.putValue(Action.NAME, "Portable document format (*.pdf)"); exportPDF.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); exportPDF.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFilePdf.png")); exportPDF.putValue(Action.LONG_DESCRIPTION, "Export the graph as a Portable document format file."); exportImageEPS = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel model = getModel(theTabs.getSelectedIndex()); if (model instanceof ChartPanel) { GUIImageExportDialog imageDialog = new GUIImageExportDialog(plug.getGUI(), (ChartPanel) model, GUIImageExportDialog.EPS); saveImage(imageDialog); } } }; exportImageEPS.putValue(Action.NAME, "Encapsulated PostScript (*.eps)"); exportImageEPS.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_E)); exportImageEPS.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFilePdf.png")); exportImageEPS.putValue(Action.LONG_DESCRIPTION, "Export graph as an Encapsulated PostScript file."); exportMatlab = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (plug.showSaveFileDialog(matlabFilter) != JFileChooser.APPROVE_OPTION) return; JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof Graph) { try { ((Graph) mgm).exportToMatlab(plug.getChooserFile()); } catch (IOException ex) { plug.error("Could not export Matlab file:\n" + ex.getMessage()); } } else if (mgm instanceof Graph3D) { try { ((Graph3D) mgm).exportToMatlab(plug.getChooserFile()); } catch (IOException e1) { plug.error("Could not export Matlab file:\n" + e1.getMessage()); e1.printStackTrace(); } } } }; exportMatlab.putValue(Action.NAME, "Matlab file (*.m)"); exportMatlab.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_M)); exportMatlab.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallFileMatlab.png")); exportMatlab.putValue(Action.LONG_DESCRIPTION, "Export graph as a Matlab file."); exportGnuplot = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (plug.showSaveFileDialog(gnuplotFilter) != JFileChooser.APPROVE_OPTION) return; JPanel mgm = models.get(theTabs.getSelectedIndex()); if (mgm instanceof ChartPanel) { try { if (mgm instanceof Graph && !(mgm instanceof ParametricGraph)) { ((Graph) mgm).exportToGnuplot(plug.getChooserFile()); } else if (mgm instanceof ParametricGraph) { ((ParametricGraph) mgm).exportToGnuplot(plug.getChooserFile()); } else if (mgm instanceof Histogram) { ((Histogram) mgm).exportToGnuplot(plug.getChooserFile()); } } catch (IOException ex) { plug.error("Could not export Gnuplot file:\n" + ex.getMessage()); } } else if (mgm instanceof Graph3D) { try { ((Graph3D) mgm).exportToGnuplot(plug.getChooserFile()); } catch (IOException ex) { plug.error("Could not export Gnuplot file:\n" + ex.getMessage()); ex.printStackTrace(); } } } }; exportGnuplot.putValue(Action.NAME, "GNU Plot file(*.gnuplot)"); exportGnuplot.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_G)); exportGnuplot.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallgnuplot.png")); exportGnuplot.putValue(Action.LONG_DESCRIPTION, "Export graph as a GNU plot file."); printGraph = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel graph = models.get(theTabs.getSelectedIndex()); if (graph instanceof ChartPanel) { if (graph instanceof Graph) { if (!((Graph) graph).getDisplaySettings().getBackgroundColor().equals(Color.white)) { if (plug.questionYesNo( "Your graph has a coloured background, this background will show up on the \n" + "printout. Would you like to make the current background colour white?") == 0) { ((Graph) graph).getDisplaySettings().setBackgroundColor(Color.white); } } } else if (graph instanceof Histogram) { if (!((Histogram) graph).getDisplaySettings().getBackgroundColor().equals(Color.white)) { if (plug.questionYesNo( "Your graph has a coloured background, this background will show up on the \n" + "printout. Would you like to make the current background colour white?") == 0) { ((Histogram) graph).getDisplaySettings().setBackgroundColor(Color.white); } } } ((ChartPanel) graph).createChartPrintJob(); } if (graph instanceof Graph3D) { ((Graph3D) graph).createPrintJob(); } } }; printGraph.putValue(Action.NAME, "Print graph"); printGraph.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_P)); printGraph.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallPrint.png")); printGraph.putValue(Action.LONG_DESCRIPTION, "Print the graph to a printer or file"); deleteGraph = new AbstractAction() { public void actionPerformed(ActionEvent e) { JPanel graph = models.get(theTabs.getSelectedIndex()); models.remove(theTabs.getSelectedIndex()); options.remove(theTabs.getSelectedIndex()); theTabs.remove(graph); } }; deleteGraph.putValue(Action.NAME, "Delete graph"); deleteGraph.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_D)); deleteGraph.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallDelete.png")); deleteGraph.putValue(Action.LONG_DESCRIPTION, "Deletes the graph."); zoomMenu = new JMenu("Zoom"); zoomMenu.setMnemonic('Z'); zoomMenu.setIcon(GUIPrism.getIconFromImage("smallView.png")); zoomMenu.add(zoomIn); zoomMenu.add(zoomOut); zoomMenu.add(zoomDefault); exportMenu = new JMenu("Export graph"); exportMenu.setMnemonic('E'); exportMenu.setIcon(GUIPrism.getIconFromImage("smallExport.png")); exportMenu.add(exportXML); exportMenu.add(exportImagePNG); exportMenu.add(exportPDF); exportMenu.add(exportImageEPS); exportMenu.add(exportImageJPG); exportMenu.add(exportMatlab); exportMenu.add(exportGnuplot); importMenu = new JMenu("Import graph"); importMenu.setMnemonic('I'); importMenu.setIcon(GUIPrism.getIconFromImage("smallImport.png")); importMenu.add(importXML); graphMenu.add(graphOptions); graphMenu.add(zoomMenu); graphMenu.addSeparator(); graphMenu.add(printGraph); graphMenu.add(deleteGraph); graphMenu.addSeparator(); graphMenu.add(exportMenu); graphMenu.add(importMenu); graphMenu.add(addFunction); /* Tab context menu */ backMenu.add(importXML); }
From source file:ee.ioc.cs.vsle.editor.Editor.java
/** * Build menu./*from w w w. jav a 2 s . co m*/ */ public void makeMenu() { JMenuItem menuItem; JMenu menu; JMenu submenu; menuBar = new JMenuBar(); setJMenuBar(menuBar); menu = new JMenu(Menu.MENU_FILE); menu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem(Menu.NEW_SCHEME, KeyEvent.VK_N); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Menu.LOAD_SCHEME, KeyEvent.VK_O); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.RELOAD_SCHEME, KeyEvent.VK_R); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK)); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Menu.SAVE_SCHEME, KeyEvent.VK_S); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.SAVE_SCHEME_AS); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Menu.DELETE_SCHEME, KeyEvent.VK_D); menuItem.addActionListener(getActionListener()); menu.add(menuItem); submenu = new JMenu(Menu.EXPORT_MENU); menu.add(submenu); //submenu.setMnemonic( KeyEvent.VK_E ); SchemeExporter.makeSchemeExportMenu(submenu, getActionListener()); // Export window graphics submenu.add(GraphicsExporter.getExportMenu()); menu.addSeparator(); menuItem = new JMenuItem(Menu.PRINT, KeyEvent.VK_P); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK)); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Menu.EXIT, KeyEvent.VK_X); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuBar.add(menu); menu = new JMenu(Menu.MENU_EDIT); menu.setMnemonic(KeyEvent.VK_E); menu.add(undoAction); menu.add(redoAction); menu.add(cloneAction); menuItem = new JMenuItem(Menu.SCHEME_FIND, KeyEvent.VK_F); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.SELECT_ALL, KeyEvent.VK_A); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.CLEAR_ALL, KeyEvent.VK_C); menuItem.addActionListener(getActionListener()); menu.add(menuItem); final JCheckBoxMenuItem painterEnabled = new JCheckBoxMenuItem(Menu.CLASSPAINTER, true); painterEnabled.addActionListener(getActionListener()); menu.add(painterEnabled); menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuCanceled(PopupMenuEvent e) { // ignore } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // ignore } @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { Canvas canvas = Editor.getInstance().getCurrentCanvas(); if (canvas == null || !canvas.getPackage().hasPainters()) { painterEnabled.setVisible(false); } else { painterEnabled.setVisible(true); painterEnabled.setSelected(canvas.isEnableClassPainter()); } } }); menuBar.add(menu); menu = new JMenu(Menu.MENU_VIEW); menu.setMnemonic(KeyEvent.VK_V); gridCheckBox = new JCheckBoxMenuItem(Menu.GRID, RuntimeProperties.isShowGrid()); gridCheckBox.setMnemonic('G'); gridCheckBox.addActionListener(getActionListener()); menu.add(gridCheckBox); ctrlCheckBox = new JCheckBoxMenuItem(Menu.CONTROL_PANEL, RuntimeProperties.isShowControls()); ctrlCheckBox.setMnemonic('C'); ctrlCheckBox.addActionListener(getActionListener()); menu.add(ctrlCheckBox); showPortCheckBox = new JCheckBoxMenuItem(Menu.SHOW_PORTS, true); showPortCheckBox.addActionListener(getActionListener()); menu.add(showPortCheckBox); showObjectNamesCheckBox = new JCheckBoxMenuItem(Menu.SHOW_NAMES, false); showObjectNamesCheckBox.addActionListener(getActionListener()); menu.add(showObjectNamesCheckBox); //sync View with current canvas menu.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { Canvas canvas; if ((canvas = getCurrentCanvas()) == null) return; gridCheckBox.setSelected(canvas.isGridVisible()); ctrlCheckBox.setSelected(canvas.isCtrlPanelVisible()); showPortCheckBox.setSelected(canvas.isDrawPorts()); showObjectNamesCheckBox.setSelected(canvas.isShowObjectNames()); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // ignore } @Override public void popupMenuCanceled(PopupMenuEvent e) { // ignore } }); menuBar.add(menu); menu = new JMenu(Menu.MENU_PACKAGE); menu.setMnemonic(KeyEvent.VK_P); menuItem = new JMenuItem(Menu.LOAD, KeyEvent.VK_L); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.RELOAD, KeyEvent.VK_R); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.INFO, KeyEvent.VK_I); menuItem.addActionListener(getActionListener()); menu.add(menuItem); if (Desktop.isDesktopSupported()) { menuItem = new JMenuItem(Menu.BROWSE_PACKAGE, KeyEvent.VK_B); menuItem.addActionListener(getActionListener()); menu.add(menuItem); } menuItem = new JMenuItem(Menu.CLOSE, KeyEvent.VK_C); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.CLOSE_ALL); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuBar.add(menu); menu.add(new JSeparator()); final JMenu submenuRecent = new JMenu(Menu.RECENT); submenuRecent.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { final JMenuItem empty = new JMenuItem("Empty"); @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { makeRecentSubMenu(submenuRecent); if (submenuRecent.getMenuComponentCount() == 0) { submenuRecent.add(empty); empty.setEnabled(false); } else { if (!((submenuRecent.getMenuComponentCount() == 1) && (submenuRecent.getPopupMenu().getComponentIndex(empty) >= -1))) { submenuRecent.remove(empty); } } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // ignore } @Override public void popupMenuCanceled(PopupMenuEvent e) { // ignore } }); menu.add(submenuRecent); final JMenu menuScheme = new JMenu(Menu.MENU_SCHEME); menuScheme.setMnemonic(KeyEvent.VK_S); makeSchemeMenu(menuScheme); menuScheme.getPopupMenu().addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { makeSchemeMenu(menuScheme); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // ignore } @Override public void popupMenuCanceled(PopupMenuEvent e) { // ignore } }); /* * menuItem = new JMenuItem("Planner"); * menuItem.addActionListener(aListener); menuScheme.add(menuItem); * menuItem = new JMenuItem("Plan, compile, run"); * menuItem.setActionCommand("Run"); * menuItem.addActionListener(aListener); menuScheme.add(menuItem); */ // menuScheme.setMnemonic(KeyEvent.VK_A); menuBar.add(menuScheme); menu = new JMenu(Menu.MENU_OPTIONS); menu.setMnemonic(KeyEvent.VK_O); menuItem = new JMenuItem(Menu.SETTINGS, KeyEvent.VK_S); menuItem.addActionListener(getActionListener()); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, ActionEvent.CTRL_MASK)); menu.add(menuItem); menuItem = new JMenuItem(Menu.FONTS); menuItem.addActionListener(getActionListener()); menu.add(menuItem); menuItem = new JMenuItem(Menu.SAVE_SETTINGS); menuItem.addActionListener(getActionListener()); menu.add(menuItem); submenu = new JMenu(Menu.MENU_LAF); submenu.setMnemonic(KeyEvent.VK_L); Look.getInstance().createMenuItems(submenu); menu.add(submenu); menuBar.add(menu); makeToolsMenu(menuBar); menu = new JMenu(Menu.MENU_HELP); menu.setMnemonic(KeyEvent.VK_H); menuBar.add(menu); menuItem = new JMenuItem(Menu.DOCS, KeyEvent.VK_D); menuItem.addActionListener(getActionListener()); menu.add(menuItem); }
From source file:xtrememp.PlaylistManager.java
private void initComponents() { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false);//from w w w. ja v a 2 s .c o m openPlaylistButton = new JButton(Utilities.DOCUMENT_OPEN_ICON); openPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.OpenPlaylist")); openPlaylistButton.addActionListener(this); toolBar.add(openPlaylistButton); savePlaylistButton = new JButton(Utilities.DOCUMENT_SAVE_ICON); savePlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.SavePlaylist")); savePlaylistButton.addActionListener(this); toolBar.add(savePlaylistButton); toolBar.addSeparator(); addToPlaylistButton = new JButton(Utilities.LIST_ADD_ICON); addToPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.AddToPlaylist")); addToPlaylistButton.addActionListener(this); toolBar.add(addToPlaylistButton); remFromPlaylistButton = new JButton(Utilities.LIST_REMOVE_ICON); remFromPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.RemoveFromPlaylist")); remFromPlaylistButton.addActionListener(this); remFromPlaylistButton.setEnabled(false); toolBar.add(remFromPlaylistButton); clearPlaylistButton = new JButton(Utilities.EDIT_CLEAR_ICON); clearPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.ClearPlaylist")); clearPlaylistButton.addActionListener(this); clearPlaylistButton.setEnabled(false); toolBar.add(clearPlaylistButton); toolBar.addSeparator(); moveUpButton = new JButton(Utilities.GO_UP_ICON); moveUpButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveUp")); moveUpButton.addActionListener(this); moveUpButton.setEnabled(false); toolBar.add(moveUpButton); moveDownButton = new JButton(Utilities.GO_DOWN_ICON); moveDownButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveDown")); moveDownButton.addActionListener(this); moveDownButton.setEnabled(false); toolBar.add(moveDownButton); toolBar.addSeparator(); mediaInfoButton = new JButton(Utilities.MEDIA_INFO_ICON); mediaInfoButton.setToolTipText(tr("MainFrame.PlaylistManager.MediaInfo")); mediaInfoButton.addActionListener(this); mediaInfoButton.setEnabled(false); toolBar.add(mediaInfoButton); toolBar.add(Box.createHorizontalGlue()); searchTextField = new SearchTextField(15); searchTextField.setMaximumSize(new Dimension(120, searchTextField.getPreferredSize().height)); searchTextField.getTextField().getDocument().addDocumentListener(new SearchFilterListener()); toolBar.add(searchTextField); toolBar.add(Box.createHorizontalStrut(6)); this.add(toolBar, BorderLayout.NORTH); playlistTable = new JTable(playlistTableModel, playlistTableColumnModel); playlistTable.setDefaultRenderer(String.class, new PlaylistCellRenderer()); playlistTable.setActionMap(null); playlistTable.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent ev) { if (SwingUtilities.isRightMouseButton(ev) || (MouseInfo.getNumberOfButtons() == 1 && ev.isControlDown())) { playlistTableColumnModel.getPopupMenu().show(playlistTable.getTableHeader(), ev.getX(), ev.getY()); return; } int clickedColumn = playlistTableColumnModel.getColumnIndexAtX(ev.getX()); PlaylistTableColumn playlistColumn = playlistTableColumnModel.getColumn(clickedColumn); playlistTableColumnModel.resetAll(playlistColumn.getModelIndex()); playlistColumn.setSortOrderUp(!playlistColumn.isSortOrderUp()); playlistTableModel.sort(playlistColumn.getComparator()); colorizeRow(); } }); playlistTable.setFillsViewportHeight(true); playlistTable.setShowGrid(false); playlistTable.setRowSelectionAllowed(true); playlistTable.setColumnSelectionAllowed(false); playlistTable.setDragEnabled(false); playlistTable.setFont(playlistTable.getFont().deriveFont(Font.BOLD)); playlistTable.setIntercellSpacing(new Dimension(0, 0)); playlistTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); playlistTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent ev) { int selectedRow = playlistTable.rowAtPoint(ev.getPoint()); if (SwingUtilities.isLeftMouseButton(ev) && ev.getClickCount() == 2) { if (selectedRow != -1) { playlist.setCursorPosition(selectedRow); controlListener.acOpenAndPlay(); } } } }); playlistTable.getSelectionModel().addListSelectionListener(this); playlistTable.getColumnModel().getSelectionModel().addListSelectionListener(this); playlistTable.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { // View Media Info if (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK) { viewMediaInfo(); } // Select all else if (e.getKeyCode() == KeyEvent.VK_A && e.getModifiers() == KeyEvent.CTRL_MASK) { playlistTable.selectAll(); } else if (e.getKeyCode() == KeyEvent.VK_UP) { // Move selected track(s) up if (e.getModifiers() == KeyEvent.ALT_MASK) { moveUp(); } // Select previous track else { if (playlistTable.getSelectedRow() > 0) { int previousRowIndex = playlistTable.getSelectedRow() - 1; playlistTable.clearSelection(); playlistTable.addRowSelectionInterval(previousRowIndex, previousRowIndex); makeRowVisible(previousRowIndex); } } } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { // Move selected track(s) down if (e.getModifiers() == KeyEvent.ALT_MASK) { moveDown(); } // Select next track else { if (playlistTable.getSelectedRow() < playlistTable.getRowCount() - 1) { int nextRowIndex = playlistTable.getSelectedRow() + 1; playlistTable.clearSelection(); playlistTable.addRowSelectionInterval(nextRowIndex, nextRowIndex); makeRowVisible(nextRowIndex); } } } // Play selected track else if (e.getKeyCode() == KeyEvent.VK_ENTER) { int selectedRow = playlistTable.getSelectedRow(); if (selectedRow != -1) { playlist.setCursorPosition(selectedRow); controlListener.acOpenAndPlay(); } } // Add new tracks else if (e.getKeyCode() == KeyEvent.VK_INSERT) { addFilesDialog(false); } // Delete selected tracks else if (e.getKeyCode() == KeyEvent.VK_DELETE) { remove(); } } }); XtremeMP.getInstance().getMainFrame().setDropTarget(new DropTarget(playlistTable, this)); JScrollPane ptScrollPane = new JScrollPane(playlistTable); ptScrollPane.setActionMap(null); this.add(ptScrollPane, BorderLayout.CENTER); }
From source file:org.rdv.ui.MainPanel.java
private void initActions() { fileAction = new DataViewerAction("File", "File Menu", KeyEvent.VK_F); connectAction = new DataViewerAction("Connect", "Connect to RBNB server", KeyEvent.VK_C, KeyStroke.getKeyStroke(KeyEvent.VK_C, menuShortcutKeyMask | ActionEvent.SHIFT_MASK)) { /** serialization version identifier */ private static final long serialVersionUID = 5038790506859429244L; public void actionPerformed(ActionEvent ae) { if (rbnbConnectionDialog == null) { rbnbConnectionDialog = new RBNBConnectionDialog(frame, rbnb, dataPanelManager); } else { rbnbConnectionDialog.setVisible(true); }// www. j a v a 2s. c o m } }; disconnectAction = new DataViewerAction("Disconnect", "Disconnect from RBNB server", KeyEvent.VK_D, KeyStroke.getKeyStroke(KeyEvent.VK_D, menuShortcutKeyMask | ActionEvent.SHIFT_MASK)) { /** serialization version identifier */ private static final long serialVersionUID = -1871076535376405181L; public void actionPerformed(ActionEvent ae) { dataPanelManager.closeAllDataPanels(); rbnb.disconnect(); } }; loginAction = new DataViewerAction("Login", "Login as a NEES user") { /** serialization version identifier */ private static final long serialVersionUID = 6105503896620555072L; public void actionPerformed(ActionEvent ae) { if (loginDialog == null) { loginDialog = new LoginDialog(frame); } else { loginDialog.setVisible(true); } } }; logoutAction = new DataViewerAction("Logout", "Logout as a NEES user") { /** serialization version identifier */ private static final long serialVersionUID = -2517567766044673777L; public void actionPerformed(ActionEvent ae) { AuthenticationManager.getInstance().setAuthentication(null); } }; loadAction = new DataViewerAction("Load Setup", "Load data viewer setup from file") { /** serialization version identifier */ private static final long serialVersionUID = 7197815395398039821L; public void actionPerformed(ActionEvent ae) { File configFile = UIUtilities.getFile(new RDVConfigurationFileFilter(), "Load"); if (configFile != null) { try { URL configURL = configFile.toURI().toURL(); ConfigurationManager.loadConfiguration(configURL); } catch (MalformedURLException e) { DataViewer.alertError("\"" + configFile + "\" is not a valid configuration file URL."); } } } }; saveAction = new DataViewerAction("Save Setup", "Save data viewer setup to file") { /** serialization version identifier */ private static final long serialVersionUID = -8259994975940624038L; public void actionPerformed(ActionEvent ae) { File file = UIUtilities.saveFile(new RDVConfigurationFileFilter()); if (file != null) { if (file.getName().indexOf(".") == -1) { file = new File(file.getAbsolutePath() + ".rdv"); } // prompt for overwrite if file already exists if (file.exists()) { int overwriteReturn = JOptionPane.showConfirmDialog(null, file.getName() + " already exists. Do you want to overwrite it?", "Overwrite file?", JOptionPane.YES_NO_OPTION); if (overwriteReturn == JOptionPane.NO_OPTION) { return; } } ConfigurationManager.saveConfiguration(file); } } }; importAction = new DataViewerAction("Import", "Import Menu", KeyEvent.VK_I, "icons/import.gif"); exportAction = new DataViewerAction("Export", "Export Menu", KeyEvent.VK_E, "icons/export.gif"); exportVideoAction = new DataViewerAction("Export video channels", "Export video on the server to the local computer") { /** serialization version identifier */ private static final long serialVersionUID = -6420430928972633313L; public void actionPerformed(ActionEvent ae) { showExportVideoDialog(); } }; exitAction = new DataViewerAction("Exit", "Exit RDV", KeyEvent.VK_X) { /** serialization version identifier */ private static final long serialVersionUID = 3137490972014710133L; public void actionPerformed(ActionEvent ae) { Application.getInstance().exit(ae); } }; controlAction = new DataViewerAction("Control", "Control Menu", KeyEvent.VK_C); realTimeAction = new DataViewerAction("Real Time", "View data in real time", KeyEvent.VK_R, KeyStroke.getKeyStroke(KeyEvent.VK_R, menuShortcutKeyMask), "icons/rt.gif") { /** serialization version identifier */ private static final long serialVersionUID = -7564783609370910512L; public void actionPerformed(ActionEvent ae) { rbnb.monitor(); } }; playAction = new DataViewerAction("Play", "Playback data", KeyEvent.VK_P, KeyStroke.getKeyStroke(KeyEvent.VK_P, menuShortcutKeyMask), "icons/play.gif") { /** serialization version identifier */ private static final long serialVersionUID = 5974457444931142938L; public void actionPerformed(ActionEvent ae) { rbnb.play(); } }; pauseAction = new DataViewerAction("Pause", "Pause data display", KeyEvent.VK_A, KeyStroke.getKeyStroke(KeyEvent.VK_S, menuShortcutKeyMask), "icons/pause.gif") { /** serialization version identifier */ private static final long serialVersionUID = -5297742186923194460L; public void actionPerformed(ActionEvent ae) { rbnb.pause(); } }; beginningAction = new DataViewerAction("Go to beginning", "Move the location to the start of the data", KeyEvent.VK_B, KeyStroke.getKeyStroke(KeyEvent.VK_B, menuShortcutKeyMask), "icons/begin.gif") { /** serialization version identifier */ private static final long serialVersionUID = 9171304956895497898L; public void actionPerformed(ActionEvent ae) { controlPanel.setLocationBegin(); } }; endAction = new DataViewerAction("Go to end", "Move the location to the end of the data", KeyEvent.VK_E, KeyStroke.getKeyStroke(KeyEvent.VK_E, menuShortcutKeyMask), "icons/end.gif") { /** serialization version identifier */ private static final long serialVersionUID = 1798579248452726211L; public void actionPerformed(ActionEvent ae) { controlPanel.setLocationEnd(); } }; gotoTimeAction = new DataViewerAction("Go to time", "Move the location to specific date time of the data", KeyEvent.VK_T, KeyStroke.getKeyStroke(KeyEvent.VK_T, menuShortcutKeyMask)) { /** serialization version identifier */ private static final long serialVersionUID = -6411442297488926326L; public void actionPerformed(ActionEvent ae) { TimeRange timeRange = RBNBHelper.getChannelsTimeRange(); double time = DateTimeDialog.showDialog(frame, rbnb.getLocation(), timeRange.start, timeRange.end); if (time >= 0) { rbnb.setLocation(time); } } }; updateChannelListAction = new DataViewerAction("Update Channel List", "Update the channel list", KeyEvent.VK_U, KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), "icons/refresh.gif") { /** serialization version identifier */ private static final long serialVersionUID = -170096772973697277L; public void actionPerformed(ActionEvent ae) { rbnb.updateMetadata(); } }; dropDataAction = new DataViewerAction("Drop Data", "Drop data if plaback can't keep up with data rate", KeyEvent.VK_D, "icons/drop_data.gif") { /** serialization version identifier */ private static final long serialVersionUID = 7079791364881120134L; public void actionPerformed(ActionEvent ae) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource(); rbnb.dropData(menuItem.isSelected()); } }; viewAction = new DataViewerAction("View", "View Menu", KeyEvent.VK_V); showChannelListAction = new DataViewerAction("Show Channels", "", KeyEvent.VK_L, "icons/channels.gif") { /** serialization version identifier */ private static final long serialVersionUID = 4982129759386009112L; public void actionPerformed(ActionEvent ae) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource(); channelListPanel.setVisible(menuItem.isSelected()); layoutSplitPane(); leftPanel.resetToPreferredSizes(); } }; showMetadataPanelAction = new DataViewerAction("Show Properties", "", KeyEvent.VK_P, "icons/properties.gif") { /** serialization version identifier */ private static final long serialVersionUID = 430106771704397810L; public void actionPerformed(ActionEvent ae) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource(); metadataPanel.setVisible(menuItem.isSelected()); layoutSplitPane(); leftPanel.resetToPreferredSizes(); } }; showControlPanelAction = new DataViewerAction("Show Control Panel", "", KeyEvent.VK_C, "icons/control.gif") { /** serialization version identifier */ private static final long serialVersionUID = 6401715717710735485L; public void actionPerformed(ActionEvent ae) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource(); controlPanel.setVisible(menuItem.isSelected()); } }; showAudioPlayerPanelAction = new DataViewerAction("Show Audio Player", "", KeyEvent.VK_A, "icons/audio.gif") { /** serialization version identifier */ private static final long serialVersionUID = -4248275698973916287L; public void actionPerformed(ActionEvent ae) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource(); audioPlayerPanel.setVisible(menuItem.isSelected()); } }; showMarkerPanelAction = new DataViewerAction("Show Marker Panel", "", KeyEvent.VK_M, "icons/info.gif") { /** serialization version identifier */ private static final long serialVersionUID = -5253555511660929640L; public void actionPerformed(ActionEvent ae) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource(); markerSubmitPanel.setVisible(menuItem.isSelected()); } }; dataPanelAction = new DataViewerAction("Arrange", "Arrange Data Panel Orientation", KeyEvent.VK_D); dataPanelHorizontalLayoutAction = new DataViewerAction("Horizontal Data Panel Orientation", "", -1, "icons/vertical.gif") { /** serialization version identifier */ private static final long serialVersionUID = 3356151813557187908L; public void actionPerformed(ActionEvent ae) { dataPanelContainer.setLayout(DataPanelContainer.VERTICAL_LAYOUT); } }; dataPanelVerticalLayoutAction = new DataViewerAction("Vertical Data Panel Orientation", "", -1, "icons/horizontal.gif") { /** serialization version identifier */ private static final long serialVersionUID = -4629920180285927138L; public void actionPerformed(ActionEvent ae) { dataPanelContainer.setLayout(DataPanelContainer.HORIZONTAL_LAYOUT); } }; showHiddenChannelsAction = new DataViewerAction("Show Hidden Channels", "", KeyEvent.VK_H, KeyStroke.getKeyStroke(KeyEvent.VK_H, menuShortcutKeyMask), "icons/hidden.gif") { /** serialization version identifier */ private static final long serialVersionUID = -2723464261568074033L; public void actionPerformed(ActionEvent ae) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource(); boolean selected = menuItem.isSelected(); channelListPanel.showHiddenChannels(selected); } }; hideEmptyTimeAction = new DataViewerAction("Hide time with no data", "", KeyEvent.VK_D) { /** serialization version identifier */ private static final long serialVersionUID = -3123608144249355642L; public void actionPerformed(ActionEvent ae) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource(); boolean selected = menuItem.isSelected(); controlPanel.hideEmptyTime(selected); } }; fullScreenAction = new DataViewerAction("Full Screen", "", KeyEvent.VK_F, KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0)) { /** serialization version identifier */ private static final long serialVersionUID = -6882310862616235602L; public void actionPerformed(ActionEvent ae) { JCheckBoxMenuItem menuItem = (JCheckBoxMenuItem) ae.getSource(); if (menuItem.isSelected()) { if (enterFullScreenMode()) { menuItem.setSelected(true); } else { menuItem.setSelected(false); } } else { leaveFullScreenMode(); menuItem.setSelected(false); } } }; windowAction = new DataViewerAction("Window", "Window Menu", KeyEvent.VK_W); closeAllDataPanelsAction = new DataViewerAction("Close all data panels", "", KeyEvent.VK_C, "icons/closeall.gif") { /** serialization version identifier */ private static final long serialVersionUID = -8104876009869238037L; public void actionPerformed(ActionEvent ae) { dataPanelManager.closeAllDataPanels(); } }; helpAction = new DataViewerAction("Help", "Help Menu", KeyEvent.VK_H); usersGuideAction = new DataViewerAction("RDV Help", "Open the RDV User's Guide", KeyEvent.VK_H, KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)) { /** serialization version identifier */ private static final long serialVersionUID = -2837190869008153291L; public void actionPerformed(ActionEvent ae) { try { URL usersGuideURL = new URL("http://it.nees.org/library/telepresence/rdv-19-users-guide.php"); DataViewer.browse(usersGuideURL); } catch (Exception e) { } } }; supportAction = new DataViewerAction("RDV Support", "Get support from NEESit", KeyEvent.VK_S) { /** serialization version identifier */ private static final long serialVersionUID = -6855670513381679226L; public void actionPerformed(ActionEvent ae) { try { URL supportURL = new URL("http://it.nees.org/support/"); DataViewer.browse(supportURL); } catch (Exception e) { } } }; releaseNotesAction = new DataViewerAction("Release Notes", "Open the RDV Release Notes", KeyEvent.VK_R) { /** serialization version identifier */ private static final long serialVersionUID = 7223639998298692494L; public void actionPerformed(ActionEvent ae) { try { URL releaseNotesURL = new URL("http://it.nees.org/library/rdv/rdv-release-notes.php"); DataViewer.browse(releaseNotesURL); } catch (Exception e) { } } }; aboutAction = new DataViewerAction("About RDV", "", KeyEvent.VK_A) { /** serialization version identifier */ private static final long serialVersionUID = 3978467903181198979L; public void actionPerformed(ActionEvent ae) { showAboutDialog(); } }; }