/
GlobalConfigurationCategory.java
90 lines (81 loc) · 3.17 KB
/
GlobalConfigurationCategory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package jenkins.model;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
import hudson.model.ModelObject;
import org.jenkinsci.Symbol;
/**
* Grouping of related {@link GlobalConfiguration}s.
*
* <p>
* To facilitate the separation of the global configuration into multiple pages, tabs, and so on,
* {@link GlobalConfiguration}s are classified into categories (such as "security", "tools", as well
* as the catch all "unclassified".) Categories themselves are extensible — plugins may introduce
* its own category as well, although that should only happen if you are creating a big enough subsystem.
*
* <p>
* The primary purpose of this is to enable future UIs to split the global configurations to
* smaller pieces that can be individually looked at and updated.
*
* @author Kohsuke Kawaguchi
* @since 1.494
* @see GlobalConfiguration
*/
public abstract class GlobalConfigurationCategory implements ExtensionPoint, ModelObject {
/**
* One-line plain text message that explains what this category is about.
* This can be used in the UI to help the user pick the right category.
*
* The text should be longer than {@link #getDisplayName()}
*/
public abstract String getShortDescription();
/**
* Returns all the registered {@link GlobalConfiguration} descriptors.
*/
public static ExtensionList<GlobalConfigurationCategory> all() {
return ExtensionList.lookup(GlobalConfigurationCategory.class);
}
public static @NonNull <T extends GlobalConfigurationCategory> T get(Class<T> type) {
T category = all().get(type);
if (category == null) {
throw new AssertionError("Category not found. It seems the " + type + " is not annotated with @Extension and so not registered");
}
return category;
}
/**
* This category represents the catch-all I-dont-know-what-category-it-is instance,
* used for those {@link GlobalConfiguration}s that don't really deserve/need a separate
* category.
*
* Also used for backward compatibility. All {@link GlobalConfiguration}s without
* explicit category gets this as the category.
*
* In the current UI, this corresponds to the /configure link.
*/
@Extension @Symbol("unclassified")
public static class Unclassified extends GlobalConfigurationCategory {
@Override
public String getShortDescription() {
return jenkins.management.Messages.ConfigureLink_Description();
}
@Override
public String getDisplayName() {
return jenkins.management.Messages.ConfigureLink_DisplayName();
}
}
/**
* Security related configurations.
*/
@Extension @Symbol("security")
public static class Security extends GlobalConfigurationCategory {
@Override
public String getShortDescription() {
return hudson.security.Messages.GlobalSecurityConfiguration_Description();
}
@Override
public String getDisplayName() {
return hudson.security.Messages.GlobalSecurityConfiguration_DisplayName();
}
}
}