|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.pietschy.command.Command
public abstract class Command
This is the base class for all Commands. It provides all code for creating initialising
and managing the attachements (buttons/menus) of the command. The two main subclasses
are ActionCommand
and CommandGroup
.
ActionCommand
,
CommandGroup
,
Face
Field Summary | |
---|---|
protected Logger |
internalLog
|
protected javax.swing.event.EventListenerList |
listenerList
|
protected javax.swing.event.SwingPropertyChangeSupport |
pcs
|
Constructor Summary | |
---|---|
protected |
Command(CommandManager commandManager)
Creates a new anonymous command. |
protected |
Command(CommandManager commandManager,
java.lang.String id)
Constructs a new Command object with the specified Id. |
Method Summary | |
---|---|
void |
addFace(Face face)
Deprecated. use getFace(String, boolean) or getDefaultFace(boolean) instead. |
void |
addHoverListener(HoverListener l)
Adds a HoverListener to the command manager. |
Face |
addNewFace(java.lang.String faceName)
Deprecated. @deprecated use getFace(String, boolean) or getDefaultFace(boolean) instead. |
void |
addNotify(CommandGroup parent)
Invoked whenever a command is added to a group. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds a property change listener to this command. |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener l)
Adds a property change listener to this command. |
void |
attach(javax.swing.AbstractButton button,
java.lang.String faceName)
Attaches this command to the specified button. |
protected java.util.Iterator |
buttonIterator()
Creates and returns an iterator over the buttons. |
protected void |
configureButtonAppearance(javax.swing.AbstractButton button)
Configures the appearance of the specified button. |
protected void |
configureButtonAppearances()
Reconfigures the appearances of all buttons bound to this command. |
protected void |
configureButtonAppearances(Face face)
Reconfigures all the buttons attached to this command that have the specified face. |
protected void |
configureButtonStates(javax.swing.AbstractButton button)
This method is called to configureMenu newly created buttons. |
javax.swing.AbstractButton |
createButton()
Creates a new button that is attached to the command. |
javax.swing.AbstractButton |
createButton(ButtonFactory factory)
Create a new button for this command using the specified ButtonFactory . |
javax.swing.AbstractButton |
createButton(ButtonFactory factory,
java.lang.String faceId)
Create a new button for this command using the specified ButtonFactory and Face . |
javax.swing.AbstractButton |
createButton(java.lang.String faceId)
Creates a new button that is attached to the command using the specified face. |
javax.swing.JMenuItem |
createMenuItem()
Creates a new menu item for this command. |
javax.swing.JMenuItem |
createMenuItem(MenuFactory factory)
Creates a new menu item for this command using Face.MENU and the specified
MenuFactory . |
javax.swing.JMenuItem |
createMenuItem(MenuFactory factory,
java.lang.String faceId)
Creates a new menu item for this command using the specified Face and the specified
MenuFactory . |
javax.swing.JMenuItem |
createMenuItem(java.lang.String faceId)
Creates a new menu item for this command using the specifed Face name and the
currently configured MenuFactory . |
void |
detach(javax.swing.AbstractButton button)
Detaches this command from the specified button. |
Command |
export()
Registers this command with its CommandManager . |
boolean |
faceExists(java.lang.String faceName)
|
protected void |
fireHoverEnded(Face face,
java.awt.Component source)
|
protected void |
fireHoverStarted(Face face,
java.awt.Component source)
|
javax.swing.KeyStroke |
getAccelerator()
Deprecated. use getDefaultFace() instead. |
java.lang.String[] |
getAlternativeFaceNames(java.lang.String face)
Gets a list of face names that can be used in place of the specified name if it hasn't been registered with the command. |
ButtonFactory |
getButtonFactory()
Gets the button factory to use for this command. |
javax.swing.AbstractButton |
getButtonIn(java.awt.Container container)
This method will find the first button from this command in the specified container. |
CommandManager |
getCommandManager()
Gets the CommandManager this command belongs to. |
Face |
getDefaultFace()
Gets this commands default face. |
Face |
getDefaultFace(boolean createIfMissing)
Gets this commands default face. |
java.lang.String |
getDescription()
Deprecated. use getDefaultFace() instead. |
Face |
getFace(java.lang.String faceName)
Gets the best matching face for the specified name. |
Face |
getFace(java.lang.String faceName,
boolean createIfMissing)
Gets the face with the specified name. |
javax.swing.Icon |
getIcon()
Deprecated. use getDefaultFace() instead. |
java.lang.String |
getId()
Gets this commands identifier. |
java.lang.String |
getLongDescription()
Deprecated. use getDefaultFace() instead. |
MenuFactory |
getMenuFactory()
Gets the MenuFactory to use for this command when creating menu items. |
java.lang.Integer |
getMnemonic()
Deprecated. use getDefaultFace() instead. |
java.lang.Integer |
getMnemonicIndex()
Deprecated. use getDefaultFace() instead. |
java.lang.String |
getProperty(java.lang.String name)
|
java.lang.String |
getProperty(java.lang.String name,
java.lang.String defaultValue)
|
java.lang.String[] |
getPropertyNames()
|
javax.swing.Icon |
getSelectedIcon()
Deprecated. use getDefaultFace() instead. |
java.lang.String |
getText()
Deprecated. use getDefaultFace() instead. |
java.lang.Integer |
getTextPosition()
Deprecated. use getDefaultFace() instead. |
ToolbarFactory |
getToolbarFactory()
Gets the toolbar factory to use for this command. |
protected void |
initCommandManager(CommandManager commandManager)
|
protected void |
installFace(Face face)
Adds a the specified face to the command. |
boolean |
isAnonymous()
Checks if this is an anonymous command. |
boolean |
isAttachedTo(javax.swing.JComponent b)
Tests if this command is attached to the specified button. |
boolean |
isEnabled()
Checks the enabled state of this action and it's attached buttons. |
boolean |
isVisible()
Checks if the buttons of this command are visible. |
void |
putProperty(java.lang.String name,
java.lang.String value)
|
void |
removeHoverListener(HoverListener l)
Removes the HoverListener from the command manager. |
void |
removeNotify(CommandGroup parent)
Invoked whenever a command is remvoved from a group. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes the listener from this command |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener l)
Removes the listener from this command |
void |
requestFocusIn(java.awt.Container container)
This method will find the first button from this command in the specified container and call JComponent.requestFocus() followed by Component.repaint() . |
void |
setAccelerator(javax.swing.KeyStroke accelerator)
Deprecated. use getDefaultFace() instead. |
void |
setButtonFactory(ButtonFactory factory)
Sets the ButtonFactory for this command to use for default when creating
buttons. |
void |
setDescription(java.lang.String shortDescription)
Deprecated. use getDefaultFace() instead. |
void |
setEnabled(boolean enabled)
Updates the enabled state of this command and any attached buttons. |
void |
setIcon(javax.swing.Icon icon)
Deprecated. use getDefaultFace() instead. |
void |
setLongDescription(java.lang.String longDescription)
Deprecated. use getDefaultFace() instead. |
void |
setMenuFactory(MenuFactory factory)
Sets the MenuFactory to use for menus created by this command. |
void |
setMnemonic(java.lang.Integer mnemonic)
Deprecated. use getDefaultFace() instead. |
void |
setMnemonicIndex(java.lang.Integer mnemonicIndex)
Deprecated. use getDefaultFace() instead. |
void |
setSelectedIcon(javax.swing.Icon newSelectedIcon)
Deprecated. use getDefaultFace() instead. |
void |
setText(java.lang.String text)
Deprecated. use getDefaultFace() instead. |
void |
setTextPosition(java.lang.Integer textPosition)
Deprecated. use getDefaultFace() instead. |
void |
setToolbarFactory(ToolbarFactory factory)
Sets the ToolbarFactory for this command to use for default when creating
buttons on toolbars. |
void |
setVisible(boolean value)
Sets the command and all it's buttons to be visible or not. |
java.lang.String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected javax.swing.event.EventListenerList listenerList
protected javax.swing.event.SwingPropertyChangeSupport pcs
protected Logger internalLog
Constructor Detail |
---|
protected Command(CommandManager commandManager)
protected Command(CommandManager commandManager, java.lang.String id)
commandManager
- id
- the identifier of this command.Method Detail |
---|
protected void initCommandManager(CommandManager commandManager)
public java.lang.String getId()
public boolean isAnonymous()
CommandManager
. They are useful when you need
to programatically create a command.
All commands created without an identifier are anonymous.
public Command export()
CommandManager
. Once exported the command
will be available for use in groups
.
java.lang.IllegalStateException
- if this command is anonymous
.public CommandManager getCommandManager()
CommandManager
this command belongs to.
CommandManager
.public void putProperty(java.lang.String name, java.lang.String value)
public java.lang.String getProperty(java.lang.String name)
public java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
public java.lang.String[] getPropertyNames()
public void addNotify(CommandGroup parent)
parent
- the parent to which the command was added.public void removeNotify(CommandGroup parent)
parent
- the parent from which the command was removed.public void attach(javax.swing.AbstractButton button, java.lang.String faceName)
button
- the button to which this command should be attached.public void detach(javax.swing.AbstractButton button)
button
- the button from which this command is to be detached.public boolean isAttachedTo(javax.swing.JComponent b)
b
- the button to check
protected void configureButtonStates(javax.swing.AbstractButton button)
button
- the button to configureMenu.public ButtonFactory getButtonFactory()
setButtonFactory(org.pietschy.command.ButtonFactory)
, then the default factory specified
by CommandManager.setButtonFactory(org.pietschy.command.ButtonFactory)
.
ButtonFactory
.setButtonFactory(org.pietschy.command.ButtonFactory)
,
CommandManager.setButtonFactory(org.pietschy.command.ButtonFactory)
public void setButtonFactory(ButtonFactory factory)
ButtonFactory
for this command to use for default when creating
buttons.
factory
- the ButtonFactory
to use.public ToolbarFactory getToolbarFactory()
setToolbarFactory(org.pietschy.command.ToolbarFactory)
, then the default factory specified
by CommandManager.setToolbarFactory(org.pietschy.command.ToolbarFactory)
is used.
ButtonFactory
.setToolbarFactory(org.pietschy.command.ToolbarFactory)
,
CommandManager.setToolbarFactory(org.pietschy.command.ToolbarFactory)
public void setToolbarFactory(ToolbarFactory factory)
ToolbarFactory
for this command to use for default when creating
buttons on toolbars.
factory
- the ButtonFactory
to use.public MenuFactory getMenuFactory()
MenuFactory
to use for this command when creating menu items. If the
factory hasn't been configured by calling setMenuFactory(org.pietschy.command.MenuFactory)
then the value provided
by CommandManager.getMenuFactory()
is used.
MenuFactory
to use.public void setMenuFactory(MenuFactory factory)
MenuFactory
to use for menus created by this command.
factory
- the MenuFactory
to use.public void setEnabled(boolean enabled)
enabled
- true
to enable the command.public boolean isEnabled()
true
if the command is enabled.public void setVisible(boolean value)
value
- public boolean isVisible()
public java.lang.String getText()
getDefaultFace()
instead.
public void setText(java.lang.String text)
getDefaultFace()
instead.
public javax.swing.KeyStroke getAccelerator()
getDefaultFace()
instead.
public void setAccelerator(javax.swing.KeyStroke accelerator)
getDefaultFace()
instead.
public void setMnemonic(java.lang.Integer mnemonic)
getDefaultFace()
instead.
public void setLongDescription(java.lang.String longDescription)
getDefaultFace()
instead.
public void setIcon(javax.swing.Icon icon)
getDefaultFace()
instead.
public void setSelectedIcon(javax.swing.Icon newSelectedIcon)
getDefaultFace()
instead.
public void setMnemonicIndex(java.lang.Integer mnemonicIndex)
getDefaultFace()
instead.
public void setDescription(java.lang.String shortDescription)
getDefaultFace()
instead.
public void setTextPosition(java.lang.Integer textPosition)
getDefaultFace()
instead.
public java.lang.Integer getTextPosition()
getDefaultFace()
instead.
public java.lang.Integer getMnemonic()
getDefaultFace()
instead.
public javax.swing.Icon getIcon()
getDefaultFace()
instead.
public javax.swing.Icon getSelectedIcon()
getDefaultFace()
instead.
public java.lang.Integer getMnemonicIndex()
getDefaultFace()
instead.
public java.lang.String getDescription()
getDefaultFace()
instead.
public java.lang.String getLongDescription()
getDefaultFace()
instead.
public void addFace(Face face)
getFace(String, boolean)
or getDefaultFace(boolean)
instead.
face
- the new Face to installFace.protected void installFace(Face face)
face
- the new Face to installFace.public Face addNewFace(java.lang.String faceName)
getFace(String, boolean)
or getDefaultFace(boolean)
instead.
faceName
- the name of the face, "button" for example.
protected java.util.Iterator buttonIterator()
public Face getDefaultFace()
Face.DEFAULT
. If no face exists with this name, then the first
registered face is returned.
public Face getDefaultFace(boolean createIfMissing)
Face.DEFAULT
. If no face exists with this name, then the first
registered face is returned.
createIfMissing
- true
to create the face if it doesn't exist,
false
to return null if it doesn't exists.
public Face getFace(java.lang.String faceName)
getAlternativeFaceNames(java.lang.String)
.
If non of these faces exist, then the default face is returned.
faceName
- the name of the face to retrieved. Face.BUTTON
for example.
getAlternativeFaceNames(java.lang.String)
.public Face getFace(java.lang.String faceName, boolean createIfMissing)
faceName
- the name of the face to retrieved. Face.BUTTON
for example.createIfMissing
- true
to create the face if it doesn't exist, false
to
return the best matching face as determined by getAlternativeFaceNames(String)
.
getAlternativeFaceNames(java.lang.String)
.public boolean faceExists(java.lang.String faceName)
public java.lang.String[] getAlternativeFaceNames(java.lang.String face)
face
- the face name
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
l
- the listenerpublic void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)
propertyName
- the property to listen to.l
- the listenerpublic void removePropertyChangeListener(java.beans.PropertyChangeListener l)
l
- the listenerpublic void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)
propertyName
- the property to stop listening to.l
- the listenerpublic void addHoverListener(HoverListener l)
HoverListener
to the command manager. The listener will be notified when
ever the mouse hovers over a command.
l
- the hover listenerHoverListener
,
removeHoverListener(org.pietschy.command.HoverListener)
public void removeHoverListener(HoverListener l)
HoverListener
from the command manager.
l
- the hover listenerHoverListener
,
addHoverListener(org.pietschy.command.HoverListener)
protected void fireHoverStarted(Face face, java.awt.Component source)
protected void fireHoverEnded(Face face, java.awt.Component source)
public void requestFocusIn(java.awt.Container container)
JComponent.requestFocus()
followed by Component.repaint()
.
container
- the container that holds a button from this command.public javax.swing.AbstractButton getButtonIn(java.awt.Container container)
container
- the container that holds a button from this command.public javax.swing.AbstractButton createButton()
public javax.swing.AbstractButton createButton(java.lang.String faceId)
public javax.swing.AbstractButton createButton(ButtonFactory factory)
ButtonFactory
. The default
Face.BUTTON
is used, it it hasn't been defined, the Face.DEFAULT
is used.
ButtonFactory
public javax.swing.AbstractButton createButton(ButtonFactory factory, java.lang.String faceId)
ButtonFactory
and Face
. If the Face
is
null the default face Face.DEFAULT
for this command is used.
public javax.swing.JMenuItem createMenuItem()
Face.MENU
and the currently configured MenuFactory
. If Face.MENU
hasn't been
configured then the default face is used.
JMenuItem
.createMenuItem(java.lang.String)
,
createMenuItem(org.pietschy.command.MenuFactory, java.lang.String)
,
createMenuItem(org.pietschy.command.MenuFactory)
public javax.swing.JMenuItem createMenuItem(java.lang.String faceId)
Face
name and the
currently configured MenuFactory
.
JMenuItem
.createMenuItem(org.pietschy.command.MenuFactory, java.lang.String)
,
createMenuItem(org.pietschy.command.MenuFactory)
public javax.swing.JMenuItem createMenuItem(MenuFactory factory)
Face.MENU
and the specified
MenuFactory
. If Face.MENU
hasn't been specified, then the default is
used.
createMenuItem(org.pietschy.command.MenuFactory, java.lang.String)
public javax.swing.JMenuItem createMenuItem(MenuFactory factory, java.lang.String faceId)
Face
and the specified
MenuFactory
.
JMenuItem
.protected void configureButtonAppearances()
protected void configureButtonAppearances(Face face)
face
- the face whose buttons are to be reconfigured.protected void configureButtonAppearance(javax.swing.AbstractButton button)
RenderManager.renderButton(javax.swing.AbstractButton)
.
button
- the button to configure.public java.lang.String toString()
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character '@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |