Class View
- All Implemented Interfaces:
ExtensionPoint
,Describable<View>
,DescriptorByNameOwner
,ModelObject
,Saveable
,SearchableModelObject
,SearchItem
,AccessControlled
,ModelObjectWithChildren
,HasWidgets
TopLevelItem
s
that Jenkins
owns.
This is an extension point in Hudson, allowing different kind of rendering to be added as plugins.
Note for implementers
-
View
subtypes need thenewViewDetail.jelly
page, which is included in the "new view" page. This page should have some description of what the view is about.
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Permission
static final Permission
Permission to create new views.static final Permission
protected String
Message displayed in the view page.protected boolean
If true, only show relevant executorsprotected boolean
If true, only show relevant queue itemsstatic final DescriptorList<View>
Deprecated.protected String
Name of this view.static final AlternativeUiTextProvider.Message<View>
"Job" in "New Job".protected ViewGroup
Container of this view.static final PermissionGroup
static final Permission
static final Comparator<View>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionall()
Returns all the registeredViewDescriptor
s.static List<ViewDescriptor>
Returns theViewDescriptor
instances that can be instantiated for theViewGroup
in the currentStaplerRequest2
.abstract boolean
contains
(TopLevelItem item) Checks if the job is in this collection.static View
create
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, ViewGroup owner) static View
create
(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, ViewGroup owner) Deprecated.static View
createViewFromXML
(String name, InputStream xml) Instantiate View subtype from XML stream.doCheckJobName
(String value) Makes sure that the given name is good as a job name.doChildrenContextMenu
(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) Generates the context menu to list up all the children.org.kohsuke.stapler.HttpResponse
doConfigDotXml
(org.kohsuke.stapler.StaplerRequest req) Deprecated.org.kohsuke.stapler.HttpResponse
doConfigDotXml
(org.kohsuke.stapler.StaplerRequest2 req) Acceptsconfig.xml
submission, as well as serve it.final void
doConfigSubmit
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) Accepts submission from the configuration page.doCreateItem
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) Creates a newItem
in this collection.doCreateItem
(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) Deprecated.void
doDoDelete
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) Deletes this view.doItemCategories
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String iconStyle) An API REST method to get the allowed {$link TopLevelItem}s and its categories.void
doRssAll
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) void
doRssFailed
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) void
doRssLatest
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) void
doSubmitDescription
(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) Accepts the new description.void
doSubmitDescription
(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) Deprecated.Gets the absolute URL of this view.getACL()
Returns theACL
for this object.Returns the transientAction
s associated with the top page.Gets all the items recursively contained in this collection in a read-only view.List of allViewProperty
s exposed primarily for the remoting API.getApi()
Returns all theViewPropertyDescriptor
s that can be potentially configured on this view.Deprecated.UsegetQueueItems()
.Iterable<? extends ListViewColumn>
If this view uses<t:projectView>
for rendering, this method returns columns to be displayed.Message displayed in the top page.Gets the descriptor for this instance.getDynamic
(String token) If this view usest:projectView
for rendering, this method returns the indenter used to indent each row.Gets theTopLevelItem
of the given name.static Permission
abstract Collection<TopLevelItem>
getItems()
Gets all the items in this collection in a read-only view.final TopLevelItem
Alias forgetItem(String)
.getOwner()
Gets theViewGroup
that this view belongs to.ItemGroup<? extends TopLevelItem>
Deprecated.callViewGroup.getItemGroup()
directlyDeprecated.callViewGroup.getPrimaryView()
directlyDeprecated.callViewGroup.getViewActions()
directlyReturns the page to redirect the user to, after the view is created.Gets the view properties configured for this view.Returns the URL of this item relative to the parentSearchItem
.Deprecated.getUrl()
Returns the path relative to the context root.Gets the name of all this collection.Same asgetUrl()
except this returns a view/{name} path even for the default view.boolean
Deprecated.Auto-refresh has been removedboolean
If true, this is a view that renders the top page of Hudson.boolean
By default, return true to render the "Edit view" link on the page.boolean
If true, only show relevant executorsboolean
If true, only show relevant queue itemsDefault implementation that returns empty index.protected void
Add a simple CollectionSearchIndex object to sibvoid
onJobRenamed
(Item item, String oldName, String newName) Deprecated.Does not work properly with moved jobs.static void
void
Renames this view.void
save()
Persists the state of this object into XML.void
setDescription
(String description) void
setFilterExecutors
(boolean filterExecutors) void
setFilterQueue
(boolean filterQueue) protected void
submit
(org.kohsuke.stapler.StaplerRequest req) Deprecated.protected void
submit
(org.kohsuke.stapler.StaplerRequest2 req) Handles the configuration submission.toString()
void
updateByXml
(Source source) Updates the View with the new XML definition.void
Deprecated.This method does nothing and should not be usedvoid
writeXml
(OutputStream out) Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, requirePOST, sendError, sendError, sendError, sendError, sendError, sendError, sendError, sendError
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2
Methods inherited from interface hudson.model.DescriptorByNameOwner
getDescriptorByName
Methods inherited from interface jenkins.widgets.HasWidgets
getWidget, getWidgets
Methods inherited from interface jenkins.model.ModelObjectWithChildren
doChildrenContextMenu
-
Field Details
-
owner
Container of this view. Set right after the construction and never change thereafter. -
name
Name of this view. -
description
Message displayed in the view page. -
filterExecutors
protected boolean filterExecutorsIf true, only show relevant executors -
filterQueue
protected boolean filterQueueIf true, only show relevant queue items -
LIST
A list of available view types. -
SORTER
-
PERMISSIONS
-
CREATE
Permission to create new views. -
DELETE
-
CONFIGURE
-
READ
-
NEW_PRONOUN
"Job" in "New Job". When a view is used in a context that restricts the child type, It might be useful to override this.
-
-
Constructor Details
-
View
-
View
-
-
Method Details
-
getItems
Gets all the items in this collection in a read-only view. -
getAllItems
Gets all the items recursively contained in this collection in a read-only view.The default implementation recursively adds the items of all contained Views in case this view implements
ViewGroup
, which should be enough for most cases.- Since:
- 1.520
-
getItem
Gets theTopLevelItem
of the given name. -
getJob
Alias forgetItem(String)
. This is the one used in the URL binding. -
contains
Checks if the job is in this collection. -
getViewName
Gets the name of all this collection.- See Also:
-
rename
Renames this view.- Throws:
Failure
Descriptor.FormException
-
getOwner
Gets theViewGroup
that this view belongs to. -
getOwnerItemGroup
Deprecated.callViewGroup.getItemGroup()
directly -
getOwnerPrimaryView
Deprecated.callViewGroup.getPrimaryView()
directly -
getOwnerViewActions
Deprecated.callViewGroup.getViewActions()
directly -
getDescription
Message displayed in the top page. Can be null. Includes HTML. -
setDescription
-
getProperties
Gets the view properties configured for this view.- Since:
- 1.406
-
getApplicablePropertyDescriptors
Returns all theViewPropertyDescriptor
s that can be potentially configured on this view. Returns bothViewPropertyDescriptor
s visible and invisible for user, seegetVisiblePropertyDescriptors()
to filter invisible one. -
getVisiblePropertyDescriptors
- Returns:
- all the
ViewPropertyDescriptor
s that can be potentially configured on this View and are visible for the user. UseDescriptorVisibilityFilter
to make a View property invisible for users. - Since:
- 2.214
-
save
Description copied from interface:Saveable
Persists the state of this object into XML.For making a bulk change efficiently, see
BulkChange
.To support listeners monitoring changes to this object, call
SaveableListener.fireOnChange(hudson.model.Saveable, hudson.XmlFile)
- Specified by:
save
in interfaceSaveable
- Throws:
IOException
- if the persistence failed.
-
getAllProperties
List of allViewProperty
s exposed primarily for the remoting API.- Since:
- 1.406
-
getDescriptor
Description copied from interface:Describable
Gets the descriptor for this instance.Descriptor
is a singleton for every concreteDescribable
implementation, so ifa.getClass() == b.getClass()
then by defaulta.getDescriptor() == b.getDescriptor()
as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)- Specified by:
getDescriptor
in interfaceDescribable<View>
-
getDisplayName
- Specified by:
getDisplayName
in interfaceModelObject
-
getNewPronoun
-
isEditable
public boolean isEditable()By default, return true to render the "Edit view" link on the page. This method is really just for the default "All" view to hide the edit link so that the default Hudson top page remains the same as before 1.316.- Since:
- 1.316
-
isAutomaticRefreshEnabled
Deprecated.Auto-refresh has been removedUsed to enable or disable automatic refreshes of the view.- Since:
- 1.557
-
isFilterExecutors
public boolean isFilterExecutors()If true, only show relevant executors -
setFilterExecutors
@DataBoundSetter public void setFilterExecutors(boolean filterExecutors) - Since:
- 2.426
-
isFilterQueue
public boolean isFilterQueue()If true, only show relevant queue items -
setFilterQueue
@DataBoundSetter public void setFilterQueue(boolean filterQueue) - Since:
- 2.426
-
getColumns
If this view uses<t:projectView>
for rendering, this method returns columns to be displayed. -
getIndenter
If this view usest:projectView
for rendering, this method returns the indenter used to indent each row. -
isDefault
public boolean isDefault()If true, this is a view that renders the top page of Hudson. -
getComputers
-
getQueueItems
-
getApproximateQueueItemsQuickly
Deprecated.UsegetQueueItems()
. As of 1.607 the approximation is no longer needed.- Returns:
- The items in the queue.
-
getUrl
Returns the path relative to the context root. Doesn't start with '/' but ends with '/' (except returns empty string when this is the default view). -
getViewUrl
Same asgetUrl()
except this returns a view/{name} path even for the default view. -
toString
-
getSearchUrl
Description copied from interface:SearchItem
Returns the URL of this item relative to the parentSearchItem
.- Specified by:
getSearchUrl
in interfaceSearchItem
- Returns:
- URL like "foo" or "foo/bar". The path can end with '/'. The path that starts with '/' will be interpreted as the absolute path (within the context path of Jenkins.)
-
getSearchIcon
- Specified by:
getSearchIcon
in interfaceSearchItem
-
getActions
Returns the transientAction
s associated with the top page.If views don't want to show top-level actions, this method can be overridden to return different objects.
- See Also:
-
updateTransientActions
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @Deprecated public void updateTransientActions()Deprecated.This method does nothing and should not be usedNo-op. Included to maintain backwards compatibility. -
getDynamic
-
getAbsoluteUrl
Gets the absolute URL of this view. -
getApi
-
getPostConstructLandingPage
Returns the page to redirect the user to, after the view is created. The returned string is appended to "/view/foobar/", so for example to direct the user to the top page of the view, return "", etc. -
getACL
Returns theACL
for this object.- Specified by:
getACL
in interfaceAccessControlled
- Returns:
- never null.
-
onJobRenamed
Deprecated.Does not work properly with moved jobs. UseItemListener.onLocationChanged(hudson.model.Item, java.lang.String, java.lang.String)
instead. -
makeSearchIndex
Add a simple CollectionSearchIndex object to sib- Parameters:
sib
- the SearchIndexBuilder- Since:
- 2.200
-
makeSearchIndex
Description copied from class:AbstractModelObject
Default implementation that returns empty index.- Overrides:
makeSearchIndex
in classAbstractModelObject
-
doSubmitDescription
public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException Accepts the new description.- Throws:
IOException
jakarta.servlet.ServletException
-
doSubmitDescription
@Deprecated @StaplerNotDispatchable public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException Deprecated.- Throws:
IOException
javax.servlet.ServletException
-
doConfigSubmit
@POST public final void doConfigSubmit(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException, Descriptor.FormException Accepts submission from the configuration page. Subtypes should override thesubmit(StaplerRequest2)
method.- Throws:
IOException
jakarta.servlet.ServletException
Descriptor.FormException
-
submit
protected void submit(org.kohsuke.stapler.StaplerRequest2 req) throws IOException, jakarta.servlet.ServletException, Descriptor.FormException Handles the configuration submission. Load view-specific properties here.- Throws:
IOException
jakarta.servlet.ServletException
Descriptor.FormException
-
submit
@Deprecated protected void submit(org.kohsuke.stapler.StaplerRequest req) throws IOException, javax.servlet.ServletException, Descriptor.FormException Deprecated.- Throws:
IOException
javax.servlet.ServletException
Descriptor.FormException
-
doDoDelete
public void doDoDelete(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException Deletes this view.- Throws:
IOException
jakarta.servlet.ServletException
-
doCreateItem
public Item doCreateItem(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException Creates a newItem
in this collection.This method should call
ModifiableItemGroup.doCreateItem(StaplerRequest2, StaplerResponse2)
and then add the newly created item to this view.- Returns:
- null if fails.
- Throws:
IOException
jakarta.servlet.ServletException
- Since:
- 2.475
-
doCreateItem
@Deprecated @StaplerNotDispatchable public Item doCreateItem(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException Deprecated.- Throws:
IOException
javax.servlet.ServletException
-
doCheckJobName
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public FormValidation doCheckJobName(@QueryParameter String value) Makes sure that the given name is good as a job name. For use fromnewJob
. -
doItemCategories
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public Categories doItemCategories(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter String iconStyle) throws IOException, jakarta.servlet.ServletException An API REST method to get the allowed {$link TopLevelItem}s and its categories.- Returns:
- A
Categories
entity that is shown as JSON file. - Throws:
IOException
jakarta.servlet.ServletException
-
doRssAll
public void doRssAll(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException - Throws:
IOException
jakarta.servlet.ServletException
-
doRssFailed
public void doRssFailed(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException - Throws:
IOException
jakarta.servlet.ServletException
-
getBuilds
-
getTimeline
@Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public BuildTimelineWidget getTimeline()Deprecated. -
doRssLatest
public void doRssLatest(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException - Throws:
IOException
jakarta.servlet.ServletException
-
doConfigDotXml
@WebMethod(name="config.xml") public org.kohsuke.stapler.HttpResponse doConfigDotXml(org.kohsuke.stapler.StaplerRequest2 req) throws IOException Acceptsconfig.xml
submission, as well as serve it.- Throws:
IOException
- Since:
- 2.475
-
doConfigDotXml
@Deprecated @StaplerNotDispatchable public org.kohsuke.stapler.HttpResponse doConfigDotXml(org.kohsuke.stapler.StaplerRequest req) throws IOException Deprecated.- Throws:
IOException
-
writeXml
- Throws:
IOException
- Since:
- 1.538
-
updateByXml
Updates the View with the new XML definition.- Parameters:
source
- source of the Item's new definition. The source should be either aStreamSource
orSAXSource
, other sources may not be handled.- Throws:
IOException
-
doChildrenContextMenu
public ModelObjectWithContextMenu.ContextMenu doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) throws Exception Description copied from interface:ModelObjectWithChildren
Generates the context menu to list up all the children.- Specified by:
doChildrenContextMenu
in interfaceModelObjectWithChildren
- Throws:
Exception
-
all
Returns all the registeredViewDescriptor
s. -
allInstantiable
Returns theViewDescriptor
instances that can be instantiated for theViewGroup
in the currentStaplerRequest2
.NOTE: Historically this method is only ever called from a
StaplerRequest2
- Returns:
- the list of instantiable
ViewDescriptor
instances for the currentStaplerRequest2
-
registerPermissions
@Initializer(before=SYSTEM_CONFIG_LOADED) @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public static void registerPermissions() -
getItemCreatePermission
-
create
public static View create(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, ViewGroup owner) throws Descriptor.FormException, IOException, jakarta.servlet.ServletException - Throws:
Descriptor.FormException
IOException
jakarta.servlet.ServletException
- Since:
- 2.475
-
create
@Deprecated public static View create(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, ViewGroup owner) throws Descriptor.FormException, IOException, javax.servlet.ServletException Deprecated.- Throws:
Descriptor.FormException
IOException
javax.servlet.ServletException
-
createViewFromXML
Instantiate View subtype from XML stream.- Parameters:
name
- Alternative name to use ornull
to keep the one in xml.- Throws:
IOException
-
all()
for read access, and useExtension
for registration.