|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.AbstractAction jpicedt.graphic.toolkit.PEAbstractAction<T>
public abstract class PEAbstractAction<T>
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 PEAbstractAction 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).
Field Summary | |
---|---|
protected T |
targetElement
|
Fields inherited from class javax.swing.AbstractAction |
---|
changeSupport, enabled |
Fields inherited from interface javax.swing.Action |
---|
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary | |
---|---|
PEAbstractAction(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 abstract Iterator<T> |
getIterator()
|
protected T |
getSelectedObject()
Returns the selected graphic element in the target board ; if setSelectedObject() has been previously called with a non-null argument, it's returned here. |
void |
setSelectedObject(T e)
Sets the selected graphic element "by hand". |
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 |
Field Detail |
---|
protected T targetElement
Constructor Detail |
---|
public PEAbstractAction(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.localizer
- 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 PEAbstractAction'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 T getSelectedObject()
public void setSelectedObject(T e)
protected abstract Iterator<T> getIterator()
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |