List of usage examples for java.awt.event KeyEvent VK_S
int VK_S
To view the source code for java.awt.event KeyEvent VK_S.
Click Source Link
From source file:org.orbisgis.view.beanshell.BshConsolePanel.java
/** * Create actions instances//from w ww. j a v a 2s .com * * Each action is put in the Popup menu and the tool bar * Their shortcuts are registered also in the editor */ private void initActions() { //Execute action executeAction = new DefaultAction(BeanShellAction.A_EXECUTE, I18N.tr("Execute"), I18N.tr("Execute the java script"), OrbisGISIcon.getIcon("execute"), EventHandler.create(ActionListener.class, this, "onExecute"), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK)); actions.addAction(executeAction); //Clear action clearAction = new DefaultAction(BeanShellAction.A_CLEAR, I18N.tr("Clear"), I18N.tr("Erase the content of the editor"), OrbisGISIcon.getIcon("erase"), EventHandler.create(ActionListener.class, this, "onClear"), null); actions.addAction(clearAction); //Open action actions.addAction( new DefaultAction(BeanShellAction.A_OPEN, I18N.tr("Open"), I18N.tr("Load a file in this editor"), OrbisGISIcon.getIcon("open"), EventHandler.create(ActionListener.class, this, "onOpenFile"), KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK))); //Save saveAction = new DefaultAction(BeanShellAction.A_SAVE, I18N.tr("Save"), I18N.tr("Save the editor content into a file"), OrbisGISIcon.getIcon("save"), EventHandler.create(ActionListener.class, this, "onSaveFile"), KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); actions.addAction(saveAction); //Find action findAction = new DefaultAction(BeanShellAction.A_SEARCH, I18N.tr("Search.."), I18N.tr("Search text in the document"), OrbisGISIcon.getIcon("find"), EventHandler.create(ActionListener.class, this, "openFindReplaceDialog"), KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK)) .addStroke(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK)); actions.addAction(findAction); }
From source file:com.AandR.beans.plotting.imagePlotPanel.CanvasPanel.java
private void createPopupMenu() { popupMenu = new JPopupMenu(); popupMenu.add(createPopupMenuItem("Toggle Log Plot", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, 0))); popupMenu.add(createPopupMenuItem("Slice Here", null, KeyStroke.getKeyStroke(KeyEvent.VK_C, 10))); popupMenu.addSeparator();//from w w w.j a v a 2 s . c om JMenu navigateMenu = new JMenu("Navigate"); navigateMenu.add(createPopupMenuItem("View First Frame", null, KeyStroke.getKeyStroke(KeyEvent.VK_F, 2))); navigateMenu .add(createPopupMenuItem("View Previous Frame", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, 2))); navigateMenu .add(createPopupMenuItem("Choose Frame To View", null, KeyStroke.getKeyStroke(KeyEvent.VK_C, 2))); navigateMenu.add(createPopupMenuItem("View Next Frame", null, KeyStroke.getKeyStroke(KeyEvent.VK_N, 2))); navigateMenu.add(createPopupMenuItem("View Last Frame", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, 2))); popupMenu.add(navigateMenu); popupMenu.addSeparator(); popupMenu.add(createPopupMenuItem("Set Zoom Level", null, KeyStroke.getKeyStroke(KeyEvent.VK_Z, 2))); popupMenu.add(createPopupMenuItem("Set Min/Max", null, KeyStroke.getKeyStroke(KeyEvent.VK_R, 2))); popupMenu.add(createPopupMenuItem("Set Physical Extent", null, KeyStroke.getKeyStroke(KeyEvent.VK_E, 2))); popupMenu.addSeparator(); popupMenu.add(createPopupMenuItem("Recenter on Viewport", null, KeyStroke.getKeyStroke(KeyEvent.VK_C, 0))); popupMenu.addSeparator(); popupMenu.add(createPopupMenuItem("Set Colormap", null, KeyStroke.getKeyStroke(KeyEvent.VK_M, 2))); popupMenu.addSeparator(); JMenu overlayMenu = new JMenu("Overlays"); overlayMenu.add(createPopupMenuItem("Add Text Overlay", null, KeyStroke.getKeyStroke(KeyEvent.VK_T, 2))); overlayMenu.add(createPopupMenuItem("Add Shape Overlay", null, KeyStroke.getKeyStroke(KeyEvent.VK_O, 2))); overlayMenu.add(createPopupMenuItem("Add Annulus Overlay", null, KeyStroke.getKeyStroke(KeyEvent.VK_U, 2))); overlayMenu.add(createPopupMenuItem("Add Arrow Overlay", null, KeyStroke.getKeyStroke(KeyEvent.VK_A, 2))); popupMenu.add(overlayMenu); popupMenu.addSeparator(); JMenu pngMenu = new JMenu("To PNG"); pngMenu.add(createPopupMenuItem("Export Original Image", null, KeyStroke.getKeyStroke(KeyEvent.VK_S, 10))); pngMenu.add(createPopupMenuItem("Export Viewport Image", null, KeyStroke.getKeyStroke(KeyEvent.VK_S, 2))); pngMenu.addSeparator(); pngMenu.add(createPopupMenuItem("Export Viewport Series", null, KeyStroke.getKeyStroke(KeyEvent.VK_S, 8))); JMenu pdfMenu = new JMenu("To PDF"); pdfMenu.add(createPopupMenuItem("Export Original Image", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK))); pdfMenu.add(createPopupMenuItem("Export Viewport Image", null, KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.ALT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK))); JMenu exportMenu = new JMenu("Export"); exportMenu.add(pngMenu); exportMenu.add(pdfMenu); popupMenu.add(exportMenu); popupMenu.addSeparator(); JMenu losslessMenu = new JMenu("Lossless Modifications"); losslessMenu.add(createPopupMenuItem("Flip Horizontally", null, KeyStroke.getKeyStroke(KeyEvent.VK_H, 10))); losslessMenu.add(createPopupMenuItem("Flip Vertically", null, KeyStroke.getKeyStroke(KeyEvent.VK_V, 10))); losslessMenu.addSeparator(); losslessMenu.add(createPopupMenuItem("Rotate +90", null, KeyStroke.getKeyStroke(KeyEvent.VK_R, 10))); losslessMenu.add(createPopupMenuItem("Rotate -90", null, KeyStroke.getKeyStroke(KeyEvent.VK_L, 10))); popupMenu.add(losslessMenu); }
From source file:com.mirth.connect.client.ui.components.rsta.MirthRSyntaxTextArea.java
public MirthRSyntaxTextArea(ContextType contextType, String styleKey, boolean autoCompleteEnabled) { super(new MirthRSyntaxDocument(styleKey)); this.contextType = contextType; setBackground(UIConstants.BACKGROUND_COLOR); setSyntaxEditingStyle(styleKey);// w w w. j a v a 2 s .co m setCodeFoldingEnabled(true); setAntiAliasingEnabled(true); setWrapStyleWord(true); setAutoIndentEnabled(true); // Add a document listener so that the save button is enabled whenever changes are made. getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { onChange(); } @Override public void removeUpdate(DocumentEvent e) { onChange(); } @Override public void insertUpdate(DocumentEvent e) { onChange(); } private void onChange() { if (saveEnabled) { PlatformUI.MIRTH_FRAME.setSaveEnabled(true); } } }); addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (saveEnabled) { boolean isAccelerated = (((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) > 0) || ((e.getModifiers() & InputEvent.CTRL_MASK) > 0)); if ((e.getKeyCode() == KeyEvent.VK_S) && isAccelerated) { PlatformUI.MIRTH_FRAME.doContextSensitiveSave(); } } } }); undoMenuItem = new CustomMenuItem(this, new UndoAction(), ActionInfo.UNDO); redoMenuItem = new CustomMenuItem(this, new RedoAction(), ActionInfo.REDO); cutMenuItem = new CustomMenuItem(this, new CutAction(this), ActionInfo.CUT); copyMenuItem = new CustomMenuItem(this, new CopyAction(this), ActionInfo.COPY); pasteMenuItem = new CustomMenuItem(this, new PasteAction(), ActionInfo.PASTE); deleteMenuItem = new CustomMenuItem(this, new DeleteAction(), ActionInfo.DELETE); selectAllMenuItem = new CustomMenuItem(this, new SelectAllAction(), ActionInfo.SELECT_ALL); findReplaceMenuItem = new CustomMenuItem(this, new FindReplaceAction(this), ActionInfo.FIND_REPLACE); findNextMenuItem = new CustomMenuItem(this, new FindNextAction(this), ActionInfo.FIND_NEXT); clearMarkedOccurrencesMenuItem = new CustomMenuItem(this, new ClearMarkedOccurrencesAction(this), ActionInfo.CLEAR_MARKED_OCCURRENCES); foldingMenu = new JMenu("Folding"); collapseFoldMenuItem = new CustomMenuItem(this, new CollapseFoldAction(), ActionInfo.FOLD_COLLAPSE); expandFoldMenuItem = new CustomMenuItem(this, new ExpandFoldAction(), ActionInfo.FOLD_EXPAND); collapseAllFoldsMenuItem = new CustomMenuItem(this, new CollapseAllFoldsAction(), ActionInfo.FOLD_COLLAPSE_ALL); collapseAllCommentFoldsMenuItem = new CustomMenuItem(this, new CollapseAllCommentFoldsAction(), ActionInfo.FOLD_COLLAPSE_ALL_COMMENTS); expandAllFoldsMenuItem = new CustomMenuItem(this, new ExpandAllFoldsAction(), ActionInfo.FOLD_EXPAND_ALL); displayMenu = new JMenu("Display"); showTabLinesMenuItem = new CustomJCheckBoxMenuItem(this, new ShowTabLinesAction(this), ActionInfo.DISPLAY_SHOW_TAB_LINES); showWhitespaceMenuItem = new CustomJCheckBoxMenuItem(this, new ShowWhitespaceAction(this), ActionInfo.DISPLAY_SHOW_WHITESPACE); showLineEndingsMenuItem = new CustomJCheckBoxMenuItem(this, new ShowLineEndingsAction(this), ActionInfo.DISPLAY_SHOW_LINE_ENDINGS); wrapLinesMenuItem = new CustomJCheckBoxMenuItem(this, new WrapLinesAction(this), ActionInfo.DISPLAY_WRAP_LINES); macroMenu = new JMenu("Macro"); beginMacroMenuItem = new CustomMenuItem(this, new BeginMacroAction(), ActionInfo.MACRO_BEGIN); endMacroMenuItem = new CustomMenuItem(this, new EndMacroAction(), ActionInfo.MACRO_END); playbackMacroMenuItem = new CustomMenuItem(this, new PlaybackMacroAction(), ActionInfo.MACRO_PLAYBACK); viewUserAPIMenuItem = new CustomMenuItem(this, new ViewUserAPIAction(this), ActionInfo.VIEW_USER_API); // Add actions that wont be in the popup menu getActionMap().put(ActionInfo.DELETE_REST_OF_LINE.getActionMapKey(), new DeleteRestOfLineAction()); getActionMap().put(ActionInfo.DELETE_LINE.getActionMapKey(), new DeleteLineAction()); getActionMap().put(ActionInfo.JOIN_LINE.getActionMapKey(), new JoinLineAction()); getActionMap().put(ActionInfo.GO_TO_MATCHING_BRACKET.getActionMapKey(), new GoToMatchingBracketAction()); getActionMap().put(ActionInfo.TOGGLE_COMMENT.getActionMapKey(), new ToggleCommentAction()); getActionMap().put(ActionInfo.DOCUMENT_START.getActionMapKey(), new DocumentStartAction(false)); getActionMap().put(ActionInfo.DOCUMENT_SELECT_START.getActionMapKey(), new DocumentStartAction(true)); getActionMap().put(ActionInfo.DOCUMENT_END.getActionMapKey(), new DocumentEndAction(false)); getActionMap().put(ActionInfo.DOCUMENT_SELECT_END.getActionMapKey(), new DocumentEndAction(true)); getActionMap().put(ActionInfo.LINE_START.getActionMapKey(), new LineStartAction(false)); getActionMap().put(ActionInfo.LINE_SELECT_START.getActionMapKey(), new LineStartAction(true)); getActionMap().put(ActionInfo.LINE_END.getActionMapKey(), new LineEndAction(false)); getActionMap().put(ActionInfo.LINE_SELECT_END.getActionMapKey(), new LineEndAction(true)); getActionMap().put(ActionInfo.MOVE_LEFT.getActionMapKey(), new MoveLeftAction(false)); getActionMap().put(ActionInfo.MOVE_LEFT_SELECT.getActionMapKey(), new MoveLeftAction(true)); getActionMap().put(ActionInfo.MOVE_LEFT_WORD.getActionMapKey(), new MoveLeftWordAction(false)); getActionMap().put(ActionInfo.MOVE_LEFT_WORD_SELECT.getActionMapKey(), new MoveLeftWordAction(true)); getActionMap().put(ActionInfo.MOVE_RIGHT.getActionMapKey(), new MoveRightAction(false)); getActionMap().put(ActionInfo.MOVE_RIGHT_SELECT.getActionMapKey(), new MoveRightAction(true)); getActionMap().put(ActionInfo.MOVE_RIGHT_WORD.getActionMapKey(), new MoveRightWordAction(false)); getActionMap().put(ActionInfo.MOVE_RIGHT_WORD_SELECT.getActionMapKey(), new MoveRightWordAction(true)); getActionMap().put(ActionInfo.MOVE_UP.getActionMapKey(), new MoveUpAction(false)); getActionMap().put(ActionInfo.MOVE_UP_SELECT.getActionMapKey(), new MoveUpAction(true)); getActionMap().put(ActionInfo.MOVE_UP_SCROLL.getActionMapKey(), new ScrollAction(true)); getActionMap().put(ActionInfo.MOVE_UP_LINE.getActionMapKey(), new MoveLineAction(true)); getActionMap().put(ActionInfo.MOVE_DOWN.getActionMapKey(), new MoveDownAction(false)); getActionMap().put(ActionInfo.MOVE_DOWN_SELECT.getActionMapKey(), new MoveDownAction(true)); getActionMap().put(ActionInfo.MOVE_DOWN_SCROLL.getActionMapKey(), new ScrollAction(false)); getActionMap().put(ActionInfo.MOVE_DOWN_LINE.getActionMapKey(), new MoveLineAction(false)); getActionMap().put(ActionInfo.PAGE_UP.getActionMapKey(), new PageUpAction(false)); getActionMap().put(ActionInfo.PAGE_UP_SELECT.getActionMapKey(), new PageUpAction(true)); getActionMap().put(ActionInfo.PAGE_LEFT_SELECT.getActionMapKey(), new HorizontalPageAction(this, true)); getActionMap().put(ActionInfo.PAGE_DOWN.getActionMapKey(), new PageDownAction(false)); getActionMap().put(ActionInfo.PAGE_DOWN_SELECT.getActionMapKey(), new PageDownAction(true)); getActionMap().put(ActionInfo.PAGE_RIGHT_SELECT.getActionMapKey(), new HorizontalPageAction(this, false)); getActionMap().put(ActionInfo.INSERT_LF_BREAK.getActionMapKey(), new InsertBreakAction("\n")); getActionMap().put(ActionInfo.INSERT_CR_BREAK.getActionMapKey(), new InsertBreakAction("\r")); List<Action> actionList = new ArrayList<Action>(); for (Object key : getActionMap().allKeys()) { actionList.add(getActionMap().get(key)); } actions = actionList.toArray(new Action[actionList.size()]); if (autoCompleteEnabled) { LanguageSupportFactory.get().register(this); // Remove the default auto-completion trigger since we handle that ourselves getInputMap().remove(AutoCompletion.getDefaultTriggerKey()); } }
From source file:javazoom.jlgui.player.amp.StandalonePlayer.java
/** * Install keyboard shortcuts./* ww w . j a va2 s .c o m*/ */ public void setKeyBoardShortcut() { KeyStroke jKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_J, 0, false); KeyStroke ctrlPKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK, false); KeyStroke altSKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.ALT_MASK, false); KeyStroke vKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V, 0, false); String searchID = "TAGSEARCH"; String preferenceID = "PREFERENCES"; String skinbrowserID = "SKINBROWSER"; String stopplayerID = "STOPPLAYER"; Action searchAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (mp != null) mp.processJumpToFile(e.getModifiers()); } }; Action preferencesAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (mp != null) mp.processPreferences(e.getModifiers()); } }; Action skinbrowserAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (mp != null) mp.processSkinBrowser(e.getModifiers()); } }; Action stopplayerAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (mp != null) mp.processStop(MouseEvent.BUTTON1_MASK); } }; setKeyboardAction(searchID, jKeyStroke, searchAction); setKeyboardAction(preferenceID, ctrlPKeyStroke, preferencesAction); setKeyboardAction(skinbrowserID, altSKeyStroke, skinbrowserAction); setKeyboardAction(stopplayerID, vKeyStroke, stopplayerAction); }
From source file:org.wandora.application.gui.topicpanels.ProcessingTopicPanel.java
@Override public void init() { Wandora wandora = Wandora.getWandora(); if (options == null) { if (USE_LOCAL_OPTIONS) { options = new Options(wandora.getOptions()); } else {//from w w w . j a v a 2s .co m options = wandora.getOptions(); } } tm = wandora.getTopicMap(); initComponents(); this.addComponentListener(this); try { // JavaSyntaxKit syntaxKit = new JavaSyntaxKit(); // syntaxKit.install(processingEditor); DefaultSyntaxKit.initKit(); processingEditor.setContentType("text/java"); } catch (Exception e) { e.printStackTrace(); } /* EditorKit ek=processingEditor.getEditorKit(); if(ek instanceof DefaultSyntaxKit){ DefaultSyntaxKit sk=(DefaultSyntaxKit)ek; sk.setProperty("Action.parenthesis", null); sk.setProperty("Action.brackets", null); sk.setProperty("Action.quotes", null); sk.setProperty("Action.double-quotes", null); sk.setProperty("Action.close-curly", null); }*/ readOptions(); KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK); processingEditor.getInputMap().put(key, "saveOperation"); Action saveOperation = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { saveCurrentSketch(); } }; processingEditor.getActionMap().put("saveOperation", saveOperation); processingEditor.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n"); innerPanel.addComponentListener(new ComponentListener() { @Override public void componentResized(ComponentEvent e) { revalidate(); Wandora.getWandora().validate(); } @Override public void componentMoved(ComponentEvent e) { revalidate(); Wandora.getWandora().validate(); } @Override public void componentShown(ComponentEvent e) { revalidate(); Wandora.getWandora().validate(); } @Override public void componentHidden(ComponentEvent e) { revalidate(); Wandora.getWandora().validate(); } }); if (currentSketch != null) { processingEditor.setText(currentSketch); } else { processingEditor.setText(defaultMessage); } FileNameExtensionFilter sketchFilter = new FileNameExtensionFilter("Processing sketch files", "sketch"); fc = new JFileChooser(); fc.setFileFilter(sketchFilter); fc.setCurrentDirectory(new File(sketchPath)); }
From source file:com.digitalgeneralists.assurance.ui.MainWindow.java
private void initializeComponent() { if (!this.initialized) { logger.info("Initializing the main window."); if (AssuranceUtils.getPlatform() == Platform.MAC) { System.setProperty("apple.laf.useScreenMenuBar", "true"); com.apple.eawt.Application macApplication = com.apple.eawt.Application.getApplication(); MacApplicationAdapter macAdapter = new MacApplicationAdapter(this); macApplication.addApplicationListener(macAdapter); macApplication.setEnabledPreferencesMenu(true); }//from w w w .j av a 2 s . co m this.setTitle(Application.applicationShortName); this.setDefaultCloseOperation(EXIT_ON_CLOSE); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); this.topArea = new JTabbedPane(); this.scanLaunchPanel.setPreferredSize(new Dimension(600, 150)); this.scanHistoryPanel.setPreferredSize(new Dimension(600, 150)); this.topArea.addTab("Scan", this.scanLaunchPanel); this.topArea.addTab("History", this.scanHistoryPanel); this.resultsPanel.setPreferredSize(new Dimension(600, 400)); this.topArea.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { resultsPanel.resetPanel(); // NOTE: This isn't ideal. It feels brittle. if (topArea.getSelectedIndex() == viewHistoryMenuItemIndex) { viewHistoryMenuItem.setSelected(true); } else { viewScanMenuItem.setSelected(true); } } }); GridBagConstraints topPanelConstraints = new GridBagConstraints(); topPanelConstraints.anchor = GridBagConstraints.NORTH; topPanelConstraints.fill = GridBagConstraints.BOTH; topPanelConstraints.gridx = 0; topPanelConstraints.gridy = 0; topPanelConstraints.weightx = 1.0; topPanelConstraints.weighty = 0.33; topPanelConstraints.gridheight = 1; topPanelConstraints.gridwidth = 1; topPanelConstraints.insets = new Insets(0, 0, 0, 0); this.getContentPane().add(this.topArea, topPanelConstraints); GridBagConstraints resultsPanelConstraints = new GridBagConstraints(); resultsPanelConstraints.anchor = GridBagConstraints.SOUTH; resultsPanelConstraints.fill = GridBagConstraints.BOTH; resultsPanelConstraints.gridx = 0; resultsPanelConstraints.gridy = 1; resultsPanelConstraints.weightx = 1.0; resultsPanelConstraints.weighty = 0.67; resultsPanelConstraints.gridheight = 1; resultsPanelConstraints.gridwidth = 1; resultsPanelConstraints.insets = new Insets(0, 0, 0, 0); this.getContentPane().add(this.resultsPanel, resultsPanelConstraints); this.applicationDelegate.addEventObserver(ScanStartedEvent.class, this); this.applicationDelegate.addEventObserver(ScanCompletedEvent.class, this); this.applicationDelegate.addEventObserver(SetScanDefinitionMenuStateEvent.class, this); this.applicationDelegate.addEventObserver(SetScanResultsMenuStateEvent.class, this); this.applicationDelegate.addEventObserver(ApplicationConfigurationLoadedEvent.class, this); JMenu menu; JMenuItem menuItem; menuBar = new JMenuBar(); StringBuilder accessiblityLabel = new StringBuilder(128); if (AssuranceUtils.getPlatform() != Platform.MAC) { menu = new JMenu(Application.applicationShortName); menu.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Actions for ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.quitApplicationMenuLabel, KeyEvent.VK_Q); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription(accessiblityLabel.append("Close the ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuItem.addActionListener(this); menuItem.setActionCommand(AssuranceActions.quitApplicationAction); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(MainWindow.aboutApplicationMenuLabel); menuItem.getAccessibleContext().setAccessibleDescription( accessiblityLabel.append("Display information about this version of ") .append(Application.applicationShortName).append(".").toString()); accessiblityLabel.setLength(0); menuItem.addActionListener(this); menuItem.setActionCommand(AssuranceActions.aboutApplicationAction); menu.add(menuItem); } menu = new JMenu("Scan"); menu.setMnemonic(KeyEvent.VK_S); menu.getAccessibleContext().setAccessibleDescription("Actions for file scans"); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.newScanDefinitonMenuLabel, KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Create a new scan definition"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.newScanDefinitonAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.deleteScanDefinitonMenuLabel, KeyEvent.VK_D); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription("Delete the selected scan definition"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.deleteScanDefinitonAction); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(MainWindow.scanMenuLabel, KeyEvent.VK_S); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription("Launch a scan using the selected scan definition"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.scanAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.scanAndMergeMenuLabel, KeyEvent.VK_M); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext().setAccessibleDescription( "Launch a scan using the selected scan definition and merge the results"); menuItem.addActionListener(this.scanLaunchPanel); menuItem.setActionCommand(AssuranceActions.scanAndMergeAction); menu.add(menuItem); menu = new JMenu("Results"); menu.setMnemonic(KeyEvent.VK_R); menu.getAccessibleContext().setAccessibleDescription("Actions for scan results"); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.replaceSourceMenuLabel, KeyEvent.VK_O); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription("Replace the source file with the target file"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.replaceSourceAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.replaceTargetMenuLabel, KeyEvent.VK_T); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription("Replace the target file with the source file"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.replaceTargetAction); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(MainWindow.sourceAttributesMenuLabel); menuItem.getAccessibleContext().setAccessibleDescription("View the source file attributes"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.sourceAttributesAction); menu.add(menuItem); menuItem = new JMenuItem(MainWindow.targetAttributesMenuLabel); menuItem.getAccessibleContext().setAccessibleDescription("View the target file attributes"); menuItem.addActionListener(this.resultsPanel.getResultMenuListener()); menuItem.setActionCommand(AssuranceActions.targetAttributesAction); menu.add(menuItem); menu = new JMenu("View"); menu.setMnemonic(KeyEvent.VK_V); menu.getAccessibleContext().setAccessibleDescription( accessiblityLabel.append("Views within ").append(Application.applicationShortName).toString()); accessiblityLabel.setLength(0); menuBar.add(menu); ButtonGroup group = new ButtonGroup(); this.viewScanMenuItem = new JRadioButtonMenuItem(MainWindow.viewScanMenuLabel); this.viewScanMenuItem.addActionListener(this); this.viewScanMenuItem.setActionCommand(AssuranceActions.viewScanAction); this.viewScanMenuItem.setSelected(true); group.add(this.viewScanMenuItem); menu.add(this.viewScanMenuItem); this.viewHistoryMenuItem = new JRadioButtonMenuItem(MainWindow.viewHistoryMenuLabel); this.viewHistoryMenuItem.addActionListener(this); this.viewHistoryMenuItem.setActionCommand(AssuranceActions.viewHistoryAction); this.viewHistoryMenuItem.setSelected(true); group.add(this.viewHistoryMenuItem); menu.add(this.viewHistoryMenuItem); if (AssuranceUtils.getPlatform() != Platform.MAC) { menu = new JMenu("Tools"); menu.getAccessibleContext() .setAccessibleDescription(accessiblityLabel.append("Additional actions for ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuBar.add(menu); menuItem = new JMenuItem(MainWindow.settingsMenuLabel, KeyEvent.VK_COMMA); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_COMMA, ActionEvent.CTRL_MASK)); menuItem.getAccessibleContext() .setAccessibleDescription(accessiblityLabel.append("Change settings for the ") .append(Application.applicationShortName).append(" application").toString()); accessiblityLabel.setLength(0); menuItem.addActionListener(this); menuItem.setActionCommand(AssuranceActions.displaySettingsAction); menu.add(menuItem); } this.setJMenuBar(menuBar); this.initialized = true; } }
From source file:org.orbisgis.groovy.GroovyConsolePanel.java
/** * Create actions instances//from w w w.j ava2s . c om * * Each action is put in the Popup menu and the tool bar Their shortcuts are * registered also in the editor */ private void initActions() { //Execute action executeAction = new DefaultAction(GroovyConsoleActions.A_EXECUTE, I18N.tr("Execute"), I18N.tr("Execute the groovy script"), GroovyIcon.getIcon("execute"), EventHandler.create(ActionListener.class, this, "onExecute"), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom"); actions.addAction(executeAction); //Execute Selected SQL executeSelectedAction = new DefaultAction(GroovyConsoleActions.A_EXECUTE_SELECTION, I18N.tr("Execute selected"), I18N.tr("Run selected code"), GroovyIcon.getIcon("execute_selection"), EventHandler.create(ActionListener.class, this, "onExecuteSelected"), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.ALT_DOWN_MASK)).setLogicalGroup("custom") .setAfter(GroovyConsoleActions.A_EXECUTE); actions.addAction(executeSelectedAction); //Clear action clearAction = new DefaultAction(GroovyConsoleActions.A_CLEAR, I18N.tr("Clear"), I18N.tr("Erase the content of the editor"), GroovyIcon.getIcon("erase"), EventHandler.create(ActionListener.class, this, "onClear"), null); actions.addAction(clearAction); //Open action actions.addAction(new DefaultAction(GroovyConsoleActions.A_OPEN, I18N.tr("Open"), I18N.tr("Load a file in this editor"), GroovyIcon.getIcon("open"), EventHandler.create(ActionListener.class, this, "onOpenFile"), KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK))); //Save saveAction = new DefaultAction(GroovyConsoleActions.A_SAVE, I18N.tr("Save"), I18N.tr("Save the editor content into a file"), GroovyIcon.getIcon("save"), EventHandler.create(ActionListener.class, this, "onSaveFile"), KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); actions.addAction(saveAction); // Save As saveAsAction = new DefaultAction(GroovyConsoleActions.A_SAVE, I18N.tr("Save As"), I18N.tr("Save the editor content into a new file"), GroovyIcon.getIcon("page_white_save"), EventHandler.create(ActionListener.class, this, "onSaveAsNewFile"), KeyStroke.getKeyStroke("ctrl maj s")); actions.addAction(saveAsAction); //Find action findAction = new DefaultAction(GroovyConsoleActions.A_SEARCH, I18N.tr("Search.."), I18N.tr("Search text in the document"), GroovyIcon.getIcon("find"), EventHandler.create(ActionListener.class, this, "openFindReplaceDialog"), KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK)) .addStroke(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK)); actions.addAction(findAction); // Comment/Uncomment commentAction = new DefaultAction(GroovyConsoleActions.A_COMMENT, I18N.tr("(Un)comment"), I18N.tr("(Un)comment the selected text"), null, EventHandler.create(ActionListener.class, this, "onComment"), KeyStroke.getKeyStroke("alt C")) .setLogicalGroup("format"); actions.addAction(commentAction); // Block Comment/Uncomment blockCommentAction = new DefaultAction(GroovyConsoleActions.A_BLOCKCOMMENT, I18N.tr("Block (un)comment"), I18N.tr("Block (un)comment the selected text."), null, EventHandler.create(ActionListener.class, this, "onBlockComment"), KeyStroke.getKeyStroke("alt shift C")).setLogicalGroup("format"); actions.addAction(blockCommentAction); }
From source file:org.jcurl.demo.editor.EditorApp.java
private JMenuBar createMenu() { final JMenuBar bar = new JMenuBar(); {/* ww w.ja v a 2 s. c o m*/ final JMenu menu = bar.add(new JMenu("File")); menu.setMnemonic('F'); menu.add(this.newMI("New", null, 'N', -1, this, "cmdNew")); menu.add(this.newMI("Open", null, 'O', KeyEvent.VK_O, this, "cmdOpen")); menu.addSeparator(); menu.add(this.newMI("Export Png", null, 'P', KeyEvent.VK_E, this, "cmdExportPng")); menu.addSeparator(); menu.add(this.newMI("Save", null, 'S', KeyEvent.VK_S, this, "cmdSave")); menu.add(this.newMI("Save As", null, 'A', -1, this, "cmdSaveAs")); menu.addSeparator(); menu.add(this.newMI("Exit", null, 'x', -1, this, "cmdExit")); } { final JMenu menu = bar.add(new JMenu("View")); menu.setMnemonic('V'); menu.add(this.newMI("Zoom", null, 'z', -1, this, "cmdZoom")); } { final JMenu menu = bar.add(new JMenu("Play")); menu.setMnemonic('P'); menu.add(this.newMI('a', -1, bStart.getAction())); menu.add(this.newMI('P', -1, bPause.getAction())); menu.add(this.newMI('o', -1, bStop.getAction())); } { final JMenu menu = bar.add(new JMenu("Help")); menu.setMnemonic('H'); menu.add(this.newMI("About", null, 'a', -1, this, "cmdAbout")); } return bar; }
From source file:net.sf.jhylafax.JHylaFAX.java
private void initializeShortCuts() { sendActionShortcut = new ActionShortcut(sendAction); sendActionShortcut.setKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); updateStatusActionShortcut = new ActionShortcut(updateStatusAction); updateStatusActionShortcut.setKeyStroke(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); }
From source file:org.orbisgis.sqlconsole.ui.SQLConsolePanel.java
/** * Create actions instances/*from w w w . j a v a2s. c o m*/ * * Each action is put in the Popup menu and the tool bar * Their shortcuts are registered also in the editor */ private void initActions() { //Execute Action executeAction = new DefaultAction(SQLAction.A_EXECUTE, I18N.tr("Execute"), I18N.tr("Run SQL statements"), SQLConsoleIcon.getIcon("execute"), EventHandler.create(ActionListener.class, this, "onExecute"), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom"); actions.addAction(executeAction); //Execute Selected SQL executeSelectedAction = new DefaultAction(SQLAction.A_EXECUTE_SELECTION, I18N.tr("Execute selected"), I18N.tr("Run selected SQL statements"), SQLConsoleIcon.getIcon("execute_selection"), EventHandler.create(ActionListener.class, this, "onExecuteSelected"), KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.ALT_DOWN_MASK)).setLogicalGroup("custom") .setAfter(SQLAction.A_EXECUTE); actions.addAction(executeSelectedAction); //Clear action clearAction = new DefaultAction(SQLAction.A_CLEAR, I18N.tr("Clear"), I18N.tr("Erase the content of the editor"), SQLConsoleIcon.getIcon("erase"), EventHandler.create(ActionListener.class, this, "onClear"), null).setLogicalGroup("custom") .setAfter(SQLAction.A_EXECUTE_SELECTION); actions.addAction(clearAction); //Find action findAction = new DefaultAction(SQLAction.A_SEARCH, I18N.tr("Search.."), I18N.tr("Search text in the document"), SQLConsoleIcon.getIcon("find"), EventHandler.create(ActionListener.class, this, "openFindReplaceDialog"), KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK)) .addStroke(KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK)) .setLogicalGroup("custom"); actions.addAction(findAction); //Quote quoteAction = new DefaultAction(SQLAction.A_QUOTE, I18N.tr("Quote"), I18N.tr("Quote selected text"), null, EventHandler.create(ActionListener.class, this, "onQuote"), KeyStroke.getKeyStroke(KeyEvent.VK_SLASH, InputEvent.SHIFT_DOWN_MASK)).setLogicalGroup("format"); actions.addAction(quoteAction); //unQuote unQuoteAction = new DefaultAction(SQLAction.A_UNQUOTE, I18N.tr("Un Quote"), I18N.tr("Un Quote selected text"), null, EventHandler.create(ActionListener.class, this, "onUnQuote"), KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SLASH, InputEvent.SHIFT_DOWN_MASK)) .setLogicalGroup("format"); actions.addAction(unQuoteAction); // Comment/Uncomment commentAction = new DefaultAction(SQLAction.A_COMMENT, I18N.tr("(Un)comment"), I18N.tr("(Un)comment the selected text"), null, EventHandler.create(ActionListener.class, this, "onComment"), KeyStroke.getKeyStroke("alt C")) .setLogicalGroup("format"); actions.addAction(commentAction); // Block Comment/Uncomment blockCommentAction = new DefaultAction(SQLAction.A_BLOCKCOMMENT, I18N.tr("Block (un)comment"), I18N.tr("Block (un)comment the selected text."), null, EventHandler.create(ActionListener.class, this, "onBlockComment"), KeyStroke.getKeyStroke("alt shift C")).setLogicalGroup("format"); actions.addAction(blockCommentAction); //Format SQL formatSQLAction = new DefaultAction(SQLAction.A_FORMAT, I18N.tr("Format"), I18N.tr("Format editor content"), null, EventHandler.create(ActionListener.class, this, "onFormatCode"), KeyStroke.getKeyStroke("alt shift F")).setLogicalGroup("format"); actions.addAction(formatSQLAction); //Save saveAction = new DefaultAction(SQLAction.A_SAVE, I18N.tr("Save"), I18N.tr("Save the editor content into a file"), SQLConsoleIcon.getIcon("save"), EventHandler.create(ActionListener.class, this, "onSaveFile"), KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom"); actions.addAction(saveAction); // Save As saveAsAction = new DefaultAction(SQLAction.A_SAVE, I18N.tr("Save As"), I18N.tr("Save the editor content into a new file"), SQLConsoleIcon.getIcon("page_white_save"), EventHandler.create(ActionListener.class, this, "onSaveAsNewFile"), KeyStroke.getKeyStroke("ctrl maj s")).setLogicalGroup("custom"); actions.addAction(saveAsAction); //Open action actions.addAction(new DefaultAction(SQLAction.A_OPEN, I18N.tr("Open"), I18N.tr("Load a file in this editor"), SQLConsoleIcon.getIcon("open"), EventHandler.create(ActionListener.class, this, "onOpenFile"), KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom")); //ShowHide function list actions.addAction(new DefaultAction(SQLAction.A_SQL_LIST, I18N.tr("SQL list"), I18N.tr("Show/Hide SQL function list"), SQLConsoleIcon.getIcon("builtinfunctionmap"), EventHandler.create(ActionListener.class, this, "onShowHideFunctionPanel"), null) .setLogicalGroup("custom")); //Time out action actions.addAction(new DefaultAction(SQLAction.A_SQL_TIMEOUT, I18N.tr("Timeout"), I18N.tr("Custom a time out to execute the SQL statement"), SQLConsoleIcon.getIcon("timeout_sql"), EventHandler.create(ActionListener.class, this, "onSQLTimeOut"), KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)).setLogicalGroup("custom")); }