|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.AbstractAction
jpicedt.graphic.toolkit.PEAction
public abstract class PEAction
An abstract subclass of Swing's AbstractAction that can (but may as well not) be shared across multiple PECanvas.
This implementation uses the same set of properties as AbstractAction.
The constructor gives a convenient way of automatically building localized properties
associated with this PEAction from a simple String (the "actionName" parameter), using a
user-provided ActionLocalizer.
Note : if an ActionLocalizer is provided to the constructor, and some of its methods return null values,
the corresponding properties are set to null. However, all jPicEdt components (e.g. PEMenu, PEToolBar,...),
like Swing components, are guaranteed to handle this case properly w/o throwing an exception.
For instance, simply setting the NAME property to null and filling the SMALL_ICON property
create a JButton without text under the component's Icon (this is the standard Swing behaviour).
Example of use : [todo]
Field Summary |
---|
Fields inherited from class javax.swing.AbstractAction |
---|
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
---|
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary | |
---|---|
PEAction(ActionDispatcher actionDispatcher,
String actionName,
ActionLocalizer localizer)
Constructor to be used either : when the target board is not known in advance (e.g. |
Method Summary | |
---|---|
void |
actionPerformed(ActionEvent e)
This is a default implementation of the "actionPerformed" method suited for undoable actions : we first call "beginUndoableUpdate" with "actionName" as the presentation name, then delegate to "undoableActionPerformed", finally mark the undoable-update as ended. |
protected PECanvas |
getCanvas()
Returns the PECanvas this Action acts upon, as specified by the ActionDispatcher provided in the constructor. |
protected Drawing |
getDrawing()
Returns the Drawing that serves as a model for the target PECanvas (this is a convenience call to getCanvas() . |
protected EditorKit |
getEditorKit()
Returns the EditorKit associated with the target PECanvas (this is a convenience call to getCanvas() . |
protected Element |
getSelectedObject()
Returns the selected graphic element in the target board ; |
protected void |
setAttribute(PicAttributeName name,
Object value)
Applies the given attribute to the drawing content. |
protected void |
undoableActionPerformed(ActionEvent e)
called by "actionPerformed" ; default implementation does nothing. |
Methods inherited from class javax.swing.AbstractAction |
---|
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PEAction(ActionDispatcher actionDispatcher, String actionName, ActionLocalizer localizer)
actionDispatcher
- the ActionDispatcher that provides a
target when this Action gets invoked. If set to null, then subclasses may want to simply override actionPerformed().actionName
- the actionName of this Action that serve to build this Action's properties using
the given ActionLocalizer (if non-null) ; in any case, actionName is used to fill the
ACTION_COMMAND_KEY property.actionLocalizer
- the ActionLocalizer that feeds this Action with localized properties ;
if null, the Action's NAME property is simply initialized to actionName, but other
properties are not set (this allow a subclass to set these properties manually).Method Detail |
---|
public void actionPerformed(ActionEvent e)
Action that don't want to be undoable should simply override this method as usual.
protected void undoableActionPerformed(ActionEvent e)
Note : this is not an abstract method, since this would force all PEAction's, including those we don't want to be undoable, to implement this method.
protected PECanvas getCanvas()
protected Drawing getDrawing()
getCanvas()
.
protected EditorKit getEditorKit()
getCanvas()
.
protected Element getSelectedObject()
protected final void setAttribute(PicAttributeName name, Object value)
If there's a selected element, we add an UndoableEdit (hence PEAction that explicitly call
setAttribute() must not override undoableActionPerformed
, but simply actionPerformed
).
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |