View Javadoc
1   /**
2    * Copyright 2005-2016 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.control;
17  
18  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20  import org.kuali.rice.krad.uif.component.Component;
21  import org.kuali.rice.krad.uif.widget.Spinner;
22  
23  import java.util.List;
24  
25  /**
26   * Text control that as decorated with a spinner widget (allowing the control value to be modified using the
27   * spinner)
28   *
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  @BeanTag(name = "spinnerControl-bean", parent = "Uif-SpinnerControl")
32  public class SpinnerControl extends TextControl {
33      private static final long serialVersionUID = -8267606288443759880L;
34  
35      private Spinner spinner;
36  
37      public SpinnerControl() {
38          super();
39      }
40  
41      /**
42       * @see org.kuali.rice.krad.uif.component.ComponentBase#getComponentsForLifecycle()
43       */
44      @Override
45      public List<Component> getComponentsForLifecycle() {
46          List<Component> components = super.getComponentsForLifecycle();
47  
48          components.add(getSpinner());
49  
50          return components;
51      }
52  
53      /**
54       * Spinner widget that should decorate the control
55       *
56       * @return Spinner
57       */
58      @BeanTagAttribute(name="spinner",type = BeanTagAttribute.AttributeType.SINGLEBEAN)
59      public Spinner getSpinner() {
60          return spinner;
61      }
62  
63      /**
64       * Setter for the control's spinner widget instance
65       *
66       * @param spinner
67       */
68      public void setSpinner(Spinner spinner) {
69          this.spinner = spinner;
70      }
71  
72      /**
73       * @see org.kuali.rice.krad.uif.component.ComponentBase#copy()
74       */
75      @Override
76      protected <T> void copyProperties(T component) {
77          super.copyProperties(component);
78          SpinnerControl spinnerControlCopy = (SpinnerControl) component;
79  
80          if(this.spinner != null) {
81              spinnerControlCopy.setSpinner((Spinner)this.spinner.copy());
82          }
83      }
84  }