@ExportedBean public abstract class Actionable extends AbstractModelObject implements ModelObjectWithContextMenu
ModelObject
that can have additional Action
s.ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem
Constructor and Description |
---|
Actionable() |
Modifier and Type | Method and Description |
---|---|
void |
addAction(Action a)
Adds a new action.
|
boolean |
addOrReplaceAction(Action a)
Add an action, replacing any existing actions of the (exact) same class.
|
ModelObjectWithContextMenu.ContextMenu |
doContextMenu(org.kohsuke.stapler.StaplerRequest request,
org.kohsuke.stapler.StaplerResponse response)
Generates the context menu.
|
<T extends Action> |
getAction(Class<T> type)
Gets the action (first instance to be found) of a specified type that contributed to this build.
|
Action |
getAction(int index)
Deprecated.
No clear purpose, since subclasses may have overridden
getActions() , and does not consider TransientActionFactory . |
List<Action> |
getActions()
Deprecated.
Normally outside code should not call this method any more.
Use
getAllActions() , or addAction(hudson.model.Action) , or replaceAction(hudson.model.Action) .
May still be called for compatibility reasons from subclasses predating TransientActionFactory . |
<T extends Action> |
getActions(Class<T> type)
Gets all actions of a specified type that contributed to this object.
|
List<? extends Action> |
getAllActions()
Gets all actions, transient or persistent.
|
Object |
getDynamic(String token,
org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp) |
boolean |
removeAction(Action a)
Remove an action.
|
boolean |
removeActions(Class<? extends Action> clazz)
Removes any actions of the specified type.
|
void |
replaceAction(Action a)
Add an action, replacing any existing actions of the (exact) same class.
|
boolean |
replaceActions(Class<? extends Action> clazz,
Action a)
Replaces any actions of the specified type by the supplied action.
|
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDisplayName
getSearchUrl
@Deprecated @Nonnull public List<Action> getActions()
getAllActions()
, or addAction(hudson.model.Action)
, or replaceAction(hudson.model.Action)
.
May still be called for compatibility reasons from subclasses predating TransientActionFactory
.
A new Action
can be added by addAction(hudson.model.Action)
.
If you are reading the list, rather than modifying it,
use getAllActions()
instead.
This method by default returns only persistent actions
(though some subclasses override it to return an extended unmodifiable list).
@Exported(name="actions") @Nonnull public final List<? extends Action> getAllActions()
getActions()
is supplemented with anything contributed by TransientActionFactory
.@Nonnull public <T extends Action> List<T> getActions(Class<T> type)
type
- The type of action to return.getAction(Class)
public void addAction(@Nonnull Action a)
getAllActions()
that happen before calls to this method may not see the update.
Note: this method will always modify the actionspublic void replaceAction(@Nonnull Action a)
getAllActions()
that happen before calls to this method may not see the update.
Note: this method does not affect transient actions contributed by a TransientActionFactory
.
Note: this method cannot provide concurrency control due to the backing storage being a
CopyOnWriteArrayList
so concurrent calls to any of the mutation methods may produce surprising results
though technically consistent from the concurrency contract of CopyOnWriteArrayList
(we would need
some form of transactions or a different backing type).a
- an action to add/replaceif you want to know whether the backing {@link #actions} was modified, for
example in cases where the caller would need to persist the {@link Actionable} in order to persist the change
and there is a desire to elide unnecessary persistence of unmodified objects.
public boolean addOrReplaceAction(@Nonnull Action a)
getAllActions()
that happen before calls to this method may not see the update.
Note: this method does not affect transient actions contributed by a TransientActionFactory
Note: this method cannot provide concurrency control due to the backing storage being a
CopyOnWriteArrayList
so concurrent calls to any of the mutation methods may produce surprising results
though technically consistent from the concurrency contract of CopyOnWriteArrayList
(we would need
some form of transactions or a different backing type).a
- an action to add/replacetrue
if this actions changed as a result of the callpublic boolean removeAction(@Nullable Action a)
getAllActions()
that happen before calls to this method may not see the update.
Note: this method does not affect transient actions contributed by a TransientActionFactory
Note: this method cannot provide concurrency control due to the backing storage being a
CopyOnWriteArrayList
so concurrent calls to any of the mutation methods may produce surprising results
though technically consistent from the concurrency contract of CopyOnWriteArrayList
(we would need
some form of transactions or a different backing type).a
- an action to remove (if null
then this will be a no-op)true
if this actions changed as a result of the callpublic boolean removeActions(@Nonnull Class<? extends Action> clazz)
getAllActions()
that happen before calls to this method may not see the update.
Note: this method does not affect transient actions contributed by a TransientActionFactory
Note: this method cannot provide concurrency control due to the backing storage being a
CopyOnWriteArrayList
so concurrent calls to any of the mutation methods may produce surprising results
though technically consistent from the concurrency contract of CopyOnWriteArrayList
(we would need
some form of transactions or a different backing type).clazz
- the type of actions to removetrue
if this actions changed as a result of the callpublic boolean replaceActions(@Nonnull Class<? extends Action> clazz, @Nonnull Action a)
getAllActions()
that happen before calls to this method may not see the update.
Note: this method does not affect transient actions contributed by a TransientActionFactory
Note: this method cannot provide concurrency control due to the backing storage being a
CopyOnWriteArrayList
so concurrent calls to any of the mutation methods may produce surprising results
though technically consistent from the concurrency contract of CopyOnWriteArrayList
(we would need
some form of transactions or a different backing type).clazz
- the type of actions to replace (note that the action you are replacing this with need not extend
this class)a
- the action to replace withtrue
if this actions changed as a result of the call@Deprecated public Action getAction(int index)
getActions()
, and does not consider TransientActionFactory
.public <T extends Action> T getAction(Class<T> type)
type
- null
if no such actions exist.getActions(Class)
public Object getDynamic(String token, org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
public ModelObjectWithContextMenu.ContextMenu doContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws Exception
ModelObjectWithContextMenu
return new ContextMenu().from(this,request,response);
,
which implements the default behaviour. See ModelObjectWithContextMenu.ContextMenu.from(ModelObjectWithContextMenu, StaplerRequest, StaplerResponse)
for more details of what it does. This should suit most implementations.doContextMenu
in interface ModelObjectWithContextMenu
Exception
Copyright © 2004–2019. All rights reserved.