Class PEAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- jpicedt.graphic.toolkit.PEAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener,java.io.Serializable,java.lang.Cloneable,java.util.EventListener,javax.swing.Action
- Direct Known Subclasses:
EditorKit.CopyAction,EditorKit.CutAction,EditorKit.DeleteAction,EditorKit.EditBoundingBoxAction,EditorKit.EditDispositionAction,EditorKit.EditGeometryAction,EditorKit.GroupAction,EditorKit.JoinCurvesAction,EditorKit.PasteAction,EditorKit.SelectAllAction,EditorKit.SelectMouseToolAction,EditorKit.ToggleEditPointsModeAction,EditorKit.UngroupAction,EditorKit.ZoomInAction,EditorKit.ZoomOutAction,JPicEdt.AboutAction,JPicEdt.ContentTypeAction,JPicEdt.ExitAction,JPicEdt.FileCloseAction,JPicEdt.FileNewAction,JPicEdt.FileOpenAction,JPicEdt.FileReloadAction,JPicEdt.FileSaveAction,JPicEdt.FileSaveAllAction,JPicEdt.FileSaveAsAction,JPicEdt.FragmentInsertAction,JPicEdt.FragmentSaveAction,JPicEdt.MemoryMonitorAction,JPicEdt.OpenBSHConsoleAction,JPicEdt.PageFormatAction,JPicEdt.PreferencesAction,JPicEdt.RedoAction,JPicEdt.RedrawAction,JPicEdt.RunExternalCommandAction,JPicEdt.ShowErrorLogAction,JPicEdt.ShowHelpAction,JPicEdt.ShowLicenseAction,JPicEdt.ToggleAttributesPanelAction,JPicEdt.ToggleToolkitPanelAction,JPicEdt.UndoAction,JPicEdt.ViewLaTeXFileAction,JPicEdt.WindowCascadeAction,JPicEdt.WindowTileHorAction,JPicEdt.WindowTileVertAction,PEScrollPane.CenterViewportAction,PEToggleAction
public abstract class PEAction extends javax.swing.AbstractActionAn 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]
- Since:
- jPicEdt 1.3.2
- Version:
- $Id: PEAction.java,v 1.8.2.1 2007/09/02 11:56:28 reynal Exp $
- Author:
- Sylvain Reynal
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(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 PECanvasgetCanvas()Returns the PECanvas this Action acts upon, as specified by the ActionDispatcher provided in the constructor.protected DrawinggetDrawing()Returns the Drawing that serves as a model for the target PECanvas (this is a convenience call togetCanvas().protected EditorKitgetEditorKit()Returns the EditorKit associated with the target PECanvas (this is a convenience call togetCanvas().protected ElementgetSelectedObject()Returns the selected graphic element in the target board ;protected voidsetAttribute(PicAttributeName name, java.lang.Object value)Applies the given attribute to the drawing content.protected voidundoableActionPerformed(java.awt.event.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
-
-
-
-
Constructor Detail
-
PEAction
public 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. MDI), and one wants to provide an own ActionDispatcher implementation
- or when the target board is known : in this case use a DefaultActionDispatcher constructed with the given target board.
- Parameters:
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
-
actionPerformed
public 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.Action that don't want to be undoable should simply override this method as usual.
-
undoableActionPerformed
protected void undoableActionPerformed(java.awt.event.ActionEvent e)
called by "actionPerformed" ; default implementation does nothing. Action that want to be undoable override this method instead of "actionPerformed".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.
-
getCanvas
protected PECanvas getCanvas()
Returns the PECanvas this Action acts upon, as specified by the ActionDispatcher provided in the constructor.- Returns:
- a null reference if no suitable canvas is found by the ActionDispatcher.
-
getDrawing
protected Drawing getDrawing()
Returns the Drawing that serves as a model for the target PECanvas (this is a convenience call togetCanvas().
-
getEditorKit
protected EditorKit getEditorKit()
Returns the EditorKit associated with the target PECanvas (this is a convenience call togetCanvas().
-
getSelectedObject
protected Element getSelectedObject()
Returns the selected graphic element in the target board ;- Returns:
- null if there's no selected graphic element, OR more than one.
-
setAttribute
protected final void setAttribute(PicAttributeName name, java.lang.Object value)
Applies the given attribute to the drawing content. If there is a selection, the attribute is applied to each element in the selection. If there is no selection, the attribute is applied to the input attribute set of the EditorKit (this specifies the attributes to be used for any new Element that gets added to the underlying Drawing).If there's a selected element, we add an UndoableEdit (hence PEAction that explicitly call setAttribute() must not override
undoableActionPerformed, but simplyactionPerformed).
-
-