📄 appcommand.java
字号:
/*====================================================================*\AppCommand.javaApplication command enumeration.------------------------------------------------------------------------This file is part of FuncPlotter, a combined Java application and appletfor plotting explicit functions in one variable.Copyright 2005-2007 Andy Morgan-Richards.FuncPlotter is free software: you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation, either version 3 of the License, or (at youroption) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public License alongwith this program. If not, see <http://www.gnu.org/licenses/>.\*====================================================================*/// IMPORTSimport java.awt.event.ActionEvent;import java.awt.event.KeyEvent;import java.beans.PropertyChangeListener;import javax.swing.Action;import javax.swing.KeyStroke;import util.Command;//----------------------------------------------------------------------// APPLICATION COMMAND ENUMERATIONenum AppCommand implements Action{////////////////////////////////////////////////////////////////////////// Constants//////////////////////////////////////////////////////////////////////// // Commands TRANSFER_FILES ( "transferFiles" ), CHECK_MODIFIED_FILE ( "checkModifiedFile" ), NEW_FILE ( "newFile", "New", KeyStroke.getKeyStroke( KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK ) ), OPEN_FILE ( "openFile", "Open" + AppConstants.ELLIPSIS_STR, KeyStroke.getKeyStroke( KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK ) ), REOPEN_FILE ( "reopenFile", "Reopen" ), CLOSE_FILE ( "closeFile", "Close" ), CLOSE_ALL_FILES ( "closeAllFiles", "Close All" ), SAVE_FILE ( "saveFile", "Save", KeyStroke.getKeyStroke( KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK ) ), SAVE_FILE_AS ( "saveFileAs", "Save As" + AppConstants.ELLIPSIS_STR ), EXPORT_IMAGE ( "exportImage", "Export Image" + AppConstants.ELLIPSIS_STR, KeyStroke.getKeyStroke( KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK ) ), EXIT ( "exit", "Exit" ), COPY_INTERVALS ( "copyIntervals", "Copy Intervals to Other Documents" + AppConstants.ELLIPSIS_STR, KeyStroke.getKeyStroke( KeyEvent.VK_I, KeyEvent.CTRL_DOWN_MASK ) ), EDIT_PREFERENCES ( "editPreferences", "Preferences" + AppConstants.ELLIPSIS_STR ), SHOW_FULL_PATHNAMES ( "showFullPathnames", "Show Full Pathnames" ); //------------------------------------------------------------------ // Property keys interface Property { String FILES = "files"; }////////////////////////////////////////////////////////////////////////// Constructors//////////////////////////////////////////////////////////////////////// private AppCommand( String key ) { command = new Command( this ); putValue( Action.ACTION_COMMAND_KEY, key ); } //------------------------------------------------------------------ private AppCommand( String key, String name ) { this( key ); putValue( Action.NAME, name ); } //------------------------------------------------------------------ private AppCommand( String key, String name, KeyStroke acceleratorKey ) { this( key, name ); putValue( Action.ACCELERATOR_KEY, acceleratorKey ); } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Instance methods : Action interface//////////////////////////////////////////////////////////////////////// public void addPropertyChangeListener( PropertyChangeListener listener ) { command.addPropertyChangeListener( listener ); } //------------------------------------------------------------------ public Object getValue( String key ) { return command.getValue( key ); } //------------------------------------------------------------------ public boolean isEnabled( ) { return command.isEnabled( ); } //------------------------------------------------------------------ public void putValue( String key, Object value ) { command.putValue( key, value ); } //------------------------------------------------------------------ public void removePropertyChangeListener( PropertyChangeListener listener ) { command.removePropertyChangeListener( listener ); } //------------------------------------------------------------------ public void setEnabled( boolean enabled ) { command.setEnabled( enabled ); } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Instance methods : ActionListener interface//////////////////////////////////////////////////////////////////////// public void actionPerformed( ActionEvent event ) { App.getInstance( ).executeCommand( this ); } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Instance methods//////////////////////////////////////////////////////////////////////// public String getMethodName( ) { return command.getMethodName( ); } //------------------------------------------------------------------ public void setSelected( boolean selected ) { putValue( Action.SELECTED_KEY, new Boolean( selected ) ); } //------------------------------------------------------------------ public void execute( ) { actionPerformed( null ); } //------------------------------------------------------------------////////////////////////////////////////////////////////////////////////// Instance variables//////////////////////////////////////////////////////////////////////// private Command command;}//----------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -