File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\model\ViewDescriptor.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.model;
25
26 import hudson.views.ListViewColumn;
27 import hudson.views.ListViewColumnDescriptor;
28 import hudson.views.ViewJobFilter;
29 import jenkins.model.Jenkins;
30 import org.kohsuke.stapler.QueryParameter;
31
32 import java.util.List;
33
34 /**
35 * {@link Descriptor} for {@link View}.
36 *
37 * @author Kohsuke Kawaguchi
38 * @since 1.269
39 */
40 public abstract class ViewDescriptor extends Descriptor<View> {
41 /**
42 * Returns the human-readable name of this type of view. Used
43 * in the view creation screen. The string should look like
44 * "Abc Def Ghi".
45 */
46 public abstract String getDisplayName();
47
48 /**
49 * Some special views are not instantiable, and for those
50 * this method returns false.
51 */
52 public boolean isInstantiable() {
53 return true;
54 }
55
56 /**
57 * Jelly fragment included in the "new view" page.
58 */
59 public final String getNewViewDetailPage() {
60 return '/'+clazz.getName().replace('.','/').replace('$','/')+"/newViewDetail.jelly";
61 }
62
63 protected ViewDescriptor(Class<? extends View> clazz) {
64 super(clazz);
65 }
66
67 protected ViewDescriptor() {
68 }
69
70 /**
71 * Auto-completion for the "copy from" field in the new job page.
72 */
73 public AutoCompletionCandidates doAutoCompleteCopyNewItemFrom(@QueryParameter final String value) {
74 final AutoCompletionCandidates r = new AutoCompletionCandidates();
75
76 new ItemVisitor() {
77 @Override
78 public void onItemGroup(ItemGroup<?> group) {
79 // only dig deep when the path matches what's typed.
80 // for example, if 'foo/bar' is typed, we want to show 'foo/barcode'
81 if (value.startsWith(group.getFullName()))
82 super.onItemGroup(group);
83 }
84
85 @Override
86 public void onItem(Item i) {
87 if (i.getFullName().startsWith(value)) {
88 r.add((i.getFullName()));
89 super.onItem(i);
90 }
91 }
92 }.onItemGroup(Jenkins.getInstance());
93
94 return r;
95 }
96
97 /**
98 * Possible {@link ListViewColumnDescriptor}s that can be used with this view.
99 */
100 public List<Descriptor<ListViewColumn>> getColumnsDescriptors() {
101 return ListViewColumn.all();
102 }
103
104 /**
105 * Possible {@link ViewJobFilter} types that can be used with this view.
106 */
107 public List<Descriptor<ViewJobFilter>> getJobFiltersDescriptors() {
108 return ViewJobFilter.all();
109 }
110 }
111