private static void constructActions() { final Action lExitAction = new ExitAction(); lExitAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_X); viewModel.put("action.exit", lExitAction); final Action lHelpAction = new HelpAction(); lHelpAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_T); viewModel.put("action.help", lHelpAction); final Action lAboutAction = new AboutAction(); lAboutAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_A); viewModel.put("action.about", lAboutAction); }
void buildActions() { String s = allowEdit ? "select_caption_ok" : "select_caption"; selectAction = new AbstractAction( bridge.getMsg(MSG_ID + s), ResourceManager.getImageIcon( allowEdit ? "icons/commit_changes.gif" : "icons/file_open.gif")) { public void actionPerformed(ActionEvent ev) { if (allowEdit && etp.getCurrentPanel() != null) { etp.getCurrentPanel().save(); if (pled.isModified()) { pled.saveMenus(pled); try { save(null); } catch (Exception ex) { bridge .getOptions() .getMessages() .showErrorWarning(getParent(), "FILE_ERR_SAVING", fullPath, ex, null); } } } if (etp.currentItem != null && etp.currentItem instanceof MenuEditor) { result = ((MenuEditor) etp.currentItem).getMenu(); } else { result = null; if (!allowEdit) return; } // modified=etp.modified; accept = true; setVisible(false); } }; selectAction.putValue( AbstractAction.SHORT_DESCRIPTION, bridge.getMsg(MSG_ID + s + "_tooltip")); if (!allowEdit) selectAction.setEnabled(false); cancelAction = new AbstractAction( bridge.getMsg(MSG_ID + "cancel_caption"), ResourceManager.getImageIcon("icons/cancel.gif")) { public void actionPerformed(ActionEvent ev) { result = null; // modified=false; accept = false; setVisible(false); } }; cancelAction.putValue( AbstractAction.SHORT_DESCRIPTION, bridge.getMsg(MSG_ID + "cancel_tooltip")); }
private void configureRichTextAction( ISQLPanelAPI sqlPanelAPI, SquirrelRSyntaxTextArea rsEdit, String rtaKey, KeyStroke acceleratorKeyStroke, String acceleratorDescription, String shortDescription) { Action action = SquirreLRSyntaxTextAreaUI.getActionForName(rsEdit, rtaKey); action.putValue(Resources.ACCELERATOR_STRING, acceleratorDescription); action.putValue(Action.SHORT_DESCRIPTION, shortDescription); action.putValue(Action.MNEMONIC_KEY, 0); action.putValue(Action.ACCELERATOR_KEY, acceleratorKeyStroke); JMenuItem mnu = sqlPanelAPI.addToSQLEntryAreaMenu(action); mnu.setText((String) action.getValue(Action.SHORT_DESCRIPTION)); _resources.configureMenuItem(action, mnu); }
/** Synchronizes the state of the actions to the current state of this host. */ private void updateActions() { final DeviceController currentDeviceController = getDeviceController(); final boolean deviceControllerSet = currentDeviceController != null; final boolean deviceCapturing = deviceControllerSet && currentDeviceController.isCapturing(); final boolean deviceSetup = deviceControllerSet && !deviceCapturing && currentDeviceController.isSetup(); getAction(CaptureAction.ID).setEnabled(deviceControllerSet); getAction(CancelCaptureAction.ID).setEnabled(deviceCapturing); getAction(RepeatCaptureAction.ID).setEnabled(deviceSetup); final boolean projectChanged = this.projectManager.getCurrentProject().isChanged(); final boolean projectSavedBefore = this.projectManager.getCurrentProject().getFilename() != null; final boolean dataAvailable = this.dataContainer.hasCapturedData(); getAction(SaveProjectAction.ID).setEnabled(projectChanged); getAction(SaveProjectAsAction.ID).setEnabled(projectSavedBefore && projectChanged); getAction(SaveDataFileAction.ID).setEnabled(dataAvailable); getAction(ZoomInAction.ID).setEnabled(dataAvailable); getAction(ZoomOutAction.ID).setEnabled(dataAvailable); getAction(ZoomDefaultAction.ID).setEnabled(dataAvailable); getAction(ZoomFitAction.ID).setEnabled(dataAvailable); final boolean triggerEnable = dataAvailable && this.dataContainer.hasTriggerData(); getAction(GotoTriggerAction.ID).setEnabled(triggerEnable); // Update the cursor actions accordingly... final boolean enableCursors = dataAvailable && this.dataContainer.isCursorsEnabled(); for (int c = 0; c < CapturedData.MAX_CURSORS; c++) { final boolean enabled = enableCursors && this.dataContainer.isCursorPositionSet(c); getAction(GotoNthCursorAction.getID(c)).setEnabled(enabled); } getAction(GotoFirstCursorAction.ID).setEnabled(enableCursors); getAction(GotoLastCursorAction.ID).setEnabled(enableCursors); getAction(SetCursorModeAction.ID).setEnabled(dataAvailable); getAction(SetCursorModeAction.ID) .putValue(Action.SELECTED_KEY, Boolean.valueOf(this.dataContainer.isCursorsEnabled())); boolean anyCursorSet = false; for (int c = 0; c < CapturedData.MAX_CURSORS; c++) { final boolean cursorPositionSet = this.dataContainer.isCursorPositionSet(c); anyCursorSet |= cursorPositionSet; final Action action = getAction(SetCursorAction.getCursorId(c)); action.setEnabled(dataAvailable); action.putValue(Action.SELECTED_KEY, Boolean.valueOf(cursorPositionSet)); } getAction(ClearCursors.ID).setEnabled(enableCursors && anyCursorSet); }
@Override public void ioResult(IOServiceEvent e) { if (e.getState() == IOServiceEvent.MOUNT_SUCCESS || e.getState() == IOServiceEvent.MOUNT_FAILURE) { lumberjack.setFullModel(buildModel(e.getResolverBundle().getResolvers())); toggleAction.setEnabled(cpos != null); toggleAction.putValue( Action.SELECTED_KEY, (Boolean) toggleAction.getValue(Action.SELECTED_KEY) && cpos != null); } }
protected Collection getActions() { ArrayList actions = new ArrayList(); actions.add(getCreateOWLDatatypePropertyAction()); Action createSubPropertyAction = getCreateSubpropertyAction(); createSubPropertyAction.putValue( Action.SMALL_ICON, OWLIcons.getCreatePropertyIcon("DatatypeSubProperty")); actions.add(createSubPropertyAction); getDeletePropertyAction() .putValue(Action.SMALL_ICON, OWLIcons.getDeleteIcon("OWLDatatypeProperty")); return actions; }
private void initCommitToDBAction() { commitToDBAction = new AbstractAction( "Commit to DB", GKApplicationUtilities.createImageIcon(getClass(), "CommitToDB.gif")) { public void actionPerformed(ActionEvent e) { commitToDB(); } }; commitToDBAction.putValue(Action.SHORT_DESCRIPTION, "Commit to the database repository"); commitToDBAction.setEnabled(false); }
private void initClearRecordAction() { clearRecordAction = new AbstractAction( "Clear Record", GKApplicationUtilities.createImageIcon(getClass(), "ClearRecord.gif")) { public void actionPerformed(ActionEvent e) { clearDeleteRecord(); } }; clearRecordAction.putValue(Action.SHORT_DESCRIPTION, "Clear delete record"); // Disable as default clearRecordAction.setEnabled(false); }
private static void configureAction( DialogBuilder builder, DialogBuilder.CustomizableAction customizableAction, ActionButtonPresentation presentation) { customizableAction.setText(presentation.getName()); String actionName = presentation.getName(); final int index = actionName.indexOf('&'); final char mnemonic; if (index >= 0 && index < actionName.length() - 1) { mnemonic = actionName.charAt(index + 1); actionName = actionName.substring(0, index) + actionName.substring(index + 1); } else { mnemonic = 0; } final Action action = ((DialogBuilder.ActionDescriptor) customizableAction).getAction(builder.getDialogWrapper()); action.putValue(Action.NAME, actionName); if (mnemonic > 0) { action.putValue(Action.MNEMONIC_KEY, Integer.valueOf(mnemonic)); } }
private void initShowComparisonAction() { showComparisonAction = new AbstractAction( "Show Comparison", GKApplicationUtilities.createImageIcon(getClass(), "ShowComparison.gif")) { public void actionPerformed(ActionEvent e) { showComparison(); } }; showComparisonAction.putValue( Action.SHORT_DESCRIPTION, "Compare an instance in the local and database repositories"); showComparisonAction.setEnabled(false); }
public FilterPanel init( final ReadablePreset.ReadableVoice voice, TableExclusiveSelectionContext tsc) throws ParameterException, DeviceException { this.setLayout(new FlowLayout()); final List filterIds = voice .getPreset() .getDeviceParameterContext() .getVoiceContext() .getIdsForCategory(ParameterCategories.VOICE_FILTER); filterModels = new ReadableParameterModel[filterIds.size()]; try { for (int i = 0, j = filterIds.size(); i < j; i++) filterModels[i] = voice.getParameterModel((Integer) filterIds.get(i)); } catch (IllegalParameterIdException e) { ZUtilities.zDisposeCollection(Arrays.asList(filterModels)); throw e; } Action ra = new AbstractAction() { public void actionPerformed(ActionEvent e) { try { voice .getPreset() .refreshVoiceParameters( voice.getVoiceNumber(), (Integer[]) filterIds.toArray(new Integer[filterIds.size()])); } catch (PresetException e1) { e1.printStackTrace(); } } }; ra.putValue("tip", "Refresh Filter"); FilterParameterTableModel model = new FilterParameterTableModel(filterModels); RowHeaderedAndSectionedTablePanel ampPanel; VoiceParameterTable vpt = new VoiceParameterTable(voice, ParameterCategories.VOICE_FILTER, model, "Filter"); tsc.addTableToContext(vpt); ampPanel = new RowHeaderedAndSectionedTablePanel() .init(vpt, "Show Filter", UIColors.getTableBorder(), ra); this.add(ampPanel); return this; }
/** * Tests that the returned JButton of <code>createManualToolBarButton</code>: 1. Is disabled upon * return. 2. Inherits the tooltip of the Action parameter <code>a</code>. */ public void testCreateManualToolBarButton() { final Action a = new AbstractAction("Test Action") { public void actionPerformed(ActionEvent ae) {} }; a.putValue(Action.LONG_DESCRIPTION, "test tooltip"); Utilities.invokeAndWait( new Runnable() { public void run() { _but = _frame._createManualToolBarButton(a); } }); assertTrue("Returned JButton is enabled.", !_but.isEnabled()); assertEquals("Tooltip text not set.", "test tooltip", _but.getToolTipText()); _log.log("testCreateManualToobarButton completed"); }
// Add icons and friendly names to actions we care about. protected void makeActionsPretty() { Action a; a = textComp.getActionMap().get(DefaultEditorKit.cutAction); a.putValue(Action.SMALL_ICON, new ImageIcon("icons/cut.gif")); a.putValue(Action.NAME, "Cut"); a = textComp.getActionMap().get(DefaultEditorKit.copyAction); a.putValue(Action.SMALL_ICON, new ImageIcon("icons/copy.gif")); a.putValue(Action.NAME, "Copy"); a = textComp.getActionMap().get(DefaultEditorKit.pasteAction); a.putValue(Action.SMALL_ICON, new ImageIcon("icons/paste.gif")); a.putValue(Action.NAME, "Paste"); a = textComp.getActionMap().get(DefaultEditorKit.selectAllAction); a.putValue(Action.NAME, "Select All"); }
public ToolBarFrame() { setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); // add a panel for color change panel = new JPanel(); add(panel, BorderLayout.CENTER); // set up actions Action blueAction = new ColorAction("Blue", new ImageIcon("blue-ball.gif"), Color.BLUE); Action yellowAction = new ColorAction("Yellow", new ImageIcon("yellow-ball.gif"), Color.YELLOW); Action redAction = new ColorAction("Red", new ImageIcon("red-ball.gif"), Color.RED); Action exitAction = new AbstractAction("Exit", new ImageIcon("exit.gif")) { public void actionPerformed(ActionEvent event) { System.exit(0); } }; exitAction.putValue(Action.SHORT_DESCRIPTION, "Exit"); // populate tool bar JToolBar bar = new JToolBar(); bar.add(blueAction); bar.add(yellowAction); bar.add(redAction); bar.addSeparator(); bar.add(exitAction); add(bar, BorderLayout.NORTH); // populate menu JMenu menu = new JMenu("Color"); menu.add(yellowAction); menu.add(blueAction); menu.add(redAction); menu.add(exitAction); JMenuBar menuBar = new JMenuBar(); menuBar.add(menu); setJMenuBar(menuBar); }
private void setupActions() { wordList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { wordEditField.setText((String) wordList.getSelectedValue()); wordEditField.selectAll(); new FocusRequester(wordEditField); } }); newWord.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { newWordAction(); } }); wordEditFieldListener = new ActionListener() { public void actionPerformed(ActionEvent e) { int index = wordList.getSelectedIndex(); String old = (String) wordList.getSelectedValue(), newVal = wordEditField.getText(); if (newVal.equals("") || newVal.equals(old)) { return; // Empty string or no change. } if (wordListModel.contains(newVal)) { // ensure that word already in list is visible index = wordListModel.indexOf(newVal); wordList.ensureIndexIsVisible(index); return; } int newIndex = findPos(wordListModel, newVal); if (index >= 0) { // initiate replacement of selected word wordListModel.remove(index); if (newIndex > index) { // newIndex has to be adjusted after removal of previous entry newIndex--; } } wordListModel.add(newIndex, newVal); wordList.ensureIndexIsVisible(newIndex); wordEditField.selectAll(); } }; wordEditField.addActionListener(wordEditFieldListener); removeWord.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int index = wordList.getSelectedIndex(); if (index == -1) return; wordListModel.remove(index); wordEditField.setText(""); if (wordListModel.size() > 0) wordList.setSelectedIndex(Math.min(index, wordListModel.size() - 1)); } }); fieldList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { currentField = (String) fieldList.getSelectedValue(); fieldNameField.setText(""); setupWordSelector(); } }); newField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (!fieldListModel.get(0).equals(FIELD_FIRST_LINE)) { // only add <field name> once fieldListModel.add(0, FIELD_FIRST_LINE); } fieldList.setSelectedIndex(0); fPane.getVerticalScrollBar().setValue(0); fieldNameField.setEnabled(true); fieldNameField.setText(currentField); fieldNameField.selectAll(); new FocusRequester(fieldNameField); } }); fieldNameField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fieldNameField.transferFocus(); } }); fieldNameField.addFocusListener( new FocusAdapter() { /** Adds the text value to the list */ public void focusLost(FocusEvent e) { String s = fieldNameField.getText(); fieldNameField.setText(""); fieldNameField.setEnabled(false); if (!FIELD_FIRST_LINE.equals(s) && !"".equals(s)) { // user has typed something // remove "<first name>" from list fieldListModel.remove(0); int pos; if (fieldListModel.contains(s)) { // field already exists, scroll to that field (below) pos = fieldListModel.indexOf(s); } else { // Add new field. pos = findPos(fieldListModel, s); fieldListModel.add(Math.max(0, pos), s); } fieldList.setSelectedIndex(pos); fieldList.ensureIndexIsVisible(pos); currentField = s; setupWordSelector(); newWordAction(); // new FocusRequester(wordEditField); } } }); removeField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int index = fieldList.getSelectedIndex(); if (index == -1) return; String fieldName = (String) fieldListModel.get(index); removedFields.add(fieldName); fieldListModel.remove(index); wordListModels.remove(fieldName); fieldNameField.setText(""); if (fieldListModel.size() > 0) fieldList.setSelectedIndex(Math.min(index, wordListModel.size() - 1)); } }); help.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { frame.helpDiag.showPage(GUIGlobals.contentSelectorHelp); } }); ok.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { applyChanges(); dispose(); } }); apply.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // Store if an entry is currently being edited: if (!wordEditField.getText().equals("")) { wordEditFieldListener.actionPerformed(null); } applyChanges(); } }); @SuppressWarnings("serial") Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { dispose(); } }; cancelAction.putValue(Action.NAME, Globals.lang("Cancel")); cancel.setAction(cancelAction); }
/** Helper method to initialize the actions used for the buttons. */ private void initActions() { /*actionUndo = new AbstractAction() { public void actionPerformed(ActionEvent ae) { try { // do redo undoManager.undo(); // notify undo manager/toolbar of change GUIPrism.getGUI().notifyEventListeners( new GUIClipboardEvent(GUIClipboardEvent.UNDOMANAGER_CHANGE, GUIPrism.getGUI().getFocussedPlugin().getFocussedComponent())); } catch (CannotUndoException ex) { //GUIPrism.getGUI().getMultiLogger().logMessage(PrismLogLevel.PRISM_ERROR, ex.getMessage()); } } }; actionUndo.putValue(Action.LONG_DESCRIPTION, "Undo the most recent action."); actionUndo.putValue(Action.NAME, "Undo"); actionUndo.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallUndo.png")); actionRedo = new AbstractAction() { public void actionPerformed(ActionEvent ae) { try { // do redo undoManager.redo(); // notify undo manager/toolbar of change GUIPrism.getGUI().notifyEventListeners( new GUIClipboardEvent(GUIClipboardEvent.UNDOMANAGER_CHANGE, GUIPrism.getGUI().getFocussedPlugin().getFocussedComponent())); } catch (CannotRedoException ex) { //GUIPrism.getGUI().getMultiLogger().logMessage(PrismLogLevel.PRISM_ERROR, ex.getMessage()); } } }; actionRedo.putValue(Action.LONG_DESCRIPTION, "Redos the most recent undo"); actionRedo.putValue(Action.NAME, "Redo"); actionRedo.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallRedo.png")); */ actionJumpToError = new AbstractAction() { public void actionPerformed(ActionEvent ae) { jumpToError(); } }; actionJumpToError.putValue(Action.NAME, "Jump to error"); actionJumpToError.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("tinyError.png")); actionJumpToError.putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke( KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); // search and replace action actionSearch = new AbstractAction() { public void actionPerformed(ActionEvent ae) { /* // System.out.println("search button pressed"); if (GUIMultiModelHandler.isDoingSearch()) { } else { try { GUIMultiModelHandler.setDoingSearch(true); FindReplaceForm.launch(GUIPrism.getGUI().getMultiModel()); } catch (PluginNotFoundException pnfe) { GUIPrism.getGUI().getMultiLogger().logMessage(prism.log.PrismLogLevel.PRISM_ERROR, pnfe.getMessage()); } } */ } }; actionSearch.putValue(Action.LONG_DESCRIPTION, "Opens a find and replace dialog."); // actionSearch.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("find.png")); actionSearch.putValue(Action.NAME, "Find/Replace"); // actionSearch.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_R, // Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); insertDTMC = new AbstractAction() { public void actionPerformed(ActionEvent ae) { int caretPosition = editor.getCaretPosition(); try { editor.getDocument().insertString(caretPosition, "dtmc", new SimpleAttributeSet()); } catch (BadLocationException ble) { // todo log? } } }; insertDTMC.putValue( Action.LONG_DESCRIPTION, "Marks this model as a \"Discrete-Time Markov Chain\""); // actionSearch.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("find.png")); insertDTMC.putValue(Action.NAME, "Probabilistic (DTMC)"); insertCTMC = new AbstractAction() { public void actionPerformed(ActionEvent ae) { int caretPosition = editor.getCaretPosition(); try { editor.getDocument().insertString(caretPosition, "ctmc", new SimpleAttributeSet()); } catch (BadLocationException ble) { // todo log? } } }; insertCTMC.putValue( Action.LONG_DESCRIPTION, "Marks this model as a \"Continous-Time Markov Chain\""); // actionSearch.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("find.png")); insertCTMC.putValue(Action.NAME, "Stochastic (CTMC)"); insertMDP = new AbstractAction() { public void actionPerformed(ActionEvent ae) { int caretPosition = editor.getCaretPosition(); try { editor.getDocument().insertString(caretPosition, "mdp", new SimpleAttributeSet()); } catch (BadLocationException ble) { // todo log? } } }; insertMDP.putValue( Action.LONG_DESCRIPTION, "Marks this model as a \"Markov Decision Process\""); // actionSearch.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("find.png")); insertMDP.putValue(Action.NAME, "Non-deterministic (MDP)"); }
/** 创建工具栏 */ private void createToolBar() { panel = new JPanel(new BorderLayout()); // 加入工具栏 toolBar = new JToolBar(); panel.add(toolBar, BorderLayout.NORTH); // 保存 saveAction = new AbstractAction("保存", new ImageIcon(TMFrame.class.getResource("/images/TSave.gif"))) { public void actionPerformed(ActionEvent e) { save(); } }; // 打印 printAction = new AbstractAction("打印", new ImageIcon(TMFrame.class.getResource("/images/TPrint.gif"))) { public void actionPerformed(ActionEvent e) { print(); } }; // 人员管理 DMManageAction = new AbstractAction("人员管理", new ImageIcon(TMFrame.class.getResource("/images/TStaff.gif"))) { public void actionPerformed(ActionEvent e) { DMManage(); } }; // 备份数据库 Action backupAction = new AbstractAction( "备份数据库", new ImageIcon(TMFrame.class.getResource("/images/TBackup.gif"))) { public void actionPerformed(ActionEvent e) { backup(); } }; // 恢复数据库 Action restoreAction = new AbstractAction( "恢复数据库", new ImageIcon(TMFrame.class.getResource("/images/TRestore.gif"))) { public void actionPerformed(ActionEvent e) { restore(); } }; Action searchAction = new AbstractAction("查询", new ImageIcon(TMFrame.class.getResource("/images/TSearch.gif"))) { public void actionPerformed(ActionEvent e) { search(); } }; // 帮助文档 Action helpAction = new AbstractAction("帮助", new ImageIcon(TMFrame.class.getResource("/images/THelp.gif"))) { public void actionPerformed(ActionEvent e) { help(); } }; // 关于我们 Action aboutAction = new AbstractAction( "关于我们", new ImageIcon(TMFrame.class.getResource("/images/TAboutUS.gif"))) { public void actionPerformed(ActionEvent e) { about(); } }; Action exitAction = new AbstractAction("退出", new ImageIcon(TMFrame.class.getResource("/images/TExit.gif"))) { public void actionPerformed(ActionEvent e) { System.exit(0); } }; // 为工具栏图标加入提示 saveAction.putValue(Action.SHORT_DESCRIPTION, "保存"); printAction.putValue(Action.SHORT_DESCRIPTION, "打印"); DMManageAction.putValue(Action.SHORT_DESCRIPTION, "人员管理"); backupAction.putValue(Action.SHORT_DESCRIPTION, "备份数据库"); restoreAction.putValue(Action.SHORT_DESCRIPTION, "恢复数据库"); searchAction.putValue(Action.SHORT_DESCRIPTION, "查询"); helpAction.putValue(Action.SHORT_DESCRIPTION, "帮助文档"); aboutAction.putValue(Action.SHORT_DESCRIPTION, "关于我们"); exitAction.putValue(Action.SHORT_DESCRIPTION, "退出系统"); toolBar.add(saveAction); toolBar.add(printAction); toolBar.add(DMManageAction); toolBar.add(backupAction); toolBar.add(restoreAction); toolBar.add(searchAction); toolBar.add(helpAction); toolBar.add(aboutAction); toolBar.add(exitAction); toolBar.setBorder(BorderFactory.createEtchedBorder()); toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 2)); add(panel); // 设置图标活动性 saveAction.setEnabled(false); printAction.setEnabled(false); backupAction.setEnabled(false); restoreAction.setEnabled(false); }
public OutOfMemoryDialog(MemoryKind memoryKind) { super(false); myMemoryKind = memoryKind; setTitle(DiagnosticBundle.message("diagnostic.out.of.memory.title")); myMessageLabel.setIcon(Messages.getErrorIcon()); myMessageLabel.setText( DiagnosticBundle.message( "diagnostic.out.of.memory.error", memoryKind == MemoryKind.HEAP ? VMOptions.XMX_OPTION_NAME : memoryKind == MemoryKind.PERM_GEN ? VMOptions.PERM_GEN_OPTION_NAME : VMOptions.CODE_CACHE_OPTION_NAME, ApplicationNamesInfo.getInstance().getProductName())); final String path = VMOptions.getSettingsFilePath(); if (path != null) { mySettingsFileHintLabel.setText( DiagnosticBundle.message("diagnostic.out.of.memory.willBeSavedTo", path)); } else { mySettingsFileHintLabel.setVisible(false); } myIgnoreAction = new AbstractAction(DiagnosticBundle.message("diagnostic.out.of.memory.ignore")) { public void actionPerformed(ActionEvent e) { save(); close(0); } }; myShutdownAction = new AbstractAction(DiagnosticBundle.message("diagnostic.out.of.memory.shutdown")) { public void actionPerformed(ActionEvent e) { save(); System.exit(0); } }; myShutdownAction.putValue(DialogWrapper.DEFAULT_ACTION, true); configControls( VMOptions.XMX_OPTION_NAME, VMOptions.readXmx(), memoryKind == MemoryKind.HEAP, myHeapSizeLabel, myHeapSizeField, myHeapUnitsLabel, myHeapCurrentValueLabel); configControls( VMOptions.PERM_GEN_OPTION_NAME, VMOptions.readMaxPermGen(), memoryKind == MemoryKind.PERM_GEN, myPermGenSizeLabel, myPermGenSizeField, myPermGenUnitsLabel, myPermGenCurrentValueLabel); configControls( VMOptions.CODE_CACHE_OPTION_NAME, VMOptions.readCodeCache(), memoryKind == MemoryKind.CODE_CACHE, myCodeCacheSizeLabel, myCodeCacheSizeField, myCodeCacheUnitsLabel, myCodeCacheCurrentValueLabel); init(); }
@Override protected Action[] createActions() { Action cancelAction = getCancelAction(); cancelAction.putValue(DEFAULT_ACTION, Boolean.TRUE); return new Action[] {cancelAction}; }