View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.uif.modifier;
17  
18  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
19  import org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase;
20  import org.kuali.rice.krad.uif.UifConstants;
21  import org.kuali.rice.krad.uif.view.View;
22  import org.kuali.rice.krad.uif.component.Component;
23  
24  import java.util.ArrayList;
25  import java.util.List;
26  
27  /**
28   * Base class for <code>ComponentModifier</code> implementations
29   *
30   * <p>
31   * Holds run phase property and defaults to the INITIALIZE phase, and the order
32   * property for setting the order in which the component modifier will be
33   * invoked
34   * </p>
35   *
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   */
38  public abstract class ComponentModifierBase extends UifDictionaryBeanBase implements ComponentModifier {
39  	private static final long serialVersionUID = -8284332412469942130L;
40  
41  	private String runPhase;
42  	private String runCondition;
43  	private int order;
44  
45  	public ComponentModifierBase() {
46          super();
47  
48  		runPhase = UifConstants.ViewPhases.INITIALIZE;
49  		order = 0;
50  	}
51  
52      /**
53       * Default performInitialization impl (does nothing)
54       *
55       * @see org.kuali.rice.krad.uif.modifier.ComponentModifierBase#performInitialization
56       */
57      @Override
58      public void performInitialization(View view, Object model, Component component) {
59  
60      }
61  
62      /**
63       * @see org.kuali.rice.krad.uif.modifier.ComponentModifierBase#getComponentPrototypes()
64       */
65      public List<Component> getComponentPrototypes() {
66          List<Component> components = new ArrayList<Component>();
67  
68          return components;
69      }
70  
71      /**
72  	 * @see org.kuali.rice.krad.uif.modifier.ComponentModifier#getRunPhase()
73  	 */
74      @BeanTagAttribute(name="runPhase")
75  	public String getRunPhase() {
76  		return this.runPhase;
77  	}
78  
79  	/**
80  	 * Setter for the component initializer run phase
81  	 *
82  	 * @param runPhase
83  	 */
84  	public void setRunPhase(String runPhase) {
85  		this.runPhase = runPhase;
86  	}
87  
88  	/**
89  	 * @see org.kuali.rice.krad.uif.modifier.ComponentModifier#getRunCondition()
90  	 */
91      @BeanTagAttribute(name="runCondition")
92  	public String getRunCondition() {
93  		return this.runCondition;
94  	}
95  
96  	/**
97  	 * Setter for the component modifiers run condition
98  	 *
99  	 * @param runCondition
100 	 */
101 	public void setRunCondition(String runCondition) {
102 		this.runCondition = runCondition;
103 	}
104 
105 	/**
106 	 * @see org.springframework.core.Ordered#getOrder()
107 	 */
108     @BeanTagAttribute(name="order")
109 	public int getOrder() {
110 		return this.order;
111 	}
112 
113 	/**
114 	 * @see org.kuali.rice.krad.uif.component.Ordered#setOrder(int)
115 	 */
116 	public void setOrder(int order) {
117 		this.order = order;
118 	}
119 
120     /**
121      * Copies the properties over for the copy method
122      *
123      */
124     protected <T> void copyProperties(T componentModifier) {
125         ComponentModifierBase componentModifierBase = (ComponentModifierBase) componentModifier;
126         componentModifierBase.setOrder(this.order);
127         componentModifierBase.setRunCondition(this.runCondition);
128         componentModifierBase.setRunPhase(this.runPhase);
129     }
130 }