public abstract class PEAction
extends javax.swing.AbstractAction
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]
Constructor and Description |
---|
PEAction(ActionDispatcher actionDispatcher,
java.lang.String actionName,
ActionLocalizer localizer)
Constructor to be used either :
when the target board is not known in advance (e.g.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.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,
java.lang.Object value)
Applies the given attribute to the drawing content.
|
protected void |
undoableActionPerformed(java.awt.event.ActionEvent e)
called by "actionPerformed" ; default implementation does nothing.
|
public PEAction(ActionDispatcher actionDispatcher, java.lang.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).public void actionPerformed(java.awt.event.ActionEvent e)
Action that don't want to be undoable should simply override this method as usual.
protected void undoableActionPerformed(java.awt.event.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, java.lang.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
).
Submit a bug : syd@jpicedt.org