View Javadoc

1   /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.student.common.ui.client.configurable.mvc.views;
17  
18  import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
19  import org.kuali.student.common.ui.client.widgets.field.layout.layouts.VerticalFieldLayout;
20  
21  import com.google.gwt.user.client.ui.Widget;
22  
23  /**
24   * The vertical layout implementation of SectionView.  The ui layout behaves exactly the same as
25   * VerticalSection.
26   * 
27   * A model id can be passed in to specify a model this particular view uses.
28   * 
29   * @author Brian Smith
30   *
31   */
32  public class VerticalSectionView extends SectionView {
33  
34  
35      /**
36       * Same as VerticalSectionView(Enum<?> viewEnum, String name, String modelId, true)
37       */
38      public VerticalSectionView(Enum<?> viewEnum, String name, String modelId) {
39          this(viewEnum, name, modelId, true);
40      }
41  
42      /**
43       * @param viewEnum Enumeration of this view - id used for navigation, history, and showing a view
44       * @param name Name of this view - what this view is called in the breadcrumb
45       * @param modelId id of the model to be used for this view when a requestModel call is made on its parent controller
46       * @param showTitle if true, show the view's name as an H2 header
47       */
48      public VerticalSectionView(Enum<?> viewEnum, String name, String modelId, boolean showTitle) {
49          super(viewEnum, name);
50          this.modelId = modelId;
51          if (name != null && !name.isEmpty()) {
52              SectionTitle sectionTitle = SectionTitle.generateH2Title(getName());
53              if (showTitle) {
54                  layout = new VerticalFieldLayout(sectionTitle);
55              } else {
56                  layout = new VerticalFieldLayout();
57              }
58          } else {
59              layout = new VerticalFieldLayout();
60          }
61          this.add(layout);
62      }
63  
64      /**
65       * VerticalSectionView with a custom titleWidget defined
66       * @param viewEnum
67       * @param name
68       * @param modelId
69       * @param titleWidget
70       */
71      public VerticalSectionView(Enum<?> viewEnum, String name, String modelId, Widget titleWidget) {
72          super(viewEnum, name);
73          this.modelId = modelId;
74          layout = new VerticalFieldLayout(titleWidget);
75          this.add(layout);
76      }
77  
78      /**
79       * This updates the model
80       *
81       * @see org.kuali.student.common.ui.client.mvc.View#updateModel()
82       */
83      @Override
84      @SuppressWarnings("unchecked")
85      public void updateModel() {
86          if (model != null && isValidationEnabled()) {
87              super.updateModel(model);
88          }
89      }
90  
91      @Override
92      public void clear() {
93          // TODO Auto-generated method stub
94      }
95  
96      public void setSectionTitle(String title) {
97          layout.setLayoutTitle(SectionTitle.generateH2Title(title));
98      }
99  }