Package com.simplicite.util
Class Action
- java.lang.Object
-
- com.simplicite.util.Action
-
- All Implemented Interfaces:
java.io.Serializable
public class Action extends java.lang.Object implements java.io.Serializable
Custom action- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static char
ACTION_ALL
Display both on list header, form and lines of liststatic char
ACTION_FORM
Enable on form / display on form and lines of liststatic char
ACTION_FORM_ONLY
Enable on form / display on form only, not on list itemsstatic char
ACTION_HIDDEN
Hidden on UI (but may be enabled for a cron job)static char
ACTION_LIST
Enable on list / display in list headerstatic char
ACTION_LIST_FORM
Both form and List header (but not on list items)static char
ACTION_LIST_ITEMS_ONLY
Enable on form / display on list items only, not on formstatic char
ACTION_PLUS
In Plus buttonstatic int
ASYNC_ISOLATED
New thread with isolated Grant (outside session) and a new job instance of objectstatic int
ASYNC_NONE
Synchronous call (means that the job will be launched directly after instantiation)static int
ASYNC_SESSION
New thread with the current Grant and the current instance of objectstatic int
ASYNC_STANDALONE
New thread with the current Grant and a new job instance of objectstatic int
LIST_COUNT_NONE
No rows counter on list actionstatic int
LIST_COUNT_SEL_OR_ALL
Count selected rows or all rows if none selected by userstatic int
LIST_COUNT_SELECTED
Count selected rows only
-
Constructor Summary
Constructors Constructor Description Action(Action action, int position, java.lang.String lang)
Copy constructorAction(java.lang.String name, char type, java.util.Map<java.lang.String,java.lang.String> display, java.lang.String image, int position, boolean plus, int count)
Silent constructor (no method, no URL).Action(java.lang.String id, java.lang.String name, char type, java.util.Map<java.lang.String,java.lang.String> display, java.util.Map<java.lang.String,java.lang.String> help, java.lang.String method, java.lang.String expr, java.lang.String url, java.lang.String image, boolean confirm, boolean plus, int async, int asyncDepth, java.lang.String confirmUI, java.lang.String confirmExpr, int countRows)
Deprecated.Action(java.lang.String id, java.lang.String name, char type, java.util.Map<java.lang.String,java.lang.String> display, java.util.Map<java.lang.String,java.lang.String> help, java.lang.String method, java.lang.String expr, java.lang.String url, java.lang.String image, boolean confirm, boolean plus, int async, int asyncDepth, java.lang.String confirmUI, java.lang.String confirmExpr, int countRows, java.lang.String color, java.lang.String bgcolor)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addConfirmField(java.lang.String lang, ObjectField field)
Add a field to confirm actionint
countRows()
Count selected rows on UI?void
disable()
Deactivate the actionvoid
enable()
Activate the actionjava.lang.String
extractTarget()
Extract URL targetjava.lang.String
extractURL(ObjectCore obj, java.lang.String contextParams)
Extract URLjava.lang.String
getAnchor(ObjectCore obj, java.lang.String contextParams)
Get URL anchorjava.lang.String
getAnchor(ObjectCore obj, java.lang.String contextParams, java.lang.String extraParams)
Get URL anchorint
getAsync()
Get asynchronous modeint
getAsyncDepth()
Get asynchronous depthjava.lang.String
getBackgroundColor()
Get background colorstatic char
getButtonVisibility(java.lang.String val, char dflt)
Convert list BTN_VIS to Action visibilityjava.lang.String
getConfirmExpr()
Get action confirmation expressionObjectField
getConfirmField(java.lang.String name)
Field to confirm actionObjectField
getConfirmField(java.lang.String lang, java.lang.String name)
Field to confirm actionjava.util.List<ObjectField>
getConfirmFields(java.lang.String lang)
Fields to confirm actionjava.lang.String
getConfirmUI()
Action confirmation templateint
getDefaultPosition()
Get default positionchar
getDefaultType()
Get action default typejava.util.Map<java.lang.String,java.lang.String>
getDisplay()
Deprecated.Use getDisplaysjava.lang.String
getDisplay(java.lang.String lang)
Get action translationjava.util.Map<java.lang.String,java.lang.String>
getDisplays()
Get action translationsjava.lang.String
getExpression()
Get expressionjava.util.Map<java.lang.String,java.lang.String>
getHelp()
Deprecated.Use getHelpsjava.lang.String
getHelp(java.lang.String lang)
Get helpjava.util.Map<java.lang.String,java.lang.String>
getHelps()
Get helpsjava.lang.String
getId()
static java.lang.String
getId(java.lang.String name)
Get action Id from namejava.lang.String
getImage()
Get the icon namejava.lang.String
getLabel(java.lang.String lang)
Get action transaction (alias to getDisplay)java.util.Map<java.lang.String,java.lang.String>
getLabels()
Get action translations (alias to getDisplays)java.lang.String
getMethod()
Get methodjava.lang.String
getName()
static java.lang.String
getName(java.lang.String rowId)
Get action name from rowIdjava.lang.String
getTextColor()
Get text colorchar
getType()
Get action current typejava.lang.String
getURL()
Get URLboolean
isConfirm()
Does action needs a user confirmation?boolean
isCustom()
Is a custom action?boolean
isDefaultPlus()
By default in the "Plus" button?boolean
isEnabled()
Is the action enabled?boolean
isFormVisible()
Is visible on form?boolean
isHidden()
Is hidden?boolean
isLimitedbyCount()
History of job is limited by count?boolean
isLimitedByDays()
History of job is limited by days?boolean
isListItemVisible()
Is visible on list items?boolean
isListVisible()
Is list visible on list?boolean
isPlus()
Action can be displayed in the "Plus" button ?boolean
isServerSide()
Is server-side (backend) action (has a method or a scripted expression)?boolean
isTransition()
Is a transition action?boolean
isUnlimited()
Unlimited jobs history?void
setAsync(int async)
Set asynchronous modevoid
setAsyncDepth(int depth)
Set asynchronous depthvoid
setBackgroundColor(java.lang.String color)
Set background colorvoid
setConfirm(boolean b)
Set whether action needs confirmationvoid
setConfirmExpr(java.lang.String expr)
Set confirmation expressionvoid
setConfirmUI(java.lang.String t)
Set confirmation templatevoid
setDefaultPosition(int pos)
Set default positionvoid
setDisplay(java.lang.String lang, java.lang.String disp)
Set action translationvoid
setEnabled(boolean b)
Enable/disable the actionvoid
setExpression(java.lang.String expr)
Set expressionvoid
setHelp(java.lang.String lang, java.lang.String help)
Set helpvoid
setImage(java.lang.String name)
Set the icon namevoid
setLabel(java.lang.String lang, java.lang.String disp)
Set action translation (alias to setDisplay)void
setMethod(java.lang.String method)
Set methodvoid
setName(java.lang.String name)
void
setPlus(boolean plus)
Set the display in the "Plus" buttonvoid
setTextColor(java.lang.String color)
Set text colorvoid
setTransition(boolean b)
Set whether action is a transitionvoid
setType(char type)
Change action current typevoid
setURL(java.lang.String url)
Set URLboolean
showLabel()
Show label on button?void
showLabel(boolean show)
Show label on button?org.json.JSONObject
toJSONObject()
Generates a JSON object representation of the actionjava.lang.String
toString()
Generates a string representation of the action
-
-
-
Field Detail
-
ACTION_LIST
public static final char ACTION_LIST
Enable on list / display in list header- See Also:
- Constant Field Values
-
ACTION_FORM
public static final char ACTION_FORM
Enable on form / display on form and lines of list- See Also:
- Constant Field Values
-
ACTION_ALL
public static final char ACTION_ALL
Display both on list header, form and lines of list- See Also:
- Constant Field Values
-
ACTION_LIST_FORM
public static final char ACTION_LIST_FORM
Both form and List header (but not on list items)- See Also:
- Constant Field Values
-
ACTION_FORM_ONLY
public static final char ACTION_FORM_ONLY
Enable on form / display on form only, not on list items- See Also:
- Constant Field Values
-
ACTION_LIST_ITEMS_ONLY
public static final char ACTION_LIST_ITEMS_ONLY
Enable on form / display on list items only, not on form- See Also:
- Constant Field Values
-
ACTION_HIDDEN
public static final char ACTION_HIDDEN
Hidden on UI (but may be enabled for a cron job)- See Also:
- Constant Field Values
-
ACTION_PLUS
public static final char ACTION_PLUS
In Plus button- See Also:
- Constant Field Values
-
ASYNC_NONE
public static final int ASYNC_NONE
Synchronous call (means that the job will be launched directly after instantiation)- See Also:
- Constant Field Values
-
ASYNC_SESSION
public static final int ASYNC_SESSION
New thread with the current Grant and the current instance of object- See Also:
- Constant Field Values
-
ASYNC_STANDALONE
public static final int ASYNC_STANDALONE
New thread with the current Grant and a new job instance of object- See Also:
- Constant Field Values
-
ASYNC_ISOLATED
public static final int ASYNC_ISOLATED
New thread with isolated Grant (outside session) and a new job instance of object- See Also:
- Constant Field Values
-
LIST_COUNT_NONE
public static final int LIST_COUNT_NONE
No rows counter on list action- See Also:
- Constant Field Values
-
LIST_COUNT_SELECTED
public static final int LIST_COUNT_SELECTED
Count selected rows only- See Also:
- Constant Field Values
-
LIST_COUNT_SEL_OR_ALL
public static final int LIST_COUNT_SEL_OR_ALL
Count selected rows or all rows if none selected by user- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Action
@Deprecated public Action(java.lang.String id, java.lang.String name, char type, java.util.Map<java.lang.String,java.lang.String> display, java.util.Map<java.lang.String,java.lang.String> help, java.lang.String method, java.lang.String expr, java.lang.String url, java.lang.String image, boolean confirm, boolean plus, int async, int asyncDepth, java.lang.String confirmUI, java.lang.String confirmExpr, int countRows)
Deprecated.Constructor- Parameters:
id
- Idname
- Action nametype
- Visibilitydisplay
- Translation per languagehelp
- Help per languagemethod
- Action methodexpr
- Action expressionurl
- Action URLimage
- Iconconfirm
- Confirm action ?plus
- Display in Plus button when possible ?async
- Asynchronous mode CronJob.ASYNC_*asyncDepth
- Execution jobs depth (null not limited)confirmUI
- Optional template to confirm actioncountRows
- Count selected rows on UI
-
Action
public Action(java.lang.String id, java.lang.String name, char type, java.util.Map<java.lang.String,java.lang.String> display, java.util.Map<java.lang.String,java.lang.String> help, java.lang.String method, java.lang.String expr, java.lang.String url, java.lang.String image, boolean confirm, boolean plus, int async, int asyncDepth, java.lang.String confirmUI, java.lang.String confirmExpr, int countRows, java.lang.String color, java.lang.String bgcolor)
Constructor- Parameters:
id
- Idname
- Action nametype
- Visibilitydisplay
- Translation per languagehelp
- Help per languagemethod
- Action methodexpr
- Action expressionurl
- Action URLimage
- Iconconfirm
- Confirm action ?plus
- Display in Plus button when possible ?async
- Asynchronous mode CronJob.ASYNC_*asyncDepth
- Execution jobs depth (null not limited)confirmUI
- Optional template to confirm actioncountRows
- Count selected rows on UIcolor
- Text colorbgcolor
- Background color
-
Action
public Action(java.lang.String name, char type, java.util.Map<java.lang.String,java.lang.String> display, java.lang.String image, int position, boolean plus, int count)
Silent constructor (no method, no URL). Internal usage to generate common actions- Parameters:
name
- Nametype
- typedisplay
- displayimage
- Imageposition
- Positionplus
- is plus ?count
- count rows ?
-
Action
public Action(Action action, int position, java.lang.String lang)
Copy constructor- Parameters:
action
- Actionposition
- Positionlang
- Optional user language to limit copy
-
-
Method Detail
-
getId
public java.lang.String getId()
-
getId
public static java.lang.String getId(java.lang.String name)
Get action Id from name- Parameters:
name
- Action name- Returns:
- action Id if exists
-
getName
public java.lang.String getName()
-
getName
public static java.lang.String getName(java.lang.String rowId)
Get action name from rowId- Parameters:
rowId
- Row Id- Returns:
- action name if exists
-
setName
public void setName(java.lang.String name)
-
setType
public void setType(char type)
Change action current type- Parameters:
type
- action type
-
getType
public char getType()
Get action current type- Returns:
- action current type
-
getDefaultType
public char getDefaultType()
Get action default type- Returns:
- action default type
-
getDisplay
public java.lang.String getDisplay(java.lang.String lang)
Get action translation- Parameters:
lang
- Language code
-
getLabel
public java.lang.String getLabel(java.lang.String lang)
Get action transaction (alias to getDisplay)- Parameters:
lang
- Language code
-
setDisplay
public void setDisplay(java.lang.String lang, java.lang.String disp)
Set action translation- Parameters:
lang
- Language codedisp
- Translation
-
setLabel
public void setLabel(java.lang.String lang, java.lang.String disp)
Set action translation (alias to setDisplay)- Parameters:
lang
- Language codedisp
- Translation
-
getDisplay
@Deprecated(forRemoval=false, since="4.0") public java.util.Map<java.lang.String,java.lang.String> getDisplay()
Deprecated.Use getDisplays
-
getDisplays
public java.util.Map<java.lang.String,java.lang.String> getDisplays()
Get action translations
-
getLabels
public java.util.Map<java.lang.String,java.lang.String> getLabels()
Get action translations (alias to getDisplays)
-
getHelp
public java.lang.String getHelp(java.lang.String lang)
Get help- Parameters:
lang
- Language code
-
setHelp
public void setHelp(java.lang.String lang, java.lang.String help)
Set help- Parameters:
lang
- Language codehelp
- Help
-
getHelps
public java.util.Map<java.lang.String,java.lang.String> getHelps()
Get helps
-
getHelp
@Deprecated(forRemoval=false, since="4.0") public java.util.Map<java.lang.String,java.lang.String> getHelp()
Deprecated.Use getHelps
-
getMethod
public java.lang.String getMethod()
Get method
-
setMethod
public void setMethod(java.lang.String method)
Set method- Parameters:
method
- Method
-
getExpression
public java.lang.String getExpression()
Get expression
-
setExpression
public void setExpression(java.lang.String expr)
Set expression- Parameters:
expr
- Expression
-
getURL
public java.lang.String getURL()
Get URL
-
setURL
public void setURL(java.lang.String url)
Set URL- Parameters:
url
- URL
-
getAsync
public int getAsync()
Get asynchronous mode
-
setAsync
public void setAsync(int async)
Set asynchronous mode- Parameters:
async
- Asynchronous mode
-
getAsyncDepth
public int getAsyncDepth()
Get asynchronous depth
-
setAsyncDepth
public void setAsyncDepth(int depth)
Set asynchronous depth- Parameters:
depth
- Asynchronous depth
-
isLimitedByDays
public boolean isLimitedByDays()
History of job is limited by days?- Returns:
- is limited by days ?
-
isLimitedbyCount
public boolean isLimitedbyCount()
History of job is limited by count?- Returns:
- is limited by count ?
-
isUnlimited
public boolean isUnlimited()
Unlimited jobs history?- Returns:
- is unlimited
-
extractURL
public java.lang.String extractURL(ObjectCore obj, java.lang.String contextParams)
Extract URL- Parameters:
obj
- ObjectcontextParams
- Context parameters
-
extractTarget
public java.lang.String extractTarget()
Extract URL target
-
getAnchor
public java.lang.String getAnchor(ObjectCore obj, java.lang.String contextParams)
Get URL anchor- Parameters:
obj
- ObjectcontextParams
- Context parameters
-
getAnchor
public java.lang.String getAnchor(ObjectCore obj, java.lang.String contextParams, java.lang.String extraParams)
Get URL anchor- Parameters:
obj
- objectcontextParams
- Context parametersextraParams
- Extra parameters
-
getImage
public java.lang.String getImage()
Get the icon name
-
setImage
public void setImage(java.lang.String name)
Set the icon name- Parameters:
name
- icon name
-
countRows
public int countRows()
Count selected rows on UI?- Returns:
- Selected rows count
-
isConfirm
public boolean isConfirm()
Does action needs a user confirmation?- Returns:
- True if user confirmation is needed
-
setConfirm
public void setConfirm(boolean b)
Set whether action needs confirmation- Parameters:
b
- Confirmation?
-
getConfirmExpr
public java.lang.String getConfirmExpr()
Get action confirmation expression- Returns:
- Confirmation expression
-
setConfirmExpr
public void setConfirmExpr(java.lang.String expr)
Set confirmation expression- Parameters:
expr
- Confirmation expression
-
getConfirmUI
public java.lang.String getConfirmUI()
Action confirmation template
-
setConfirmUI
public void setConfirmUI(java.lang.String t)
Set confirmation template- Parameters:
t
- HTML template
-
addConfirmField
public void addConfirmField(java.lang.String lang, ObjectField field)
Add a field to confirm action- Parameters:
lang
- User languagefield
- Field definition
-
getConfirmFields
public java.util.List<ObjectField> getConfirmFields(java.lang.String lang)
Fields to confirm action- Parameters:
lang
- User language- Returns:
- List of fields to confirm action
-
getConfirmField
public ObjectField getConfirmField(java.lang.String lang, java.lang.String name)
Field to confirm action- Parameters:
lang
- User languagename
- Field name- Returns:
- Field or null if unknown
-
getConfirmField
public ObjectField getConfirmField(java.lang.String name)
Field to confirm action- Parameters:
name
- Field name- Returns:
- Field or null if unknown
-
isPlus
public boolean isPlus()
Action can be displayed in the "Plus" button ?- Returns:
- True if in "Plus" button
-
setPlus
public void setPlus(boolean plus)
Set the display in the "Plus" button- Parameters:
plus
- Display in the "Plus" button?
-
isDefaultPlus
public boolean isDefaultPlus()
By default in the "Plus" button?- Returns:
- By default in the "Plus" button?
-
getDefaultPosition
public int getDefaultPosition()
Get default position- Returns:
- Default position
-
setDefaultPosition
public void setDefaultPosition(int pos)
Set default position- Parameters:
pos
- Position
-
showLabel
public boolean showLabel()
Show label on button?- Returns:
- True if label is shown
-
showLabel
public void showLabel(boolean show)
Show label on button?- Parameters:
show
- Show label?
-
getBackgroundColor
public java.lang.String getBackgroundColor()
Get background color
-
setBackgroundColor
public void setBackgroundColor(java.lang.String color)
Set background color- Parameters:
color
- RGB color
-
getTextColor
public java.lang.String getTextColor()
Get text color
-
setTextColor
public void setTextColor(java.lang.String color)
Set text color- Parameters:
color
- RGB color
-
isCustom
public boolean isCustom()
Is a custom action?- Returns:
- True if action is custom
-
isTransition
public boolean isTransition()
Is a transition action?- Returns:
- True if action is transition
-
setTransition
public void setTransition(boolean b)
Set whether action is a transition- Parameters:
b
- Transition?
-
enable
public void enable()
Activate the action
-
disable
public void disable()
Deactivate the action
-
isEnabled
public boolean isEnabled()
Is the action enabled?- Returns:
- True if enabled
-
setEnabled
public void setEnabled(boolean b)
Enable/disable the action- Parameters:
b
- Enabled?
-
isFormVisible
public boolean isFormVisible()
Is visible on form?- Returns:
- True if visible on form
-
isListVisible
public boolean isListVisible()
Is list visible on list?- Returns:
- True if visible on list
-
isListItemVisible
public boolean isListItemVisible()
Is visible on list items?- Returns:
- True if visible on list items
-
isHidden
public boolean isHidden()
Is hidden?- Returns:
- True if hidden
-
isServerSide
public boolean isServerSide()
Is server-side (backend) action (has a method or a scripted expression)?- Returns:
- True if action is server-side
-
getButtonVisibility
public static char getButtonVisibility(java.lang.String val, char dflt)
Convert list BTN_VIS to Action visibility- Parameters:
val
- Valuedflt
- default- Returns:
- Action visibility
-
toJSONObject
public org.json.JSONObject toJSONObject()
Generates a JSON object representation of the action- Returns:
- Action as JSON object
-
toString
public java.lang.String toString()
Generates a string representation of the action- Overrides:
toString
in classjava.lang.Object
- Returns:
- Action as string
-
-