Package hudson.model
Class TopLevelItemDescriptor
- java.lang.Object
-
- hudson.model.Descriptor<TopLevelItem>
-
- hudson.model.TopLevelItemDescriptor
-
- Direct Known Subclasses:
AbstractProject.AbstractProjectDescriptor
public abstract class TopLevelItemDescriptor extends Descriptor<TopLevelItem> implements IconSpec
Descriptor
forTopLevelItem
s.- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.model.Descriptor
Descriptor.FormException, Descriptor.PropertyType, Descriptor.Self
-
-
Field Summary
-
Fields inherited from class hudson.model.Descriptor
clazz
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TopLevelItemDescriptor()
Infers the type of the correspondingTopLevelItem
from the outer class.protected
TopLevelItemDescriptor(Class<? extends TopLevelItem> clazz)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static ExtensionList<TopLevelItemDescriptor>
all()
Returns all the registeredTopLevelItem
descriptors.void
checkApplicableIn(ItemGroup parent)
Checks if this top level item is applicable within the specified item group.String
getCategoryId()
Used to categorize this kind of item type.String
getDescription()
A description of this kind of item type.String
getDisplayName()
Human readable name of this kind of configurable object.String
getIconClassName()
Get the Item's Icon class specification e.g.String
getIconFilePath(String size)
Deprecated.prefergetIconClassName()
String
getIconFilePathPattern()
Deprecated.prefergetIconClassName()
boolean
isApplicable(Descriptor descriptor)
TopLevelItemDescriptor
s often uses other descriptors to decorate itself.boolean
isApplicableIn(ItemGroup parent)
TopLevelItemDescriptor
s often may want to limit the scope within which they can be created.abstract TopLevelItem
newInstance(ItemGroup parent, String name)
Creates a newTopLevelItem
for the specified parent.TopLevelItem
newInstance(String name)
Deprecated.as of 1.390 UsenewInstance(ItemGroup, String)
TopLevelItem
newInstance(org.kohsuke.stapler.StaplerRequest req)
Deprecated.since 2007-01-19.boolean
testInstance(TopLevelItem i)
Tests if the given instance belongs to this descriptor, in the sense that this descriptor can produce items like the given one.-
Methods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, calcAutoCompleteSettings, calcFillSettings, configure, configure, doHelp, find, find, findByDescribableClassName, findById, getCategory, getCheckMethod, getCheckUrl, getConfigFile, getConfigPage, getCurrentDescriptorByNameUrl, getDescriptorFullUrl, getDescriptorUrl, getGlobalConfigPage, getGlobalPropertyType, getHelpFile, getHelpFile, getHelpFile, getId, getJsonSafeClassName, getKlass, getPlugin, getPossibleViewNames, getPropertyType, getPropertyType, getPropertyTypeOrDie, getRequiredGlobalConfigPagePermission, getT, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
-
-
-
Constructor Detail
-
TopLevelItemDescriptor
protected TopLevelItemDescriptor(Class<? extends TopLevelItem> clazz)
-
TopLevelItemDescriptor
protected TopLevelItemDescriptor()
Infers the type of the correspondingTopLevelItem
from the outer class. This version works when you follow the common convention, where a descriptor is written as the static nested class of the describable class.- Since:
- 1.278
-
-
Method Detail
-
isApplicable
public boolean isApplicable(Descriptor descriptor)
TopLevelItemDescriptor
s often uses other descriptors to decorate itself. This method allows the subtype ofTopLevelItemDescriptor
s to filter them out.This is useful for a workflow/company specific item type that wants to eliminate options that the user would see.
- Since:
- 1.294
-
isApplicableIn
public boolean isApplicableIn(ItemGroup parent)
TopLevelItemDescriptor
s often may want to limit the scope within which they can be created. This method allows the subtype ofTopLevelItemDescriptor
s to filter them out.- Since:
- 1.607
-
checkApplicableIn
public final void checkApplicableIn(ItemGroup parent)
Checks if this top level item is applicable within the specified item group.This is just a convenience function.
- Since:
- 1.607
-
testInstance
public boolean testInstance(TopLevelItem i)
Tests if the given instance belongs to this descriptor, in the sense that this descriptor can produce items like the given one.TopLevelItemDescriptor
s that act like a wizard and produces different object types thanDescriptor.clazz
can override this method to augment instance-descriptor relationship.- Since:
- 1.410
-
getDisplayName
@NonNull public String getDisplayName()
Human readable name of this kind of configurable object. Should be overridden for most descriptors, if the display name is visible somehow. As a fallback it usesClass.getSimpleName()
onDescriptor.clazz
, so for exampleMyThing
fromsome.pkg.MyThing.DescriptorImpl
. Historically some implementations returned null as a way of hiding the descriptor from the UI, but this is generally managed by an explicit method such asisEnabled
orisApplicable
.Used as the caption when the user chooses what item type to create. The descriptor implementation also needs to have
newInstanceDetail.jelly
script, which will be used to render the text below the caption that explains the item type.- Overrides:
getDisplayName
in classDescriptor<TopLevelItem>
-
getDescription
@NonNull public String getDescription()
A description of this kind of item type. This description can contain HTML code but it is recommended that you use plain text in order to be consistent with the rest of Jenkins. This method should be called from a thread where Stapler is handling an HTTP request, otherwise it will return an empty string.- Returns:
- A string, by default the value from newInstanceDetail view is taken.
- Since:
- 2.0
-
getCategoryId
@NonNull public String getCategoryId()
Used to categorize this kind of item type. @seeItemCategory
- Returns:
- A string with the category identifier,
ItemCategory.UncategorizedCategory.getId()
by default. - Since:
- 2.0
-
getIconFilePathPattern
@CheckForNull @Deprecated public String getIconFilePathPattern()
Deprecated.prefergetIconClassName()
Represents a file path pattern to get the Item icon in different sizes. For example: plugin/plugin-shortname/images/:size/item.png, where:size
represents the different icon sizes used commonly in Jenkins project: 16x16, 24x24, 32x32 or 48x48- Returns:
- A string or null if it is not defined.
- Since:
- 2.0
- See Also:
FreeStyleProject.DescriptorImpl.getIconFilePathPattern()
-
getIconFilePath
@CheckForNull @Deprecated public String getIconFilePath(String size)
Deprecated.prefergetIconClassName()
An icon file path associated to a specific size.- Parameters:
size
- A string with values that represent the common sizes: 16x16, 24x24, 32x32 or 48x48- Returns:
- A string or null if it is not defined.
- Since:
- 2.0
-
getIconClassName
public String getIconClassName()
Get the Item's Icon class specification e.g. 'icon-notepad'.Note: do NOT include icon size specifications (such as 'icon-sm').
- Specified by:
getIconClassName
in interfaceIconSpec
- Returns:
- The Icon class specification e.g. 'icon-notepad'.
-
newInstance
@Deprecated public TopLevelItem newInstance(org.kohsuke.stapler.StaplerRequest req) throws Descriptor.FormException
Deprecated.since 2007-01-19. This is not a valid operation forItem
s.- Overrides:
newInstance
in classDescriptor<TopLevelItem>
- Throws:
Descriptor.FormException
-
newInstance
@Deprecated public TopLevelItem newInstance(String name)
Deprecated.as of 1.390 UsenewInstance(ItemGroup, String)
Creates a newTopLevelItem
.
-
newInstance
public abstract TopLevelItem newInstance(ItemGroup parent, String name)
Creates a newTopLevelItem
for the specified parent.- Since:
- 1.390
-
all
public static ExtensionList<TopLevelItemDescriptor> all()
Returns all the registeredTopLevelItem
descriptors.
-
-