Package de.tsl2.nano.action
Class CommonAction<RETURNTYPE>
java.lang.Object
de.tsl2.nano.action.CommonAction<RETURNTYPE>
- Type Parameters:
RETURNTYPE-
- All Implemented Interfaces:
IAction<RETURNTYPE>,Serializable,Comparable<CommonAction<RETURNTYPE>>,Runnable
public abstract class CommonAction<RETURNTYPE>
extends Object
implements IAction<RETURNTYPE>, Serializable, Comparable<CommonAction<RETURNTYPE>>
- Version:
- $Revision$
- Author:
- Thomas Schneider
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IActivableprotected Function<?,RETURNTYPE> while a function is not really serializeable/changeable/deserializeable, this function should only be used, where the action should not be deserialized!protected Stringprotected Stringprotected booleanprotected booleanprotected Objectprotected Stringprotected Parametersprotected Collection<String>protected Stringprotected booleanprotected static final StringFields inherited from interface de.tsl2.nano.action.IAction
CANCELED, MODE_DLG_CANCEL, MODE_DLG_OK, MODE_UNDEFINED -
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor can be used for hidden actions.CommonAction(String id) CommonAction(String id, boolean isDefault, boolean isEnabled, Object keyStroke, String shortDescription, String longDescription, boolean synchron, IActivable actionEnabler, Collection<String> receiverIDs, Function<?, RETURNTYPE> function) ConstructorCommonAction(String id, String shortDescription, String longDescription) CommonAction(String id, String shortDescription, String longDescription, IActivable enabler, Collection<String> receiverIDs, Function<?, RETURNTYPE> function) CommonAction(String id, String shortDescription, String longDescription, IActivable actionEnabler, Function<?, RETURNTYPE> function) CommonAction(String id, String shortDescription, String longDescription, Function<?, RETURNTYPE> function) CommonAction(String id, Function<?, RETURNTYPE> function) -
Method Summary
Modifier and TypeMethodDescriptionaction()The action to be startedactivate()if the action is asynchron, the result will be mostly null.intbooleanintaction mode. e.g. on dialogs it is usable to define the buttons result type. seeIAction.MODE_DLG_CANCEL,IAction.MODE_DLG_OK.Class[]getArgumentTypesgetId()getIdGetter getKeyStrokegetLongDescriptionObject[]getParameter(int i) the receivers will receive the result of the activation.getShortDescriptioninthashCode()protected booleanoverride this method to enable debuggingbooleanisDefaultbooleanisEnabledbooleanbooleanGetter isSynchronprotected voidresetCursor(Object lastCursor) override this method to handle the mouse cursorvoidrun()runvoidsetDefault(boolean isDefault) setDefaultvoidsetEnabled(boolean isEnabled) setEnabledvoidsetEnabler(IActivable enabler) voidsetImagePath(String imagePath) setParameter(Object... parameter) protected Objectoverride this method to handle the mouse cursortoString()
-
Field Details
-
id
-
shortDescription
-
longDescription
-
isDefault
protected boolean isDefault -
isEnabled
protected boolean isEnabled -
synchron
protected boolean synchron -
keyStroke
-
receiverIDs
-
enabler
-
parameter
-
imagePath
-
UNNAMED
- See Also:
-
function
while a function is not really serializeable/changeable/deserializeable, this function should only be used, where the action should not be deserialized! NOTE: technically it is possible to serialize the function, e.g.: (Runnable & Serializable) () -> doSomething;. but it is not changable inside a readable xml serialization like in simple-xml.
-
-
Constructor Details
-
CommonAction
public CommonAction()The default constructor can be used for hidden actions. This are action, not connected to a user interface like a button. -
CommonAction
- Parameters:
id- unique id
-
CommonAction
-
CommonAction
- Parameters:
id- unique idshortDescription- name of the button (representing this action).longDescription- tooltip text of the button (representing this action).
-
CommonAction
public CommonAction(String id, String shortDescription, String longDescription, Function<?, RETURNTYPE> function) -
CommonAction
public CommonAction(String id, String shortDescription, String longDescription, IActivable actionEnabler, Function<?, RETURNTYPE> function) - Parameters:
id- unique idshortDescription- name of the button (representing this action).longDescription- tooltip text of the button (representing this action).instance- for an action enabler
-
CommonAction
public CommonAction(String id, String shortDescription, String longDescription, IActivable enabler, Collection<String> receiverIDs, Function<?, RETURNTYPE> function) - Parameters:
id- unique idshortDescription- name of the button (representing this action).longDescription- tooltip text of the button (representing this action).enabler- is able to to functional checks for button enablingreceiverIDs- ids of visible components to receive the result of this action.
-
CommonAction
public CommonAction(String id, boolean isDefault, boolean isEnabled, Object keyStroke, String shortDescription, String longDescription, boolean synchron, IActivable actionEnabler, Collection<String> receiverIDs, Function<?, RETURNTYPE> function) Constructor- Parameters:
id- unique idisDefault- whether the button (representing this action) is the default button.isEnabled- whether the button (representing this action) is enabled.keyStroke- button key strokelongDescription- tooltip text of the button (representing this action).shortDescription- name of the button (representing this action).synchron- whether this method is synchron or asynchron.function-
-
-
Method Details
-
isEnabled
public boolean isEnabled()isEnabled- Specified by:
isEnabledin interfaceIAction<RETURNTYPE>- Returns:
- Returns the isEnabled.
- See Also:
-
setEnabled
public void setEnabled(boolean isEnabled) setEnabled- Specified by:
setEnabledin interfaceIAction<RETURNTYPE>- Parameters:
isEnabled- The isEnabled to set.- See Also:
-
getEnabler
- Returns:
- Returns the enabler.
-
setEnabler
- Parameters:
enabler- The enabler to set.
-
getId
getId- Specified by:
getIdin interfaceIAction<RETURNTYPE>- Returns:
- Returns the id.
- See Also:
-
getShortDescription
getShortDescription- Specified by:
getShortDescriptionin interfaceIAction<RETURNTYPE>- Returns:
- Returns the shortDescription.
- See Also:
-
getLongDescription
getLongDescription- Specified by:
getLongDescriptionin interfaceIAction<RETURNTYPE>- Returns:
- Returns the longDescription.
- See Also:
-
isDefault
public boolean isDefault()isDefault- Specified by:
isDefaultin interfaceIAction<RETURNTYPE>- Returns:
- Returns the isDefault.
- See Also:
-
setDefault
public void setDefault(boolean isDefault) setDefault- Specified by:
setDefaultin interfaceIAction<RETURNTYPE>- Parameters:
isDefault- whether to set the action as default action
-
isSynchron
public boolean isSynchron()Getter isSynchron- Specified by:
isSynchronin interfaceIAction<RETURNTYPE>- Returns:
- Returns the synchron.
-
isDebugMode
protected boolean isDebugMode()override this method to enable debugging- Returns:
- true, if debugging is enabled
-
action
Description copied from interface:IActionThe action to be started- Specified by:
actionin interfaceIAction<RETURNTYPE>- Returns:
- result of the action. use
IAction.CANCELEDto define for buttons, the action was canceled. - Throws:
Exception
-
run
public void run()run -
activate
if the action is asynchron, the result will be mostly null.- Specified by:
activatein interfaceIAction<RETURNTYPE>- Returns:
- the result
- See Also:
-
setWaitCursor
override this method to handle the mouse cursor- Returns:
- the last cursor instance
-
resetCursor
override this method to handle the mouse cursor- Parameters:
lastCursor- cursor to be set
-
getReceiverIDs
Description copied from interface:IActionthe receivers will receive the result of the activation.- Specified by:
getReceiverIDsin interfaceIAction<RETURNTYPE>- Returns:
- Returns the receiverIDs.
-
parameters
-
getArgumentTypes
Description copied from interface:IActiongetArgumentTypes- Specified by:
getArgumentTypesin interfaceIAction<RETURNTYPE>- Returns:
- optional definition of argument types to check
IAction.getParameter()andIAction.setParameter(Object...). default is null
-
getParameter
- Specified by:
getParameterin interfaceIAction<RETURNTYPE>- Returns:
- Returns the parameter.
-
getParameter
- Specified by:
getParameterin interfaceIAction<RETURNTYPE>
-
setParameter
- Specified by:
setParameterin interfaceIAction<RETURNTYPE>- Parameters:
parameter- The parameter to set.
-
getImagePath
- Specified by:
getImagePathin interfaceIAction<RETURNTYPE>- Returns:
- image
-
getLastResult
-
getKeyStroke
Description copied from interface:IActionGetter getKeyStroke- Specified by:
getKeyStrokein interfaceIAction<RETURNTYPE>- Returns:
- Returns the keyStroke.
-
setImagePath
-
compareTo
- Specified by:
compareToin interfaceComparable<RETURNTYPE>
-
equals
-
hashCode
public int hashCode() -
toString
-
getActionMode
public int getActionMode()action mode. e.g. on dialogs it is usable to define the buttons result type. seeIAction.MODE_DLG_CANCEL,IAction.MODE_DLG_OK.- Specified by:
getActionModein interfaceIAction<RETURNTYPE>- Returns:
- action mode
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceIAction<RETURNTYPE>- Returns:
- Returns the isRunning.
-