|
|||||||||||
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.
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. |
static boolean |
BUNDLE
Use bundle for tabel/tooltip/shortcut/icon. |
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 |
static boolean |
VALID_ACTION
Status returned by the notifyAction |
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 |
void |
dispose()
Reset all reference to XMLEditor and XMLContainer. |
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)
|
boolean |
isPopable()
|
boolean |
isToolbarable()
|
abstract boolean |
notifyAction()
Notify action must be done. |
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, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled |
Methods inherited from class java.lang.Object |
equals, 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 BUNDLE
public static boolean AUTO_UI
public static boolean VALID_ACTION
public static boolean INVALID_ACTION
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 toolbarpublic java.lang.String getPopupGroup()
null
public void setXMLEditor(XMLEditor editor)
public XMLEditor getXMLEditor()
public void setXMLContainer(XMLContainer container)
public XMLContainer getXMLContainer()
public void actionPerformed(java.awt.event.ActionEvent e)
notifyAction
if an editor is available
actionPerformed
in interface java.awt.event.ActionListener
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 |