List of usage examples for javax.swing AbstractAction AbstractAction
public AbstractAction(String name)
From source file:com.intuit.tank.tools.debugger.ActionProducer.java
/** * //from www . j a va2 s. c o m * @return */ public Action getQuitAction() { Action ret = actionMap.get(ACTION_QUIT); if (ret == null) { ret = new AbstractAction(ACTION_QUIT) { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { debuggerFrame.quit(); } }; ret.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(Character.valueOf('Q'), menuActionMods)); ret.putValue(Action.MNEMONIC_KEY, new Integer('Q')); actionMap.put(ACTION_QUIT, ret); } return ret; }
From source file:com.opendoorlogistics.studio.AppFrame.java
private void createNewDatastore() { if (!canCloseDatastore()) { return;/*w ww . j a v a 2 s .c o m*/ } ArrayList<JButton> buttons = new ArrayList<>(); buttons.add(new JButton(new AbstractAction("Create empty datastore") { @Override public void actionPerformed(ActionEvent e) { openEmptyDatastore(); } })); // buttons.add(new JButton(new AbstractAction("Create example datastore") { // // @Override // public void actionPerformed(ActionEvent e) { // onOpenedDatastore(ExampleData.createExampleDatastore(false), null, null); // } // })); for (final String exampleDs : new String[] { "Customers" // , "Sales territories" // disable sales territories for the moment as it takes 30 seconds to load! }) { buttons.add(new JButton(new AbstractAction("Create example " + exampleDs + " datastore") { @Override public void actionPerformed(ActionEvent e) { onOpenedDatastore(TableIOUtils.importExampleDatastore(exampleDs + ".xlsx", null), null, null); } })); } // buttons.add(new JButton(new AbstractAction("Run datastore creation script wizard") { // // @Override // public void actionPerformed(ActionEvent e) { // Script script = WizardUtils.createTableCreationScript(); // scriptManager.launchScriptEditor(script, null); // } // })); // for (final File file : scriptsPanel.getScriptsByType(ScriptType.CREATE_TABLES)) { // buttons.add(new JButton(new AbstractAction("Run script \"" + file.getName() + "\"") { // // @Override // public void actionPerformed(ActionEvent e) { // openEmptyDatastore(); // // // run script // scriptManager.executeScript(file); // // } // })); // // } launchButtonsListDialog("Create new spreadsheet", "Choose creation option:", null, buttons); }
From source file:net.sf.vfsjfilechooser.filepane.VFSFilePane.java
public Action getNewFolderAction() { if (!readOnly && (newFolderAction == null)) { newFolderAction = new AbstractAction(newFolderActionLabelText) { private Action basicNewFolderAction; {// ww w. j av a2 s . c om putValue(Action.ACTION_COMMAND_KEY, VFSFilePane.ACTION_NEW_FOLDER); FileObject currentDirectory = getFileChooser().getCurrentDirectory(); if (currentDirectory != null) { setEnabled(canWrite(currentDirectory)); } } public void actionPerformed(ActionEvent ev) { if (basicNewFolderAction == null) { basicNewFolderAction = fileChooserUIAccessor.getNewFolderAction(); } VFSJFileChooser fc = getFileChooser(); FileObject oldFile = fc.getSelectedFile(); basicNewFolderAction.actionPerformed(ev); FileObject newFile = fc.getSelectedFile(); if ((newFile != null) && !newFile.equals(oldFile) && VFSUtils.isDirectory(newFile)) { newFolderFile = newFile; } } }; } return newFolderAction; }
From source file:com.googlecode.vfsjfilechooser2.filepane.VFSFilePane.java
public Action getNewFolderAction() { if (!readOnly && (newFolderAction == null)) { newFolderAction = new AbstractAction(newFolderActionLabelText) { private Action basicNewFolderAction; {//from w w w.j a v a 2s .c o m putValue(Action.ACTION_COMMAND_KEY, VFSFilePane.ACTION_NEW_FOLDER); FileObject currentDirectory = getFileChooser().getCurrentDirectoryObject(); if (currentDirectory != null) { setEnabled(canWrite(currentDirectory)); } } public void actionPerformed(ActionEvent ev) { if (basicNewFolderAction == null) { basicNewFolderAction = fileChooserUIAccessor.getNewFolderAction(); } VFSJFileChooser fc = getFileChooser(); FileObject oldFile = fc.getSelectedFileObject(); basicNewFolderAction.actionPerformed(ev); FileObject newFile = fc.getSelectedFileObject(); if ((newFile != null) && !newFile.equals(oldFile) && VFSUtils.isDirectory(newFile)) { newFolderFile = newFile; } } }; } return newFolderAction; }
From source file:com.opendoorlogistics.studio.appframe.AppFrame.java
@Override public void launchScriptWizard(final int tableIds[], final ODLComponent component) { // final ODLTableDefinition dfn = (tableId != -1 && loaded != null) ? loaded.getDs().getTableByImmutableId(tableId) : null; // create button to launch the wizard ArrayList<JButton> buttons = new ArrayList<>(); for (final ODLWizardTemplateConfig config : ScriptTemplatesImpl.getTemplates(getApi(), component)) { Action action = new AbstractAction( "Launch wizard \"" + config.getName() + "\" to configure new script") { @Override// ww w .j av a 2s .c o m public void actionPerformed(ActionEvent e) { Script script = ScriptWizardActions.createScriptFromMasterComponent(getApi(), AppFrame.this, component, config, loaded != null ? loaded.getDs() : null, tableIds); if (script != null) { // ScriptEditor dlg = new ScriptEditorWizardGenerated(script, null, getScriptUIManager()); // AppFrame.this.addInternalFrame(dlg); scriptManager.launchScriptEditor(script, null, null); } } }; JButton button = new JButton(action); button.setToolTipText(config.getDescription()); buttons.add(button); } // launch dialog to select the option if (buttons.size() > 1) { launchButtonsListDialog(component.getName(), "Choose \"" + component.getName() + "\" option:", component.getIcon(getApi(), ODLComponent.MODE_DEFAULT), buttons); } else { // pick the only option... buttons.get(0).doClick(); } }
From source file:net.sourceforge.pmd.util.designer.Designer.java
private static void makeTextComponentUndoable(JTextComponent textConponent) { final UndoManager undoManager = new UndoManager(); textConponent.getDocument().addUndoableEditListener(new UndoableEditListener() { @Override//w ww . ja va2 s . c o m public void undoableEditHappened(UndoableEditEvent evt) { undoManager.addEdit(evt.getEdit()); } }); ActionMap actionMap = textConponent.getActionMap(); InputMap inputMap = textConponent.getInputMap(); actionMap.put("Undo", new AbstractAction("Undo") { @Override public void actionPerformed(ActionEvent evt) { try { if (undoManager.canUndo()) { undoManager.undo(); } } catch (CannotUndoException e) { throw new RuntimeException(e); } } }); inputMap.put(KeyStroke.getKeyStroke("control Z"), "Undo"); actionMap.put("Redo", new AbstractAction("Redo") { @Override public void actionPerformed(ActionEvent evt) { try { if (undoManager.canRedo()) { undoManager.redo(); } } catch (CannotRedoException e) { throw new RuntimeException(e); } } }); inputMap.put(KeyStroke.getKeyStroke("control Y"), "Redo"); }
From source file:org.colombbus.tangara.EditorFrame.java
/** * Returns the cut action//from w w w .j a v a 2s.c o m * * @return */ public Action getCutAction() { if (cutAction == null) { cutAction = new AbstractAction(Messages.getString("Banner.menu.cut")) { //$NON-NLS-1$ @Override public void actionPerformed(ActionEvent e) { cut(); } }; cutAction.setEnabled(false); cutAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control X")); } return cutAction; }
From source file:com.diversityarrays.kdxplore.KDXploreFrame.java
private JMenuBar buildMenuBar() { RunMode runMode = RunMode.getRunMode(); JMenuBar mb = new JMenuBar(); mb.add(createMainMenu(runMode));//from w ww .j a va 2 s . c o m if (!backupProviders.isEmpty()) { String toolsMenuLabel = Msg.MENU_TOOLS(); JMenu toolsMenu = new JMenu(toolsMenuLabel); mb.add(toolsMenu); for (Action a : pluginInfo.getToolsMenuActions()) { toolsMenu.add(a); } Action backupAction = new AbstractAction(Msg.MENUITEM_BACKUP_DB()) { @Override public void actionPerformed(ActionEvent e) { doBackupDatabase(); } }; backupAction.putValue(Action.SMALL_ICON, KDClientUtils.getIcon(ImageId.DB_BACKUP)); toolsMenu.add(backupAction); boolean seen = false; for (BackupProvider bp : backupProviders) { Action a = bp.getOfflineDataAction(); if (a != null) { if (!seen) { seen = true; toolsMenu.add(new JSeparator()); } toolsMenu.add(a); } } } mb.add(frameWindowOpener.getWindowsMenu()); mb.add(createHelpMenu()); return mb; }
From source file:org.geopublishing.atlasViewer.swing.AtlasViewerGUI.java
/** * Change the {@link JMenu} languageSubMenu that allows changing the * displayed language Attention, not to replace the object in the * {@link JMenu} structure Call this after changes to atlasConfig.langages. * /*from w w w .j a va 2 s . c o m*/ * @author <a href="mailto:skpublic@wikisquare.de">Stefan Alfons Tzeggai</a> * * Note: This method is double in {@link AtlasViewerGUI} and * Geopublisher */ private void updateLangMenu() { if (getAtlasConfig() == null) return; // Assuming that the language was changed, update the windows title // getJFrame().setTitle("Loaded ace.getName().toString()); SwingUtil.checkOnEDT(); if (languageSubMenu == null) { languageSubMenu = new JMenu(GpCoreUtil.R("AtlasViewer.FileMenu.LanguageSubMenu.change_language")); languageSubMenu.setFont(AtlasMenuItem.BIGFONT); languageSubMenu.setToolTipText(GpCoreUtil.R("AtlasViewer.FileMenu.LanguageSubMenu.change_language_tt")); languageSubMenu.setIcon(Icons.ICON_FLAGS_SMALL); } else { // Remove all old MenuItems languageSubMenu.removeAll(); } // If there is only one language, the whole menu is disabled and a // different tooltip appears. if (getAtlasConfig().getLanguages().size() == 1) { getLanguageSubMenu().setToolTipText( GpCoreUtil.R("AtlasViewer.FileMenu.LanguageSubMenu.change_language_notAvailable_tt", getAtlasConfig().getLanguages().get(0))); getLanguageSubMenu().setEnabled(false); return; } for (String langCode : getAtlasConfig().getLanguages()) { // Not show the option to switch to actual language... if (langCode.equals(Translation.getActiveLang())) continue; JMenuItem langMenuItem = new AtlasMenuItem( new AbstractAction(I18NUtil.getMultilanguageString(langCode)) { @Override public void actionPerformed(ActionEvent e) { try { Translation.setActiveLang(e.getActionCommand()); // To force the recreation of the Menus, we have // to null some of the elements // updateMenu(); // Update the GUI updateLangMenu(); setMap(map, true); } catch (Throwable ex) { ExceptionDialog.show(getJFrame(), ex); } } }); langMenuItem.setActionCommand(langCode); getLanguageSubMenu().add(langMenuItem); } }
From source file:org.colombbus.tangara.EditorFrame.java
/** * Returns the copy action// ww w .j a va 2 s. c o m * * @return */ public Action getCopyAction() { if (copyAction == null) { copyAction = new AbstractAction(Messages.getString("Banner.menu.copy")) { //$NON-NLS-1$ @Override public void actionPerformed(ActionEvent e) { copy(); } }; copyAction.setEnabled(false); copyAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control C")); } return copyAction; }