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

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2011, CloudBees, Inc., Stephen Connolly
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.DescriptorExtensionList;
27 import hudson.ExtensionPoint;
28 import jenkins.model.Jenkins;
29 import net.sf.json.JSONObject;
30 import org.kohsuke.stapler.StaplerRequest;
31
32 /**
33 * Extensible property of {@link View}.
34 *
35 * <p>
36 * {@link hudson.Plugin}s can extend this to define custom properties for {@link View}s.
37 * {@link ViewProperty}s show up in the view configuration screen, and they are
38 * persisted with the view object.
39 *
40 * <p>
41 * Configuration screen should be defined in <code>config.jelly</code>.
42 * Within this page, the {@link ViewProperty} instance is available as
43 * the <code>instance</code> EL variable (while the <code>it</code> EL variable
44 * refers to the {@link View}.
45 *
46 * @author Stephen Connolly
47 * @since 1.406
48 */
49 public class ViewProperty implements ReconfigurableDescribable<ViewProperty>, ExtensionPoint {
50 /**
51 * The view object that owns this property.
52 * This value will be set by the core code.
53 * Derived classes can expect this value to be always set.
54 */
55 protected transient View view;
56
57 /*package*/ final void setView(View view) {
58 this.view = view;
59 }
60
61 public ViewPropertyDescriptor getDescriptor() {
62 return (ViewPropertyDescriptor) Jenkins.getInstance().getDescriptorOrDie(getClass());
63 }
64
65 public static DescriptorExtensionList<ViewProperty,ViewPropertyDescriptor> all() {
66 return Jenkins.getInstance().<ViewProperty,ViewPropertyDescriptor>getDescriptorList(ViewProperty.class);
67 }
68
69 public ViewProperty reconfigure(StaplerRequest req, JSONObject form) throws Descriptor.FormException {
70 return form==null ? null : getDescriptor().newInstance(req, form);
71 }
72 }
73