Class View
- java.lang.Object
-
- hudson.model.AbstractModelObject
-
- hudson.model.View
-
- All Implemented Interfaces:
ExtensionPoint,Describable<View>,DescriptorByNameOwner,ModelObject,Saveable,SearchableModelObject,SearchItem,AccessControlled,ModelObjectWithChildren,HasWidgets
@ExportedBean public abstract class View extends AbstractModelObject implements AccessControlled, Describable<View>, ExtensionPoint, Saveable, ModelObjectWithChildren, DescriptorByNameOwner, HasWidgets
Encapsulates the rendering of the list ofTopLevelItems thatJenkinsowns.This is an extension point in Hudson, allowing different kind of rendering to be added as plugins.
Note for implementers
-
Viewsubtypes need thenewViewDetail.jellypage, 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:
ViewDescriptor,ViewGroup
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classView.PropertyList-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static PermissionCONFIGUREstatic PermissionCREATEPermission to create new views.static PermissionDELETEprotected StringdescriptionMessage displayed in the view page.protected booleanfilterExecutorsIf true, only show relevant executorsprotected booleanfilterQueueIf true, only show relevant queue itemsstatic DescriptorList<View>LISTprotected StringnameName of this view.static AlternativeUiTextProvider.Message<View>NEW_PRONOUN"Job" in "New Job".protected ViewGroupownerContainer of this view.static PermissionGroupPERMISSIONSstatic PermissionREADstatic Comparator<View>SORTER
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DescriptorExtensionList<View,ViewDescriptor>all()Returns all the registeredViewDescriptors.static List<ViewDescriptor>allInstantiable()Returns theViewDescriptorinstances that can be instantiated for theViewGroupin the currentStaplerRequest.abstract booleancontains(TopLevelItem item)Checks if the job is in this collection.static Viewcreate(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, ViewGroup owner)static ViewcreateViewFromXML(String name, InputStream xml)Instantiate View subtype from XML stream.FormValidationdoCheckJobName(String value)Makes sure that the given name is good as a job name.ModelObjectWithContextMenu.ContextMenudoChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)Generates the context menu to list up all the children.org.kohsuke.stapler.HttpResponsedoConfigDotXml(org.kohsuke.stapler.StaplerRequest req)Acceptsconfig.xmlsubmission, as well as serve it.voiddoConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Accepts submission from the configuration page.abstract ItemdoCreateItem(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Creates a newItemin this collection.voiddoDoDelete(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Deletes this view.CategoriesdoItemCategories(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, String iconStyle)An API REST method to get the allowed {$link TopLevelItem}s and its categories.voiddoRssAll(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)voiddoRssFailed(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)voiddoRssLatest(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)voiddoSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)Accepts the new description.StringgetAbsoluteUrl()Gets the absolute URL of this view.ACLgetACL()Returns theACLfor this object.List<Action>getActions()Returns the transientActions associated with the top page.Collection<TopLevelItem>getAllItems()Gets all the items recursively contained in this collection in a read-only view.List<ViewProperty>getAllProperties()List of allViewPropertys exposed primarily for the remoting API.ApigetApi()List<ViewPropertyDescriptor>getApplicablePropertyDescriptors()Returns all theViewPropertyDescriptors that can be potentially configured on this view.List<Queue.Item>getApproximateQueueItemsQuickly()Deprecated.UsegetQueueItems().RunListgetBuilds()Iterable<? extends ListViewColumn>getColumns()If this view uses<t:projectView>for rendering, this method returns columns to be displayed.List<Computer>getComputers()StringgetDescription()Message displayed in the top page.ViewDescriptorgetDescriptor()Gets the descriptor for this instance.StringgetDisplayName()ObjectgetDynamic(String token)IndentergetIndenter()If this view usest:projectViewfor rendering, this method returns the indenter used to indent each row.TopLevelItemgetItem(String name)Gets theTopLevelItemof the given name.static PermissiongetItemCreatePermission()abstract Collection<TopLevelItem>getItems()Gets all the items in this collection in a read-only view.TopLevelItemgetJob(String name)Alias forgetItem(String).StringgetNewPronoun()ViewGroupgetOwner()Gets theViewGroupthat this view belongs to.ItemGroup<? extends TopLevelItem>getOwnerItemGroup()Deprecated.callViewGroup.getItemGroup()directlyViewgetOwnerPrimaryView()Deprecated.callViewGroup.getPrimaryView()directlyList<Action>getOwnerViewActions()Deprecated.callViewGroup.getViewActions()directlyStringgetPostConstructLandingPage()Returns the page to redirect the user to, after the view is created.DescribableList<ViewProperty,ViewPropertyDescriptor>getProperties()Gets the view properties configured for this view.List<Queue.Item>getQueueItems()StringgetSearchUrl()Returns the URL of this item relative to the parentSearchItem.BuildTimelineWidgetgetTimeline()Deprecated.StringgetUrl()Returns the path relative to the context root.StringgetViewName()Gets the name of all this collection.StringgetViewUrl()Same asgetUrl()except this returns a view/{name} path even for the default view.List<ViewPropertyDescriptor>getVisiblePropertyDescriptors()booleanisAutomaticRefreshEnabled()Deprecated.Auto-refresh has been removedbooleanisDefault()If true, this is a view that renders the top page of Hudson.booleanisEditable()By default, return true to render the "Edit view" link on the page.booleanisFilterExecutors()If true, only show relevant executorsbooleanisFilterQueue()If true, only show relevant queue itemsSearchIndexBuildermakeSearchIndex()Default implementation that returns empty index.protected voidmakeSearchIndex(SearchIndexBuilder sib)Add a simple CollectionSearchIndex object to sibvoidonJobRenamed(Item item, String oldName, String newName)Deprecated.Does not work properly with moved jobs.static voidregisterPermissions()voidrename(String newName)Renames this view.voidsave()Persists the state of this object into XML.voidsetDescription(String description)voidsetFilterExecutors(boolean filterExecutors)voidsetFilterQueue(boolean filterQueue)protected abstract voidsubmit(org.kohsuke.stapler.StaplerRequest req)Handles the configuration submission.StringtoString()voidupdateByXml(Source source)Updates the View with the new XML definition.voidupdateTransientActions()Deprecated.This method does nothing and should not be usedvoidwriteXml(OutputStream out)-
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, requirePOST, 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
-
-
-
-
Field Detail
-
owner
protected ViewGroup owner
Container of this view. Set right after the construction and never change thereafter.
-
name
protected String name
Name of this view.
-
description
protected String description
Message displayed in the view page.
-
filterExecutors
protected boolean filterExecutors
If true, only show relevant executors
-
filterQueue
protected boolean filterQueue
If true, only show relevant queue items
-
LIST
@Deprecated public static final DescriptorList<View> LIST
A list of available view types.
-
SORTER
public static final Comparator<View> SORTER
-
PERMISSIONS
public static final PermissionGroup PERMISSIONS
-
CREATE
public static final Permission CREATE
Permission to create new views.
-
DELETE
public static final Permission DELETE
-
CONFIGURE
public static final Permission CONFIGURE
-
READ
public static final Permission READ
-
NEW_PRONOUN
public static final AlternativeUiTextProvider.Message<View> 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.
-
-
Method Detail
-
getItems
@NonNull @Exported(name="jobs") public abstract Collection<TopLevelItem> getItems()
Gets all the items in this collection in a read-only view.
-
getAllItems
public Collection<TopLevelItem> 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
public TopLevelItem getItem(String name)
Gets theTopLevelItemof the given name.
-
getJob
public final TopLevelItem getJob(String name)
Alias forgetItem(String). This is the one used in the URL binding.
-
contains
public abstract boolean contains(TopLevelItem item)
Checks if the job is in this collection.
-
getViewName
@Exported(visibility=2, name="name") @NonNull public String getViewName()Gets the name of all this collection.- See Also:
rename(String)
-
rename
public void rename(String newName) throws Failure, Descriptor.FormException
Renames this view.- Throws:
FailureDescriptor.FormException
-
getOwnerItemGroup
@Deprecated public ItemGroup<? extends TopLevelItem> getOwnerItemGroup()
Deprecated.callViewGroup.getItemGroup()directly
-
getOwnerPrimaryView
@Deprecated public View getOwnerPrimaryView()
Deprecated.callViewGroup.getPrimaryView()directly
-
getOwnerViewActions
@Deprecated public List<Action> getOwnerViewActions()
Deprecated.callViewGroup.getViewActions()directly
-
getDescription
@Exported public String getDescription()
Message displayed in the top page. Can be null. Includes HTML.
-
setDescription
@DataBoundSetter public void setDescription(String description)
-
getProperties
public DescribableList<ViewProperty,ViewPropertyDescriptor> getProperties()
Gets the view properties configured for this view.- Since:
- 1.406
-
getApplicablePropertyDescriptors
public List<ViewPropertyDescriptor> getApplicablePropertyDescriptors()
Returns all theViewPropertyDescriptors that can be potentially configured on this view. Returns bothViewPropertyDescriptors visible and invisible for user, seegetVisiblePropertyDescriptors()to filter invisible one.
-
getVisiblePropertyDescriptors
public List<ViewPropertyDescriptor> getVisiblePropertyDescriptors()
- Returns:
- all the
ViewPropertyDescriptors that can be potentially configured on this View and are visible for the user. UseDescriptorVisibilityFilterto make a View property invisible for users. - Since:
- 2.214
-
save
public void save() throws IOExceptionDescription copied from interface:SaveablePersists 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:
savein interfaceSaveable- Throws:
IOException- if the persistence failed.
-
getAllProperties
@Exported(name="property", inline=true) public List<ViewProperty> getAllProperties()List of allViewPropertys exposed primarily for the remoting API.- Since:
- 1.406
-
getDescriptor
public ViewDescriptor getDescriptor()
Description copied from interface:DescribableGets the descriptor for this instance.Descriptoris a singleton for every concreteDescribableimplementation, 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:
getDescriptorin interfaceDescribable<View>
-
getDisplayName
public String getDisplayName()
- Specified by:
getDisplayNamein interfaceModelObject
-
getNewPronoun
public String 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 public boolean 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
public Iterable<? extends ListViewColumn> getColumns()
If this view uses<t:projectView>for rendering, this method returns columns to be displayed.
-
getIndenter
public Indenter getIndenter()
If this view usest:projectViewfor 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.
-
getQueueItems
public List<Queue.Item> getQueueItems()
-
getApproximateQueueItemsQuickly
@Deprecated public List<Queue.Item> getApproximateQueueItemsQuickly()
Deprecated.UsegetQueueItems(). As of 1.607 the approximation is no longer needed.- Returns:
- The items in the queue.
-
getUrl
public String 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
public String getViewUrl()
Same asgetUrl()except this returns a view/{name} path even for the default view.
-
getSearchUrl
public String getSearchUrl()
Description copied from interface:SearchItemReturns the URL of this item relative to the parentSearchItem.- Specified by:
getSearchUrlin 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.)
-
getActions
public List<Action> getActions()
Returns the transientActions 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:
Jenkins.getActions()
-
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.
-
getAbsoluteUrl
@Exported(visibility=2, name="url") public String getAbsoluteUrl()Gets the absolute URL of this view.
-
getApi
public Api getApi()
-
getPostConstructLandingPage
public String 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
@NonNull public ACL getACL()
Returns theACLfor this object.- Specified by:
getACLin interfaceAccessControlled- Returns:
- never null.
-
onJobRenamed
@Deprecated public void onJobRenamed(Item item, String oldName, String newName)
Deprecated.Does not work properly with moved jobs. UseItemListener.onLocationChanged(hudson.model.Item, java.lang.String, java.lang.String)instead.
-
makeSearchIndex
protected void makeSearchIndex(SearchIndexBuilder sib)
Add a simple CollectionSearchIndex object to sib- Parameters:
sib- the SearchIndexBuilder- Since:
- 2.200
-
makeSearchIndex
public SearchIndexBuilder makeSearchIndex()
Description copied from class:AbstractModelObjectDefault implementation that returns empty index.- Overrides:
makeSearchIndexin classAbstractModelObject
-
doSubmitDescription
public void doSubmitDescription(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletExceptionAccepts the new description.- Throws:
IOExceptionjavax.servlet.ServletException
-
doConfigSubmit
@POST public final void doConfigSubmit(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException, Descriptor.FormExceptionAccepts submission from the configuration page. Subtypes should override thesubmit(StaplerRequest)method.- Throws:
IOExceptionjavax.servlet.ServletExceptionDescriptor.FormException
-
submit
protected abstract void submit(org.kohsuke.stapler.StaplerRequest req) throws IOException, javax.servlet.ServletException, Descriptor.FormExceptionHandles the configuration submission. Load view-specific properties here.- Throws:
IOExceptionjavax.servlet.ServletExceptionDescriptor.FormException
-
doDoDelete
public void doDoDelete(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletExceptionDeletes this view.- Throws:
IOExceptionjavax.servlet.ServletException
-
doCreateItem
public abstract Item doCreateItem(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
Creates a newItemin this collection.This method should call
ModifiableItemGroup.doCreateItem(StaplerRequest, StaplerResponse)and then add the newly created item to this view.- Returns:
- null if fails.
- Throws:
IOExceptionjavax.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.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, @QueryParameter String iconStyle) throws IOException, javax.servlet.ServletException
An API REST method to get the allowed {$link TopLevelItem}s and its categories.- Returns:
- A
Categoriesentity that is shown as JSON file. - Throws:
IOExceptionjavax.servlet.ServletException
-
doRssAll
public void doRssAll(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
doRssFailed
public void doRssFailed(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
getBuilds
public RunList getBuilds()
-
getTimeline
@Deprecated @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public BuildTimelineWidget getTimeline()
Deprecated.
-
doRssLatest
public void doRssLatest(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
doConfigDotXml
@WebMethod(name="config.xml") public org.kohsuke.stapler.HttpResponse doConfigDotXml(org.kohsuke.stapler.StaplerRequest req) throws IOExceptionAcceptsconfig.xmlsubmission, as well as serve it.- Throws:
IOException
-
writeXml
public void writeXml(OutputStream out) throws IOException
- Throws:
IOException- Since:
- 1.538
-
updateByXml
public void updateByXml(Source source) throws IOException
Updates the View with the new XML definition.- Parameters:
source- source of the Item's new definition. The source should be either aStreamSourceorSAXSource, other sources may not be handled.- Throws:
IOException
-
doChildrenContextMenu
public ModelObjectWithContextMenu.ContextMenu doChildrenContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws Exception
Description copied from interface:ModelObjectWithChildrenGenerates the context menu to list up all the children.- Specified by:
doChildrenContextMenuin interfaceModelObjectWithChildren- Throws:
Exception
-
all
public static DescriptorExtensionList<View,ViewDescriptor> all()
Returns all the registeredViewDescriptors.
-
allInstantiable
@NonNull public static List<ViewDescriptor> allInstantiable()
Returns theViewDescriptorinstances that can be instantiated for theViewGroupin the currentStaplerRequest.NOTE: Historically this method is only ever called from a
StaplerRequest- Returns:
- the list of instantiable
ViewDescriptorinstances for the currentStaplerRequest
-
registerPermissions
@Initializer(before=SYSTEM_CONFIG_LOADED) @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public static void registerPermissions()
-
getItemCreatePermission
public static Permission getItemCreatePermission()
-
create
public static View create(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, ViewGroup owner) throws Descriptor.FormException, IOException, javax.servlet.ServletException
- Throws:
Descriptor.FormExceptionIOExceptionjavax.servlet.ServletException
-
createViewFromXML
public static View createViewFromXML(String name, InputStream xml) throws IOException
Instantiate View subtype from XML stream.- Parameters:
name- Alternative name to use ornullto keep the one in xml.- Throws:
IOException
-
-