| 1 |
772 |
jeremybenn |
/* Action.java --
|
| 2 |
|
|
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
|
| 3 |
|
|
|
| 4 |
|
|
This file is part of GNU Classpath.
|
| 5 |
|
|
|
| 6 |
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
| 7 |
|
|
it under the terms of the GNU General Public License as published by
|
| 8 |
|
|
the Free Software Foundation; either version 2, or (at your option)
|
| 9 |
|
|
any later version.
|
| 10 |
|
|
|
| 11 |
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
| 12 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 14 |
|
|
General Public License for more details.
|
| 15 |
|
|
|
| 16 |
|
|
You should have received a copy of the GNU General Public License
|
| 17 |
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
| 18 |
|
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
| 19 |
|
|
02110-1301 USA.
|
| 20 |
|
|
|
| 21 |
|
|
Linking this library statically or dynamically with other modules is
|
| 22 |
|
|
making a combined work based on this library. Thus, the terms and
|
| 23 |
|
|
conditions of the GNU General Public License cover the whole
|
| 24 |
|
|
combination.
|
| 25 |
|
|
|
| 26 |
|
|
As a special exception, the copyright holders of this library give you
|
| 27 |
|
|
permission to link this library with independent modules to produce an
|
| 28 |
|
|
executable, regardless of the license terms of these independent
|
| 29 |
|
|
modules, and to copy and distribute the resulting executable under
|
| 30 |
|
|
terms of your choice, provided that you also meet, for each linked
|
| 31 |
|
|
independent module, the terms and conditions of the license of that
|
| 32 |
|
|
module. An independent module is a module which is not derived from
|
| 33 |
|
|
or based on this library. If you modify this library, you may extend
|
| 34 |
|
|
this exception to your version of the library, but you are not
|
| 35 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
| 36 |
|
|
exception statement from your version. */
|
| 37 |
|
|
|
| 38 |
|
|
package javax.swing;
|
| 39 |
|
|
|
| 40 |
|
|
import java.awt.event.ActionListener;
|
| 41 |
|
|
import java.beans.PropertyChangeListener;
|
| 42 |
|
|
|
| 43 |
|
|
/**
|
| 44 |
|
|
* Provides a convenient central point of control for some task
|
| 45 |
|
|
* that can be triggered by more than one control in a Swing user interface
|
| 46 |
|
|
* (for example, a menu item and a toolbar button).
|
| 47 |
|
|
*
|
| 48 |
|
|
* @see AbstractButton#setAction(Action)
|
| 49 |
|
|
*
|
| 50 |
|
|
* @author Ronald Veldema (rveldema@cs.vu.nl)
|
| 51 |
|
|
* @author Andrew Selkirk
|
| 52 |
|
|
*/
|
| 53 |
|
|
public interface Action extends ActionListener {
|
| 54 |
|
|
|
| 55 |
|
|
/**
|
| 56 |
|
|
* A key to access the default property for the action (this is not used).
|
| 57 |
|
|
*/
|
| 58 |
|
|
String DEFAULT = "Default";
|
| 59 |
|
|
|
| 60 |
|
|
/**
|
| 61 |
|
|
* A key to access the long description for the action.
|
| 62 |
|
|
*/
|
| 63 |
|
|
String LONG_DESCRIPTION = "LongDescription";
|
| 64 |
|
|
|
| 65 |
|
|
/**
|
| 66 |
|
|
* A key to access the name for the action.
|
| 67 |
|
|
*/
|
| 68 |
|
|
String NAME = "Name";
|
| 69 |
|
|
|
| 70 |
|
|
/**
|
| 71 |
|
|
* A key to access the short description for the action (the short
|
| 72 |
|
|
* description is typically used as the tool tip text).
|
| 73 |
|
|
*/
|
| 74 |
|
|
String SHORT_DESCRIPTION = "ShortDescription";
|
| 75 |
|
|
|
| 76 |
|
|
/**
|
| 77 |
|
|
* A key to access the icon for the action.
|
| 78 |
|
|
*/
|
| 79 |
|
|
String SMALL_ICON = "SmallIcon";
|
| 80 |
|
|
|
| 81 |
|
|
/**
|
| 82 |
|
|
* A key to access the {@link KeyStroke} used as the accelerator for the
|
| 83 |
|
|
* action.
|
| 84 |
|
|
*/
|
| 85 |
|
|
String ACCELERATOR_KEY = "AcceleratorKey";
|
| 86 |
|
|
|
| 87 |
|
|
/**
|
| 88 |
|
|
* A key to access the action command string for the action.
|
| 89 |
|
|
*/
|
| 90 |
|
|
String ACTION_COMMAND_KEY = "ActionCommandKey";
|
| 91 |
|
|
|
| 92 |
|
|
/**
|
| 93 |
|
|
* A key to access the mnemonic for the action.
|
| 94 |
|
|
*/
|
| 95 |
|
|
String MNEMONIC_KEY = "MnemonicKey";
|
| 96 |
|
|
|
| 97 |
|
|
/**
|
| 98 |
|
|
* Returns the value associated with the specified key.
|
| 99 |
|
|
*
|
| 100 |
|
|
* @param key the key (not <code>null</code>).
|
| 101 |
|
|
*
|
| 102 |
|
|
* @return The value associated with the specified key, or
|
| 103 |
|
|
* <code>null</code> if the key is not found.
|
| 104 |
|
|
*/
|
| 105 |
|
|
Object getValue(String key);
|
| 106 |
|
|
|
| 107 |
|
|
/**
|
| 108 |
|
|
* Sets the value associated with the specified key and sends a
|
| 109 |
|
|
* {@link java.beans.PropertyChangeEvent} to all registered listeners.
|
| 110 |
|
|
* The standard keys are defined in this interface: {@link #NAME},
|
| 111 |
|
|
* {@link #SHORT_DESCRIPTION}, {@link #LONG_DESCRIPTION},
|
| 112 |
|
|
* {@link #SMALL_ICON}, {@link #ACTION_COMMAND_KEY},
|
| 113 |
|
|
* {@link #ACCELERATOR_KEY} and {@link #MNEMONIC_KEY}. Any existing value
|
| 114 |
|
|
* associated with the key will be overwritten.
|
| 115 |
|
|
*
|
| 116 |
|
|
* @param key the key (not <code>null</code>).
|
| 117 |
|
|
* @param value the value (<code>null</code> permitted).
|
| 118 |
|
|
*/
|
| 119 |
|
|
void putValue(String key, Object value);
|
| 120 |
|
|
|
| 121 |
|
|
/**
|
| 122 |
|
|
* Returns the flag that indicates whether or not this action is enabled.
|
| 123 |
|
|
*
|
| 124 |
|
|
* @return The flag.
|
| 125 |
|
|
*/
|
| 126 |
|
|
boolean isEnabled();
|
| 127 |
|
|
|
| 128 |
|
|
/**
|
| 129 |
|
|
* Sets the flag that indicates whether or not this action is enabled. If
|
| 130 |
|
|
* the value changes, a {@link java.beans.PropertyChangeEvent} is sent to
|
| 131 |
|
|
* all registered listeners.
|
| 132 |
|
|
*
|
| 133 |
|
|
* @param b the new value of the flag.
|
| 134 |
|
|
*/
|
| 135 |
|
|
void setEnabled(boolean b);
|
| 136 |
|
|
|
| 137 |
|
|
/**
|
| 138 |
|
|
* Registers a listener to receive notification whenever one of the
|
| 139 |
|
|
* action's properties is modified.
|
| 140 |
|
|
*
|
| 141 |
|
|
* @param listener the listener.
|
| 142 |
|
|
*/
|
| 143 |
|
|
void addPropertyChangeListener(PropertyChangeListener listener);
|
| 144 |
|
|
|
| 145 |
|
|
/**
|
| 146 |
|
|
* Deregisters a listener so that it no longer receives notification of
|
| 147 |
|
|
* changes to the action's properties.
|
| 148 |
|
|
*
|
| 149 |
|
|
* @param listener the listener.
|
| 150 |
|
|
*/
|
| 151 |
|
|
void removePropertyChangeListener(PropertyChangeListener listener);
|
| 152 |
|
|
|
| 153 |
|
|
} // Action
|