|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.AbstractAction
com.japisoft.xmlpad.action.XMLAction
Abstract class for XML action.
The XMLAction class is shared between serveral XMLContainers
. Each time an
XMLContainers take the focus, all XMLAction are resetted for taking into account the
current XMLContainer. This is possible with the setXMLContainer
method. You can force
the usage of an XMLContainer calling ActionModel.resetActionState
This action takes an XMLContainer and XMLEditor context for working. You can invoke
an action by calling notifyAction
. The icon is found from the current classpath
searching for an "Action" class name an "Action16.gif" or "Action24.gif" depending on the IMAGE_SIZE value.
Otherwise, user can have its own icon location by overriding the getDefaultIcon
method.
If you don't wish to use .gif image, please call XMLAction.IMAGE_EXT = EXT
If your action works only on the real time tree, you must implement the TreeAction
interface or inherit
from the com.japisoft.xmlpad.tree.action.AbstractTreeAction
You can change or traduce default label and tooltip using Properties file (from PropertyResourceBundle spec). This property file is found using the getName() value. So if you have a com.MyAction class, the property file will be found in the com/MyAction.properties path from the classpath. Use a LABEL key and a TOOLTIP key... like :
LABEL=myActionName
TOOLTIP=This is ...
MNEMONIC=A
ACCELERATOR=ctrl A
ICON=com/japisoft/xmlpad/action/edit/CopyAction16.gif
GROUP=Edit
To override a default action descriptor. Create a file from the default action name and inserts it before in your classpath the xmlpad.jar. For instance if you want to change the label of the NewAction, create a com/japisoft/xmlpad/action/new/NewAction.properties with a LABEL key or change the default one inside the xmlpad.jar
When adding an action in an existing group, you can override the getActionGroup method to match the good group or called setActionReferenceGroup to use the same group than the action name argument :
class MyAction extends XMLAction {
public MyAction() {
super();
}
public String getPopupGroup() { return "Edit"; }
}
or
class MyAction extends XMLAction {
public MyAction() {
setActionReferenceGroup( ActionModel.CUT_ACTION );
}
}
UIManager properties : - xmlpad.action.[FULL ACTION CLASS NAME].mnemonic (a string) - xmlpad.action.[FULL ACTION CLASS NAME].accelerator(a string) - xmlpad.action.[FULL ACTION CLASS NAME].label - xmlpad.action.[FULL ACTION CLASS NAME].tooltip - xmlpad.action.[FULL ACTION CLASS NAME].icon
Nested Class Summary | |
static class |
XMLAction.EmptyIcon
Empty icon for alignment on popup |
Field Summary | |
static boolean |
AUTO_UI
Use default method for building UI part. |
protected XMLContainer |
container
|
protected XMLEditor |
editor
|
protected java.lang.String |
groupName
XMLAction group reference name |
static java.lang.String |
IMAGE_EXT
Default image file extension |
static int |
IMAGE_SIZE
Default image size |
static boolean |
INVALID_ACTION
Status returned by the notifyAction |
protected java.lang.Object |
param
|
static boolean |
RESOURCE_BUNDLE
Use a resource bundle for tabel/tooltip/shortcut/icon. |
static boolean |
VALID_ACTION
Status returned by the notifyAction |
Fields inherited from class javax.swing.AbstractAction |
changeSupport, enabled |
Fields inherited from interface com.japisoft.xmlpad.action.Features |
VALIDATING_FEATURE |
Fields inherited from interface com.japisoft.xmlpad.action.Properties |
FILE_ENCODING, INDENT_CHAR_PROPERTY, INDENT_SIZE_PROPERTY |
Fields inherited from interface javax.swing.Action |
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON |
Constructor Summary | |
XMLAction()
|
|
XMLAction(java.lang.String actionReference)
ActionReference is a way to use the same icon than another known action |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent e)
Don't override it, this method will call the notifyAction if an editor is available |
protected boolean |
autoRequestFocus()
|
void |
dispose()
Reset all reference to XMLEditor and XMLContainer. |
protected javax.swing.KeyStroke |
getDefaultAccelerator()
|
protected javax.swing.Icon |
getDefaultIcon()
|
protected java.lang.String |
getDefaultLabel()
|
protected char |
getDefaultMnemonic()
|
protected java.lang.String |
getDefaultTooltip()
|
protected java.lang.String |
getLabel(java.lang.String name,
java.lang.String def)
|
java.lang.String |
getName()
Return the name of the action. |
java.lang.Object |
getParam()
|
java.lang.String |
getPopupGroup()
With this group you can create sub-menu inside the popup. |
java.lang.Object |
getProperty(java.lang.String propertyName,
java.lang.Object defaultValue)
|
XMLContainer |
getXMLContainer()
|
XMLEditor |
getXMLEditor()
|
boolean |
hasFeature(java.lang.String feature)
|
protected void |
installUIContent()
Reset the default icon and the default text |
boolean |
isPopable()
|
boolean |
isToolbarable()
|
abstract boolean |
notifyAction()
Notify action must be done. |
protected void |
notifyXMLContainer()
Notify that an XMLContainer has been provided for futur action |
protected void |
notifyXMLEditor()
Notify that an XMLEditor has been provided for futur action |
void |
setActionDelegate(javax.swing.Action listener)
Set a delegate for receiving the action event. |
void |
setActionReferenceGroup(java.lang.String actionReference)
Override the default group name using the group name used by this actionReference |
void |
setActionReferenceIcon(java.lang.String actionReference)
Override the default icon using the icon of another action. |
void |
setFeature(java.lang.String feature,
boolean enabled)
Set a feature for the action |
void |
setParam(java.lang.Object param)
Set an optionnal parameter. |
void |
setPopable(boolean popable)
Decide to include this action in a popup menu |
void |
setProperty(java.lang.String propertyName,
java.lang.Object value)
Reset a property value for this action. |
void |
setToolbarable(boolean inToolbar)
Decide to include this action in the main toolbar. |
void |
setXMLContainer(XMLContainer container)
Set the current XMLEditor for action |
void |
setXMLEditor(XMLEditor editor)
Set the current XMLEditor for action |
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 |
public static int IMAGE_SIZE
public static java.lang.String IMAGE_EXT
public static boolean RESOURCE_BUNDLE
SharedProperties
public static boolean AUTO_UI
true
public static boolean VALID_ACTION
public static boolean INVALID_ACTION
protected java.lang.String groupName
protected XMLEditor editor
protected XMLContainer container
protected java.lang.Object param
Constructor Detail |
public XMLAction()
public XMLAction(java.lang.String actionReference)
actionReference
- another action class nameMethod Detail |
public void dispose()
public void setActionReferenceIcon(java.lang.String actionReference)
actionReference
- Action namepublic void setActionReferenceGroup(java.lang.String actionReference)
public void setPopable(boolean popable)
public boolean isPopable()
true
if this action can be integrated in a popup menu. By default true
public void setToolbarable(boolean inToolbar)
true
public boolean isToolbarable()
true
if the toolbar can be include in the main toolbarprotected java.lang.String getLabel(java.lang.String name, java.lang.String def)
protected void installUIContent()
protected javax.swing.Icon getDefaultIcon()
protected java.lang.String getDefaultLabel()
protected java.lang.String getDefaultTooltip()
protected char getDefaultMnemonic()
protected javax.swing.KeyStroke getDefaultAccelerator()
public java.lang.String getPopupGroup()
null
public void setXMLEditor(XMLEditor editor)
public XMLEditor getXMLEditor()
protected void notifyXMLEditor()
public void setXMLContainer(XMLContainer container)
public XMLContainer getXMLContainer()
protected void notifyXMLContainer()
protected boolean autoRequestFocus()
true
for editor focus at the end of the action. By default true
public void actionPerformed(java.awt.event.ActionEvent e)
notifyAction
if an editor is available
actionPerformed
in interface java.awt.event.ActionListener
public void setActionDelegate(javax.swing.Action listener)
public abstract boolean notifyAction()
public java.lang.String getName()
public void setParam(java.lang.Object param)
notifyAction
public java.lang.Object getParam()
public void setFeature(java.lang.String feature, boolean enabled)
public boolean hasFeature(java.lang.String feature)
public java.lang.Object getProperty(java.lang.String propertyName, java.lang.Object defaultValue)
XMLAction
has not overrided it a null
value will be returnedpublic void setProperty(java.lang.String propertyName, java.lang.Object value)
propertyName
- Property namevalue
- Property value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |