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

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Tom Huybrechts
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 jenkins.model.Jenkins;
27 import org.kohsuke.stapler.DataBoundConstructor;
28 import org.kohsuke.stapler.Stapler;
29 import org.kohsuke.stapler.StaplerRequest;
30 import org.kohsuke.stapler.StaplerResponse;
31
32 import javax.servlet.ServletException;
33 import java.io.IOException;
34 import java.util.Collection;
35
36 import hudson.model.Descriptor.FormException;
37 import hudson.Extension;
38
39 /**
40 * {@link View} that contains everything.
41 *
42 * @author Kohsuke Kawaguchi
43 * @since 1.269
44 */
45 public class AllView extends View {
46 @DataBoundConstructor
47 public AllView(String name) {
48 super(name);
49 }
50
51 public AllView(String name, ViewGroup owner) {
52 this(name);
53 this.owner = owner;
54 }
55
56 @Override
57 public String getDescription() {
58 return Jenkins.getInstance().getDescription();
59 }
60
61 @Override
62 public boolean isEditable() {
63 return false;
64 }
65
66 @Override
67 public boolean contains(TopLevelItem item) {
68 return true;
69 }
70
71 @Override
72 public Item doCreateItem(StaplerRequest req, StaplerResponse rsp)
73 throws IOException, ServletException {
74 ItemGroup<? extends TopLevelItem> ig = getOwnerItemGroup();
75 if (ig instanceof ModifiableItemGroup)
76 return ((ModifiableItemGroup<? extends TopLevelItem>)ig).doCreateItem(req, rsp);
77 return null;
78 }
79
80 @Override
81 public Collection<TopLevelItem> getItems() {
82 return (Collection)getOwnerItemGroup().getItems();
83 }
84
85 @Override
86 public synchronized void doSubmitDescription( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
87 checkPermission(Jenkins.ADMINISTER);
88
89 Jenkins.getInstance().setSystemMessage(req.getParameter("description"));
90 rsp.sendRedirect(".");
91 }
92
93 @Override
94 public String getPostConstructLandingPage() {
95 return ""; // there's no configuration page
96 }
97
98 @Override
99 public void onJobRenamed(Item item, String oldName, String newName) {
100 // noop
101 }
102
103 @Override
104 protected void submit(StaplerRequest req) throws IOException, ServletException, FormException {
105 // noop
106 }
107
108 @Extension
109 public static final class DescriptorImpl extends ViewDescriptor {
110 @Override
111 public boolean isInstantiable() {
112 for (View v : Stapler.getCurrentRequest().findAncestorObject(ViewGroup.class).getViews())
113 if(v instanceof AllView)
114 return false;
115 return true;
116 }
117
118 public String getDisplayName() {
119 return Messages.Hudson_ViewName();
120 }
121 }
122 }
123