List of usage examples for java.awt.event ActionEvent SHIFT_MASK
int SHIFT_MASK
To view the source code for java.awt.event ActionEvent SHIFT_MASK.
Click Source Link
From source file:edu.brown.gui.CatalogViewer.java
/** * /*w ww . ja va2 s.c o m*/ */ protected void viewerInit() { // ---------------------------------------------- // MENU // ---------------------------------------------- JMenu menu; JMenuItem menuItem; // // File Menu // menu = new JMenu("File"); menu.getPopupMenu().setLightWeightPopupEnabled(false); menu.setMnemonic(KeyEvent.VK_F); menu.getAccessibleContext().setAccessibleDescription("File Menu"); menuBar.add(menu); menuItem = new JMenuItem("Open Catalog From File"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From File"); menuItem.addActionListener(this.menuHandler); menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_FILE); menu.add(menuItem); menuItem = new JMenuItem("Open Catalog From Jar"); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From Project Jar"); menuItem.addActionListener(this.menuHandler); menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_JAR); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem("Quit", KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Quit Program"); menuItem.addActionListener(this.menuHandler); menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.QUIT); menu.add(menuItem); // ---------------------------------------------- // CATALOG TREE PANEL // ---------------------------------------------- this.catalogTree = new JTree(); this.catalogTree.setEditable(false); this.catalogTree.setCellRenderer(new CatalogViewer.CatalogTreeRenderer()); this.catalogTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); this.catalogTree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) CatalogViewer.this.catalogTree .getLastSelectedPathComponent(); if (node == null) return; Object user_obj = node.getUserObject(); String new_text = ""; // <html>"; boolean text_mode = true; if (user_obj instanceof WrapperNode) { CatalogType catalog_obj = ((WrapperNode) user_obj).getCatalogType(); new_text += CatalogViewer.this.getAttributesText(catalog_obj); } else if (user_obj instanceof AttributesNode) { AttributesNode wrapper = (AttributesNode) user_obj; new_text += wrapper.getAttributes(); } else if (user_obj instanceof PlanTreeCatalogNode) { final PlanTreeCatalogNode wrapper = (PlanTreeCatalogNode) user_obj; text_mode = false; CatalogViewer.this.mainPanel.remove(0); CatalogViewer.this.mainPanel.add(wrapper.getPanel(), BorderLayout.CENTER); CatalogViewer.this.mainPanel.validate(); CatalogViewer.this.mainPanel.repaint(); if (SwingUtilities.isEventDispatchThread() == false) { SwingUtilities.invokeLater(new Runnable() { public void run() { wrapper.centerOnRoot(); } }); } else { wrapper.centerOnRoot(); } } else { new_text += CatalogViewer.this.getSummaryText(); } // Text Mode if (text_mode) { if (CatalogViewer.this.text_mode == false) { CatalogViewer.this.mainPanel.remove(0); CatalogViewer.this.mainPanel.add(CatalogViewer.this.textInfoPanel); } CatalogViewer.this.textInfoTextArea.setText(new_text); // Scroll to top CatalogViewer.this.textInfoTextArea.grabFocus(); } CatalogViewer.this.text_mode = text_mode; } }); this.generateCatalogTree(this.catalog, this.catalog_file_path.getName()); // // Text Information Panel // this.textInfoPanel = new JPanel(); this.textInfoPanel.setLayout(new BorderLayout()); this.textInfoTextArea = new JTextArea(); this.textInfoTextArea.setEditable(false); this.textInfoTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); this.textInfoTextArea.setText(this.getSummaryText()); this.textInfoTextArea.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { // TODO Auto-generated method stub } @Override public void focusGained(FocusEvent e) { CatalogViewer.this.scrollTextInfoToTop(); } }); this.textInfoScroller = new JScrollPane(this.textInfoTextArea); this.textInfoPanel.add(this.textInfoScroller, BorderLayout.CENTER); this.mainPanel = new JPanel(new BorderLayout()); this.mainPanel.add(textInfoPanel, BorderLayout.CENTER); // // Search Toolbar // JPanel searchPanel = new JPanel(); searchPanel.setLayout(new BorderLayout()); JPanel innerSearchPanel = new JPanel(); innerSearchPanel.setLayout(new BoxLayout(innerSearchPanel, BoxLayout.X_AXIS)); innerSearchPanel.add(new JLabel("Search: ")); this.searchField = new JTextField(30); innerSearchPanel.add(this.searchField); searchPanel.add(innerSearchPanel, BorderLayout.EAST); this.searchField.addKeyListener(new KeyListener() { private String last = null; @Override public void keyReleased(KeyEvent e) { String value = CatalogViewer.this.searchField.getText().toLowerCase().trim(); if (!value.isEmpty() && (this.last == null || !this.last.equals(value))) { CatalogViewer.this.search(value); } this.last = value; } @Override public void keyTyped(KeyEvent e) { // Do nothing... } @Override public void keyPressed(KeyEvent e) { // Do nothing... } }); // Putting it all together JScrollPane scrollPane = new JScrollPane(this.catalogTree); JPanel topPanel = new JPanel(); topPanel.setLayout(new BorderLayout()); topPanel.add(searchPanel, BorderLayout.NORTH); topPanel.add(scrollPane, BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, topPanel, this.mainPanel); splitPane.setDividerLocation(400); this.add(splitPane, BorderLayout.CENTER); }
From source file:com.diversityarrays.kdxplore.trialmgr.TrialManagerApp.java
public TrialManagerApp(KdxPluginInfo pluginInfo) throws IOException { super(new BorderLayout()); this.messagesPanel = pluginInfo.getMessagePrinter(); this.backgroundRunner = pluginInfo.getBackgroundRunner(); this.userDataFolder = pluginInfo.getUserDataFolder(); this.clientProvider = pluginInfo.getClientProvider(); this.offlineData = pluginInfo.getSingletonSharedResource(OfflineData.class); KDSmartApplication.getInstance().setMessagePrinter(pluginInfo.getMessagePrintStream()); this.driverType = DriverType.getDriverTypeFromSystemProperties(DriverType.H2); offlineData.addOfflineDataChangeListener(offlineDataChangeListener); linkedIcon = KDClientUtils.getIcon(ImageId.CONNECTED_24); unlinkedIcon = KDClientUtils.getIcon(ImageId.DISCONNECTED_24); barcodeIcon = KDClientUtils.getIcon(ImageId.BARCODE_PAGE); updateDatabaseUrlLabel();/*from w w w . j a va 2 s .c o m*/ this.clientProvider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { handleClientChanged(); } }); explorerProperties = ExplorerProperties.getInstance(); PreferenceCollection pc = TrialManagerPreferences.getInstance().getPreferenceCollection(this, Msg.APPNAME_TRIAL_MANAGER()); KdxplorePreferences.getInstance().addPreferenceCollection(pc); TraitValue.DISPLAY_DATE_DIFF_AS_NDAYS = explorerProperties.getDisplayElapsedDaysAsCount(); ExplorerServices explorerServices = new ExplorerServices(pluginInfo, offlineData // , clientProvider ); trialExplorerPanel = new TrialExplorerPanel(this, // KdxApp pluginInfo, explorerServices.getKdxDeviceService(), this, // as TrialExplorerManager offlineData, driverType, barcodeIcon, clientUrlChanger, trialsLoadedConsumer, traitRemovalHandler); tabbedPane.addTab(TAB_TRIALS, KDClientUtils.getIcon(ImageId.KDS_TRIALS), trialExplorerPanel); Transformer<Trial, Boolean> checkIfEditorIsActive = new Transformer<Trial, Boolean>() { @Override public Boolean transform(Trial trial) { return trialExplorerPanel.isEditorActiveForTrial(trial); } }; traitExplorerPanel = new TraitExplorerPanel(messagesPanel, offlineData, clientProvider, // uploadHandler, backgroundRunner, barcodeIcon, checkIfEditorIsActive); tabbedPane.addTab(TAB_TRAITS, KDClientUtils.getIcon(ImageId.KDS_TRAITS), traitExplorerPanel); tagExplorerPanel = new TagExplorerPanel(offlineData); tabbedPane.addTab(TAB_TAGS, KDClientUtils.getIcon(ImageId.BLACK_TAG), tagExplorerPanel); // Now tie together those panels that need to talk to each other trialExplorerPanel.setTraitExplorer(traitExplorerPanel); Box box = Box.createHorizontalBox(); explorerServices.addActions(box); box.add(Box.createHorizontalGlue()); box.add(databaseUrlLabel); box.add(Box.createHorizontalGlue()); Action action = offlineData.getOfflineDataAction(); if (action != null) { JButton button = new JButton(pluginInfo.getKdxploreIcon()); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (RunMode.getRunMode().isDeveloper()) { if (0 != (ActionEvent.SHIFT_MASK & e.getModifiers())) { openJdbcExplorer(); return; } } action.actionPerformed(e); } }); box.add(button); } add(box, BorderLayout.NORTH); add(tabbedPane, BorderLayout.CENTER); }
From source file:com.emental.mindraider.ui.frames.MindRaiderMainWindow.java
/** * Build main menu./*w w w . j a va 2s. co m*/ * * @param spiders */ private void buildMenu(final SpidersGraph spiders) { JMenuBar menuBar; JMenu menu, submenu; JMenuItem menuItem, subMenuItem; JRadioButtonMenuItem rbMenuItem; // create the menu bar menuBar = new JMenuBar(); setJMenuBar(menuBar); // - main menu ------------------------------------------------------- menu = new JMenu(MindRaiderConstants.MR_TITLE); menu.setMnemonic(KeyEvent.VK_M); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.setActiveNotebookAsHome")); menuItem.setMnemonic(KeyEvent.VK_H); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.profile.setHomeNotebook(); } }); menu.add(menuItem); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.preferences")); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new PreferencesJDialog(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.exit"), KeyEvent.VK_X); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { exitMindRaider(); } }); menu.add(menuItem); menuBar.add(menu); // - Find ---------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.search")); menu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchNotebooks")); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new OpenOutlineJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchFulltext")); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new FtsJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchConceptsInNotebook")); menuItem.setMnemonic(KeyEvent.VK_C); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutlineUri() != null) { new OpenNoteJDialog(); } } }); menu.add(menuItem); // search by tag menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchConceptsByTag")); menuItem.setEnabled(true); menuItem.setMnemonic(KeyEvent.VK_T); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new OpenConceptByTagJDialog(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.previousNote")); menuItem.setEnabled(true); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.recentConcepts.moveOneNoteBack(); } }); menu.add(menuItem); // global RDF search // menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchRdql")); // menuItem.setEnabled(false); // menuItem.setMnemonic(KeyEvent.VK_R); // menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, // ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); // menuItem.addActionListener(new ActionListener() { // // public void actionPerformed(ActionEvent e) { // // TODO rdql to be implemented // } // }); // menu.add(menuItem); menuBar.add(menu); // - view ------------------------------------------------------------ menu = new JMenu(Messages.getString("MindRaiderJFrame.view")); menu.setMnemonic(KeyEvent.VK_V); // TODO localize L&F menu ButtonGroup lfGroup = new ButtonGroup(); submenu = new JMenu(Messages.getString("MindRaiderJFrame.lookAndFeel")); logger.debug("Look and feel is: " + MindRaider.profile.getLookAndFeel()); // {{debug}} submenu.setMnemonic(KeyEvent.VK_L); subMenuItem = new JRadioButtonMenuItem(Messages.getString("MindRaiderJFrame.lookAndFeelNative")); if (MindRaider.LF_NATIVE.equals(MindRaider.profile.getLookAndFeel())) { subMenuItem.setSelected(true); } subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel(MindRaider.LF_NATIVE); } }); submenu.add(subMenuItem); lfGroup.add(subMenuItem); subMenuItem = new JRadioButtonMenuItem(Messages.getString("MindRaiderJFrame.lookAndFeelJava")); if (MindRaider.LF_JAVA_DEFAULT.equals(MindRaider.profile.getLookAndFeel())) { subMenuItem.setSelected(true); } subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel(MindRaider.LF_JAVA_DEFAULT); } }); submenu.add(subMenuItem); lfGroup.add(subMenuItem); menu.add(submenu); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.leftSideBar")); menuItem.setMnemonic(KeyEvent.VK_L); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (leftSidebarSplitPane.getDividerLocation() == 1) { leftSidebarSplitPane.resetToPreferredSizes(); } else { closeLeftSidebar(); } } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rightSideBar")); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().toggleRightSidebar(); } }); menu.add(menuItem); // TODO tips to be implemented // JCheckBoxMenuItem helpCheckbox=new JCheckBoxMenuItem("Tips",true); // menu.add(helpCheckbox); // TODO localize menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.toolbar")); menuItem.setMnemonic(KeyEvent.VK_T); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.masterToolBar.toggleVisibility(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rdfNavigatorDashboard")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.spidersGraph.getGlPanel().toggleControlPanel(); } }); menu.add(menuItem); JCheckBoxMenuItem checkboxMenuItem; ButtonGroup colorSchemeGroup; // if (!MindRaider.OUTLINER_PERSPECTIVE.equals(MindRaider.profile // .getUiPerspective())) { menu.addSeparator(); // Facets submenu = new JMenu(Messages.getString("MindRaiderJFrame.facet")); submenu.setMnemonic(KeyEvent.VK_F); colorSchemeGroup = new ButtonGroup(); String[] facetLabels = FacetCustodian.getInstance().getFacetLabels(); if (!ArrayUtils.isEmpty(facetLabels)) { for (String facetLabel : facetLabels) { rbMenuItem = new JRadioButtonMenuItem(facetLabel); rbMenuItem.addActionListener(new FacetActionListener(facetLabel)); colorSchemeGroup.add(rbMenuItem); submenu.add(rbMenuItem); if (BriefFacet.LABEL.equals(facetLabel)) { rbMenuItem.setSelected(true); } } } menu.add(submenu); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.graphLabelAsUri")); checkboxMenuItem.setMnemonic(KeyEvent.VK_G); checkboxMenuItem.setState(MindRaider.spidersGraph.isUriLabels()); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); MindRaider.spidersGraph.setUriLabels(j.getState()); MindRaider.spidersGraph.renderModel(); MindRaider.profile.setGraphShowLabelsAsUris(j.getState()); MindRaider.profile.save(); } } }); menu.add(checkboxMenuItem); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.predicateNodes")); checkboxMenuItem.setMnemonic(KeyEvent.VK_P); checkboxMenuItem.setState(!MindRaider.spidersGraph.getHidePredicates()); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); MindRaider.spidersGraph.hidePredicates(!j.getState()); MindRaider.spidersGraph.renderModel(); MindRaider.profile.setGraphHidePredicates(!j.getState()); MindRaider.profile.save(); } } }); menu.add(checkboxMenuItem); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.multilineLabels")); checkboxMenuItem.setMnemonic(KeyEvent.VK_M); checkboxMenuItem.setState(MindRaider.spidersGraph.isMultilineNodes()); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); MindRaider.spidersGraph.setMultilineNodes(j.getState()); MindRaider.spidersGraph.renderModel(); MindRaider.profile.setGraphMultilineLabels(j.getState()); MindRaider.profile.save(); } } }); menu.add(checkboxMenuItem); // } menu.addSeparator(); // Antialias checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.antiAliased"), true); checkboxMenuItem.setMnemonic(KeyEvent.VK_A); checkboxMenuItem.setState(SpidersGraph.antialiased); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); SpidersGraph.antialiased = j.getState(); MindRaider.spidersGraph.renderModel(); } } }); menu.add(checkboxMenuItem); // Enable hyperbolic checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.hyperbolic"), true); checkboxMenuItem.setMnemonic(KeyEvent.VK_H); checkboxMenuItem.setState(SpidersGraph.hyperbolic); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); SpidersGraph.hyperbolic = j.getState(); MindRaider.spidersGraph.renderModel(); } } }); menu.add(checkboxMenuItem); // Show FPS checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.fps"), true); checkboxMenuItem.setMnemonic(KeyEvent.VK_F); checkboxMenuItem.setState(SpidersGraph.fps); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); SpidersGraph.fps = j.getState(); MindRaider.spidersGraph.renderModel(); } } }); menu.add(checkboxMenuItem); // Graph color scheme submenu = new JMenu(Messages.getString("MindRaiderJFrame.colorScheme")); submenu.setMnemonic(KeyEvent.VK_C); String[] allProfilesUris = MindRaider.spidersColorProfileRegistry.getAllProfilesUris(); colorSchemeGroup = new ButtonGroup(); for (int i = 0; i < allProfilesUris.length; i++) { rbMenuItem = new UriJRadioButtonMenuItem( MindRaider.spidersColorProfileRegistry.getColorProfileByUri(allProfilesUris[i]).getLabel(), allProfilesUris[i]); rbMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof UriJRadioButtonMenuItem) { MindRaider.spidersColorProfileRegistry .setCurrentProfile(((UriJRadioButtonMenuItem) e.getSource()).uri); MindRaider.spidersGraph .setRenderingProfile(MindRaider.spidersColorProfileRegistry.getCurrentProfile()); MindRaider.spidersGraph.renderModel(); } } }); colorSchemeGroup.add(rbMenuItem); submenu.add(rbMenuItem); } menu.add(submenu); // Annotation color scheme submenu = new JMenu(Messages.getString("MindRaiderJFrame.colorSchemeAnnotation")); submenu.setMnemonic(KeyEvent.VK_A); allProfilesUris = MindRaider.annotationColorProfileRegistry.getAllProfilesUris(); colorSchemeGroup = new ButtonGroup(); for (int i = 0; i < allProfilesUris.length; i++) { rbMenuItem = new UriJRadioButtonMenuItem( MindRaider.annotationColorProfileRegistry.getColorProfileByUri(allProfilesUris[i]).getLabel(), allProfilesUris[i]); rbMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof UriJRadioButtonMenuItem) { MindRaider.annotationColorProfileRegistry .setCurrentProfile(((UriJRadioButtonMenuItem) e.getSource()).uri); OutlineJPanel.getInstance().conceptJPanel.refresh(); } } }); colorSchemeGroup.add(rbMenuItem); submenu.add(rbMenuItem); } menu.add(submenu); menu.addSeparator(); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.fullScreen")); checkboxMenuItem.setMnemonic(KeyEvent.VK_U); checkboxMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0)); checkboxMenuItem.setState(false); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); if (j.getState()) { Gfx.toggleFullScreen(MindRaiderMainWindow.this); } else { Gfx.toggleFullScreen(null); } } } }); menu.add(checkboxMenuItem); menuBar.add(menu); // - outline // ---------------------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.notebook")); menu.setMnemonic(KeyEvent.VK_N); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.newNotebook")); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO clear should be optional - only if creation finished // MindRider.spidersGraph.clear(); new NewOutlineJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.open")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new OpenOutlineJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.close")); menuItem.setMnemonic(KeyEvent.VK_C); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.outlineCustodian.close(); OutlineJPanel.getInstance().refresh(); MindRaider.spidersGraph.renderModel(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.discard")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.setEnabled(false); // TODO discard method must be implemented menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int result = JOptionPane.showConfirmDialog(MindRaiderMainWindow.this, Messages.getString( "MindRaiderJFrame.confirmDiscardNotebook", MindRaider.profile.getActiveOutline())); if (result == JOptionPane.YES_OPTION) { if (MindRaider.profile.getActiveOutlineUri() != null) { try { MindRaider.labelCustodian .discardOutline(MindRaider.profile.getActiveOutlineUri().toString()); MindRaider.outlineCustodian.close(); } catch (Exception e1) { logger.error(Messages.getString("MindRaiderJFrame.unableToDiscardNotebook"), e1); } } } } }); menu.add(menuItem); menu.addSeparator(); // export submenu = new JMenu(Messages.getString("MindRaiderJFrame.export")); submenu.setMnemonic(KeyEvent.VK_E); // Atom subMenuItem = new JMenuItem("Atom"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exportActiveOutlineToAtom(); } }); submenu.add(subMenuItem); // OPML subMenuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.opml")); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutline() == null) { JOptionPane.showMessageDialog(MindRaiderMainWindow.this, Messages.getString("MindRaiderJFrame.exportNotebookWarning"), Messages.getString("MindRaiderJFrame.exportError"), JOptionPane.ERROR_MESSAGE); return; } JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export" + File.separator + "opml"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { String dstFileName = fc.getSelectedFile().getAbsolutePath() + File.separator + "OPML-EXPORT-" + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".xml"; logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName)); MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_OPML, dstFileName); Launcher.launchViaStart(dstFileName); } else { logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser")); } } }); submenu.add(subMenuItem); // TWiki subMenuItem = new JMenuItem("TWiki"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutline() == null) { JOptionPane.showMessageDialog(MindRaiderMainWindow.this, Messages.getString("MindRaiderJFrame.exportNotebookWarning"), Messages.getString("MindRaiderJFrame.exportError"), JOptionPane.ERROR_MESSAGE); return; } JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export" + File.separator + "twiki"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final String dstFileName = fc.getSelectedFile().getAbsolutePath() + File.separator + "TWIKI-EXPORT-" + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".txt"; logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName)); MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_TWIKI, dstFileName); } else { logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser")); } } }); submenu.add(subMenuItem); menu.add(submenu); // import submenu = new JMenu(Messages.getString("MindRaiderJFrame.import")); submenu.setMnemonic(KeyEvent.VK_I); subMenuItem = new JMenuItem("Atom"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { importFromAtom(); } }); submenu.add(subMenuItem); // TWiki subMenuItem = new JMenuItem("TWiki"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // choose file to be transformed OutlineJPanel.getInstance().clear(); MindRaider.profile.setActiveOutlineUri(null); JFileChooser fc = new JFileChooser(); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final File file = fc.getSelectedFile(); MindRaider.profile.deleteActiveModel(); logger.debug( Messages.getString("MindRaiderJFrame.importingTWikiTopic", file.getAbsolutePath())); // perform it async final SwingWorker worker = new SwingWorker() { public Object construct() { ProgressDialogJFrame progressDialogJFrame = new ProgressDialogJFrame( Messages.getString("MindRaiderJFrame.twikiImport"), Messages.getString("MindRaiderJFrame.processingTopicTWiki")); try { MindRaider.outlineCustodian.importNotebook(OutlineCustodian.FORMAT_TWIKI, (file != null ? file.getAbsolutePath() : null), progressDialogJFrame); } finally { if (progressDialogJFrame != null) { progressDialogJFrame.dispose(); } } return null; } }; worker.start(); } else { logger.debug(Messages.getString("MindRaiderJFrame.openCommandCancelledByUser")); } } }); submenu.add(subMenuItem); menu.add(submenu); menuBar.add(menu); // - note // ---------------------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.concept")); menu.setMnemonic(KeyEvent.VK_C); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.new")); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().newConcept(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.open")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutlineUri() != null) { new OpenNoteJDialog(); } } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.discard")); // do not accelerate this command with DEL - it's already handled // elsewhere menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptDiscard(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.up")); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptUp(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.promote")); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptPromote(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.demote")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptDemote(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.down")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptDown(); } }); menu.add(menuItem); menuBar.add(menu); // - Tools ----------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.tools")); menu.setMnemonic(KeyEvent.VK_T); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.checkAndFix")); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Checker.checkAndFixRepositoryAsync(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.backupRepository")); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Installer.backupRepositoryAsync(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rebuildSearchIndex")); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SearchCommander.rebuildSearchAndTagIndices(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.captureScreen")); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.screenshot")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseScreenshotDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "Screenshots"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final String filename = fc.getSelectedFile().getAbsolutePath() + File.separator + "screenshot.jpg"; // do it in async (redraw screen) Thread thread = new Thread() { public void run() { OutputStream file = null; try { file = new FileOutputStream(filename); Robot robot = new Robot(); robot.delay(1000); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(file); encoder.encode(robot.createScreenCapture( new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()))); } catch (Exception e1) { logger.error("Unable to capture screen!", e1); } finally { if (file != null) { try { file.close(); } catch (IOException e1) { logger.error("Unable to close stream", e1); } } } } }; thread.setDaemon(true); thread.start(); } } }); menu.add(menuItem); menuBar.add(menu); // - MindForger ----------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderMainWindow.menuMindForger")); menu.setMnemonic(KeyEvent.VK_O); //menu.setIcon(IconsRegistry.getImageIcon("tasks-internet.png")); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerVideoTutorial")); menuItem.setMnemonic(KeyEvent.VK_G); menuItem.setToolTipText("http://mindraider.sourceforge.net/mindforger.html"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://mindraider.sourceforge.net/mindforger.html"); } }); menuItem.setEnabled(true); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.signUp")); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.setToolTipText("http://www.mindforger.com"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://www.mindforger.com"); } }); menuItem.setEnabled(true); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerUpload")); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // fork in order to enable status updates in the main window new MindForgerUploadOutlineJDialog(); } }); menuItem.setEnabled(true); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerDownload")); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { downloadAnOutlineFromMindForger(); } }); menuItem.setEnabled(true); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerMyOutlines")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setEnabled(true); menuItem.setToolTipText("http://web.mindforger.com"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://web.mindforger.com"); } }); menu.add(menuItem); menuBar.add(menu); // - align Help on right ------------------------------------------------------------- menuBar.add(Box.createHorizontalGlue()); // - help ------------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.help")); menu.setMnemonic(KeyEvent.VK_H); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.documentation")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { MindRaider.outlineCustodian.loadOutline(new URI(MindRaiderVocabulary .getNotebookUri(OutlineCustodian.MR_DOC_NOTEBOOK_DOCUMENTATION_LOCAL_NAME))); OutlineJPanel.getInstance().refresh(); } catch (Exception e1) { logger.error(Messages.getString("MindRaiderJFrame.unableToLoadHelp", e1.getMessage())); } } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.webHomepage")); menuItem.setMnemonic(KeyEvent.VK_H); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://mindraider.sourceforge.net"); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.reportBug")); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://sourceforge.net/forum/?group_id=128454"); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.updateCheck")); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // just open html page at: // http://mindraider.sourceforge.net/update-7.2.html // this page will either contain "you have the last version" or will ask user to // download the latest version from main page Launcher.launchInBrowser("http://mindraider.sourceforge.net/" + "update-" + MindRaiderConstants.majorVersion + "." + MindRaiderConstants.minorVersion + ".html"); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.about", MindRaiderConstants.MR_TITLE)); menuItem.setMnemonic(KeyEvent.VK_A); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AboutJDialog(); } }); menu.add(menuItem); menuBar.add(menu); }
From source file:ch.fork.AdHocRailway.ui.AdHocRailway.java
private void initMenu() { menuBar = new JMenuBar(); /* FILE *//*from w w w. j a v a2 s . c o m*/ final JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); final JMenuItem newItem = new JMenuItem(new NewFileAction()); newItem.setMnemonic(KeyEvent.VK_N); newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); final JMenuItem openItem = new JMenuItem(new OpenFileAction()); openItem.setMnemonic(KeyEvent.VK_O); openItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); final JMenuItem openDatabaseItem = new JMenuItem(new OpenDatabaseAction()); saveItem = new JMenuItem(new SaveAction()); saveItem.setMnemonic(KeyEvent.VK_S); saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); saveAsItem = new JMenuItem(new SaveAsAction()); saveAsItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); final JMenuItem importAllItem = new JMenuItem(new ImportAllAction()); final JMenuItem importLocomotivesItem = new JMenuItem(new ImportLocomotivesAction()); final JMenuItem exportLocomotivesItem = new JMenuItem(new ExportLocomotivesAction()); final JMenuItem exportAllItem = new JMenuItem(new ExportAllAction()); final JMenu importMenu = new JMenu("Import"); importMenu.add(importAllItem); importMenu.add(importLocomotivesItem); final JMenu exportMenu = new JMenu("Export"); exportMenu.add(exportLocomotivesItem); exportMenu.add(exportAllItem); final JMenuItem clearLocomotivesItem = new JMenuItem(new ClearLocomotivesAction()); final JMenuItem clearTurnoutsRoutesItem = new JMenuItem(new ClearTurnoutsAndRoutesAction()); final JMenu clearMenu = new JMenu("Clear"); clearMenu.add(clearLocomotivesItem); clearMenu.add(clearTurnoutsRoutesItem); final JMenuItem exitItem = new JMenuItem(new ExitAction()); exitItem.setMnemonic(KeyEvent.VK_X); exitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); fileMenu.add(newItem); fileMenu.add(openItem); fileMenu.add(openDatabaseItem); fileMenu.add(saveItem); fileMenu.add(saveAsItem); fileMenu.add(new JSeparator()); fileMenu.add(importMenu); fileMenu.add(exportMenu); fileMenu.add(clearMenu); fileMenu.add(new JSeparator()); fileMenu.add(exitItem); /* EDIT */ final JMenu editMenu = new JMenu("Edit"); enableEditing = new JCheckBoxMenuItem(new EnableEditingAction()); switchesItem = new JMenuItem(new TurnoutAction()); routesItem = new JMenuItem(new RoutesAction()); locomotivesItem = new JMenuItem(new LocomotivesAction()); preferencesItem = new JMenuItem(new PreferencesAction()); enableEditing.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.ALT_MASK)); switchesItem.setMnemonic(KeyEvent.VK_T); switchesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.ALT_MASK)); routesItem.setMnemonic(KeyEvent.VK_R); routesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.ALT_MASK)); locomotivesItem.setMnemonic(KeyEvent.VK_L); locomotivesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L, ActionEvent.ALT_MASK)); preferencesItem.setMnemonic(KeyEvent.VK_P); preferencesItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK)); editMenu.add(enableEditing); editMenu.add(new JSeparator()); editMenu.add(switchesItem); editMenu.add(routesItem); editMenu.add(locomotivesItem); editMenu.add(new JSeparator()); editMenu.add(preferencesItem); /* DAEMON */ final JMenu daemonMenu = new JMenu("Device"); daemonConnectItem = new JMenuItem(new ConnectAction()); daemonConnectItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK)); daemonDisconnectItem = new JMenuItem(new DisconnectAction()); daemonPowerOnItem = new JMenuItem(new PowerOnAction()); assignAccelerator(daemonPowerOnItem, "PowerOn"); daemonPowerOnItem.setEnabled(true); daemonPowerOffItem = new JMenuItem(new PowerOffAction()); assignAccelerator(daemonPowerOffItem, "PowerOff"); daemonPowerOffItem.setEnabled(true); daemonDisconnectItem.setEnabled(false); daemonMenu.add(daemonConnectItem); daemonMenu.add(daemonDisconnectItem); daemonMenu.add(new JSeparator()); daemonMenu.add(daemonPowerOnItem); daemonMenu.add(daemonPowerOffItem); /* VIEW */ final JMenu viewMenu = new JMenu("View"); final JMenuItem refreshItem = new JMenuItem(new RefreshAction()); final JMenuItem fullscreenItem = new JMenuItem(new ToggleFullscreenAction()); viewMenu.add(refreshItem); viewMenu.add(fullscreenItem); /* HELP */ // JMenu helpMenu = new JMenu("Help"); addMenu(fileMenu); addMenu(editMenu); addMenu(daemonMenu); addMenu(viewMenu); // addMenu(helpMenu); setJMenuBar(menuBar); }
From source file:com.net2plan.gui.tools.GUINetworkDesign.java
private void addAllKeyCombinationActions() { addKeyCombinationAction("Resets the tool", new AbstractAction() { @Override/*www. ja v a 2 s .c o m*/ public void actionPerformed(ActionEvent e) { resetButton(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Outputs current design to console", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { System.out.println(getDesign().toString()); } }, KeyStroke.getKeyStroke(KeyEvent.VK_F11, InputEvent.CTRL_DOWN_MASK)); /* FROM THE OFFLINE ALGORITHM EXECUTION */ addKeyCombinationAction("Execute algorithm", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { executionPane.doClickInExecutionButton(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK)); /* From the TOPOLOGY PANEL */ addKeyCombinationAction("Load design", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { topologyPanel.loadDesign(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Save design", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { topologyPanel.saveDesign(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Zoom in", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0) topologyPanel.getCanvas().zoomIn(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ADD, InputEvent.CTRL_DOWN_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Zoom out", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0) topologyPanel.getCanvas().zoomOut(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, InputEvent.CTRL_DOWN_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Zoom all", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (topologyPanel.getSize().getWidth() != 0 && topologyPanel.getSize().getHeight() != 0) topologyPanel.getCanvas().zoomAll(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_MULTIPLY, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Take snapshot", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { topologyPanel.takeSnapshot(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Load traffic demands", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { topologyPanel.loadTrafficDemands(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)); /* FROM REPORT */ addKeyCombinationAction("Close selected report", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { int tab = reportPane.getReportContainer().getSelectedIndex(); if (tab == -1) return; reportPane.getReportContainer().remove(tab); } }, KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK)); addKeyCombinationAction("Close all reports", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { reportPane.getReportContainer().removeAll(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); /* Online simulation */ addKeyCombinationAction("Run simulation", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { try { if (onlineSimulationPane.isRunButtonEnabled()) onlineSimulationPane.runSimulation(false); } catch (Net2PlanException ex) { if (ErrorHandling.isDebugEnabled()) ErrorHandling.addErrorOrException(ex, OnlineSimulationPane.class); ErrorHandling.showErrorDialog(ex.getMessage(), "Error executing simulation"); } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, OnlineSimulationPane.class); ErrorHandling.showErrorDialog("An error happened"); } } }, KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK)); // Windows addKeyCombinationAction("Show control window", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { WindowController.showTablesWindow(true); } }, KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK + ActionEvent.SHIFT_MASK)); viewEditTopTables.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); viewEditTopTables.setActionMap(this.getActionMap()); reportPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); reportPane.setActionMap(this.getActionMap()); executionPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); executionPane.setActionMap(this.getActionMap()); onlineSimulationPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); onlineSimulationPane.setActionMap(this.getActionMap()); whatIfAnalysisPane.setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)); whatIfAnalysisPane.setActionMap(this.getActionMap()); }
From source file:de.huxhorn.lilith.swing.ApplicationPreferences.java
public boolean isReplacingOnApply(ActionEvent event) { // TODO make default behavior configurable. boolean result = false; if (event == null || (ActionEvent.SHIFT_MASK & event.getModifiers()) == 0) { result = true;/* w w w . j av a2s . c om*/ } return result; }
From source file:org.executequery.gui.browser.FindAction.java
public void actionPerformed(ActionEvent e) { if (e.getSource() == searchField) popup.setVisible(false);/*from w w w.j ava 2 s. c o m*/ else { // component = (JComponent) e.getSource(); ignoreCase = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; searchField.removeActionListener(this); searchField.removeKeyListener(this); searchField.getDocument().removeDocumentListener(this); initSearch(e); searchField.addActionListener(this); searchField.addKeyListener(this); searchField.getDocument().addDocumentListener(this); clearResultsListData(); Rectangle rect = component.getVisibleRect(); // popup.show(comp, rect.x = 5, rect.y - popup.getPreferredSize().height // - 10); popup.show(component, rect.x = 80, rect.y); searchField.requestFocus(); } }
From source file:org.pentaho.reporting.designer.core.actions.global.ScreenCaptureAction.java
public static void saveScreenShot(final int modifiers) { final Component component = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); final GraphicsConfiguration graphicsConfiguration = component.getGraphicsConfiguration(); final GraphicsDevice graphicsDevice = graphicsConfiguration.getDevice(); try {//from www .j a v a2s. co m final Robot robot = new Robot(graphicsDevice); final BufferedImage image; if ((modifiers & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK) { image = robot.createScreenCapture(graphicsConfiguration.getBounds()); } else { image = robot.createScreenCapture(component.getBounds()); } final String homeDirectory = ReportDesignerBoot.getInstance().getGlobalConfig() .getConfigProperty("user.home", "."); final File homeDir = new File(homeDirectory); final File f = generateName(homeDir); if (f == null) { return; } final FileOutputStream fout = new FileOutputStream(f); try { final PngEncoder encoder = new PngEncoder(); encoder.setCompressionLevel(6); encoder.setEncodeAlpha(false); encoder.setImage(image); final byte[] bytes = encoder.pngEncode(); fout.write(bytes); } finally { fout.close(); } } catch (IOException ioe) { UncaughtExceptionsModel.getInstance().addException(ioe); } catch (AWTException e1) { // ignore UncaughtExceptionsModel.getInstance().addException(e1); } }
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); }//from w w w. ja va2 s . 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(); } }; }
From source file:org.tinymediamanager.ui.movies.MoviePanel.java
private void buildMenu() { menu.setMnemonic(KeyEvent.VK_M); // menu items JMenuItem menuItem = menu.add(actionUpdateDataSources2); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.setAccelerator(//www . j a v a 2s . co m KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); final JMenu menuUpdateDatasources = new JMenu(BUNDLE.getString("update.datasource")); //$NON-NLS-1$ final JMenu menuFindMissingMovies = new JMenu(BUNDLE.getString("movie.findmissing")); //$NON-NLS-1$ menuUpdateDatasources.addMenuListener(new MenuListener() { @Override public void menuCanceled(MenuEvent arg0) { } @Override public void menuDeselected(MenuEvent arg0) { } @Override public void menuSelected(MenuEvent arg0) { menuUpdateDatasources.removeAll(); menuFindMissingMovies.removeAll(); for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) { JMenuItem item = new JMenuItem(new MovieUpdateSingleDatasourceAction(ds)); menuUpdateDatasources.add(item); item = new JMenuItem(new MovieFindMissingAction(ds)); menuFindMissingMovies.add(item); } } }); menu.add(menuUpdateDatasources); menu.add(new MovieFindMissingAction()); menu.add(menuFindMissingMovies); menu.add(new MovieCreateOfflineAction(true)); menu.addSeparator(); JMenu menuScrape = new JMenu(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$ menuScrape.setMnemonic(KeyEvent.VK_S); menuItem = menuScrape.add(actionScrape2); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuScrape.add(actionScrapeSelected); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuScrape.add(actionScrapeUnscraped); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuScrape.add(actionScrapeMetadataSelected); menuItem.setMnemonic(KeyEvent.VK_M); menuScrape.add(actionAssignMovieSets); menu.add(menuScrape); JMenu menuEdit = new JMenu(BUNDLE.getString("Button.edit")); //$NON-NLS-1$ menuEdit.setMnemonic(KeyEvent.VK_E); menuItem = menuEdit.add(actionEditMovie2); menuItem.setMnemonic(KeyEvent.VK_E); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionBatchEdit); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionSetWatchedFlag); menuItem.setMnemonic(KeyEvent.VK_W); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionRename2); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menuEdit.add(actionRenamerPreview); menuItem.setMnemonic(KeyEvent.VK_P); menu.add(menuEdit); menuItem = menu.add(actionRewriteNfo); menuItem.setMnemonic(KeyEvent.VK_N); menuItem = menu.add(actionTrailerDownload); menuItem = menu.add(actionSearchSubtitle); menuItem = menu.add(actionDownloadSubtitle); menu.addSeparator(); menuItem = menu.add(actionMediaInformation2); menuItem.setMnemonic(KeyEvent.VK_M); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionExport); menuItem.setMnemonic(KeyEvent.VK_X); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK)); menuItem = menu.add(actionRemove2); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.setAccelerator(KeyStroke.getKeyStroke((char) KeyEvent.VK_DELETE)); menuItem = menu.add(actionDelete2); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK)); menu.addSeparator(); menuItem = menu.add(actionSyncTrakt); menuItem.setMnemonic(KeyEvent.VK_T); menuItem = menu.add(actionSyncWatchedTrakt); menuItem.setMnemonic(KeyEvent.VK_W); menuItem = menu.add(actionSyncSelectedTrakt); menu.addSeparator(); menuItem = menu.add(actionClearImageCache); menuItem.setMnemonic(KeyEvent.VK_C); // popup menu JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(actionScrape2); popupMenu.add(actionScrapeSelected); popupMenu.add(actionScrapeUnscraped); popupMenu.add(actionScrapeMetadataSelected); popupMenu.add(actionAssignMovieSets); popupMenu.addSeparator(); popupMenu.add(actionEditMovie2); popupMenu.add(actionBatchEdit); popupMenu.add(actionSetWatchedFlag); popupMenu.add(actionRewriteNfo); popupMenu.add(actionRename2); popupMenu.add(actionRenamerPreview); popupMenu.add(actionMediaInformation2); popupMenu.add(actionExport); popupMenu.add(actionTrailerDownload); popupMenu.add(actionSearchSubtitle); popupMenu.add(actionDownloadSubtitle); popupMenu.addSeparator(); popupMenu.add(actionSyncTrakt); popupMenu.add(actionSyncWatchedTrakt); popupMenu.add(actionSyncSelectedTrakt); popupMenu.addSeparator(); popupMenu.add(actionClearImageCache); popupMenu.addSeparator(); popupMenu.add(actionRemove2); popupMenu.add(actionDelete2); if (Globals.isDebug()) { JMenu menuDebug = new JMenu("Debug"); //$NON-NLS-1$ menuDebug.add(debugDumpMovie); menuDebug.addSeparator(); menuDebug.add(new FakeTmmTaskAction("download", 1, 10)); menuDebug.add(new FakeTmmTaskAction("download", 10, 10)); menuDebug.add(new FakeTmmTaskAction("image", 1, 10)); menuDebug.add(new FakeTmmTaskAction("image", 10, 10)); menuDebug.add(new FakeTmmTaskAction("unnamed", 1, 10)); menuDebug.add(new FakeTmmTaskAction("unnamed", 10, 10)); popupMenu.add(menuDebug); } MouseListener mouseListener = new MovieTableMouseListener(popupMenu, table); table.addMouseListener(mouseListener); }