View Javadoc

1   /**
2    * Copyright 2005-2012 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.widget;
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.service.KRADServiceLocatorWeb;
21  import org.kuali.rice.krad.uif.util.ExpressionUtils;
22  import org.kuali.rice.krad.uif.view.HistoryEntry;
23  import org.kuali.rice.krad.uif.view.View;
24  import org.kuali.rice.krad.uif.component.Component;
25  
26  import java.util.ArrayList;
27  import java.util.HashMap;
28  import java.util.List;
29  import java.util.Map;
30  
31  /**
32   * The breadcrumb widget contains various settings for setting up
33   * Breadcrumb/History support on the view
34   *
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  @BeanTag(name = "breadcrumbs", parent = "Uif-Breadcrumbs")
38  public class BreadCrumbs extends WidgetBase {
39      private static final long serialVersionUID = -2864287914665842251L;
40  
41      private boolean displayHomewardPath;
42      private boolean displayPassedHistory;
43      private boolean displayBreadcrumbsWhenOne;
44  
45      private List<HistoryEntry> homewardPathList;
46  
47      public BreadCrumbs() {
48          homewardPathList = new ArrayList<HistoryEntry>();
49      }
50  
51      /**
52       * The following updates are done here:
53       *
54       * <ul>
55       * <li>Evaluate expression on homeward path list</li>
56       * </ul>
57       *
58       * @see org.kuali.rice.krad.uif.component.Component#performApplyModel(org.kuali.rice.krad.uif.view.View,
59       *      java.lang.Object, org.kuali.rice.krad.uif.component.Component)
60       */
61      @Override
62      public void performApplyModel(View view, Object model, Component parent) {
63          super.performApplyModel(view, model, parent);
64  
65          if (homewardPathList != null) {
66              Map<String, Object> context = new HashMap<String, Object>();
67              context.putAll(view.getContext());
68  
69              for (HistoryEntry historyEntry : homewardPathList) {
70                  ExpressionUtils.populatePropertyExpressionsFromGraph(historyEntry, false);
71                  KRADServiceLocatorWeb.getExpressionEvaluatorService().evaluateExpressionsOnConfigurable(view,
72                          historyEntry, model, context);
73              }
74          }
75      }
76  
77      /**
78       * Determines if the homewardPath is to be displayed. Even when this is
79       * setting is on the code may determine to turn off homewardPath display
80       * based on user interaction and ui elements being displayed (ie lightbox)
81       *
82       * @return the displayHomewardPath
83       */
84      @BeanTagAttribute(name="displayHomewardPath")
85      public boolean isDisplayHomewardPath() {
86          return this.displayHomewardPath;
87      }
88  
89      /**
90       * @param displayHomewardPath the displayHomewardPath to set
91       */
92      public void setDisplayHomewardPath(boolean displayHomewardPath) {
93          this.displayHomewardPath = displayHomewardPath;
94      }
95  
96      /**
97       * Determines if the passedHistory is to be displayed. In most cases this
98       * should not be set through the xml as this is toggled off and on through
99       * code during different ui procedures.
100      *
101      * @return the displayPassedHistory
102      */
103     @BeanTagAttribute(name="displayPassedHistory")
104     public boolean isDisplayPassedHistory() {
105         return this.displayPassedHistory;
106     }
107 
108     /**
109      * @param displayPassedHistory the displayPassedHistory to set
110      */
111     public void setDisplayPassedHistory(boolean displayPassedHistory) {
112         this.displayPassedHistory = displayPassedHistory;
113     }
114 
115     /**
116      * The homewardPath to be displayed on this representative of the logical
117      * "location" of the view within the site hierarchy, can be set to anything
118      * desired.
119      *
120      * @return the homewardPathList
121      */
122     @BeanTagAttribute(name="homewardPathList",type= BeanTagAttribute.AttributeType.LISTBEAN)
123     public List<HistoryEntry> getHomewardPathList() {
124         return this.homewardPathList;
125     }
126 
127     /**
128      * @param homewardPathList the homewardPathList to set
129      */
130     public void setHomewardPathList(List<HistoryEntry> homewardPathList) {
131         this.homewardPathList = homewardPathList;
132     }
133 
134     /**
135      * If true, breadcrumbs will not be displayed if only one breadcrumb is
136      * going to be shown, this improves visual clarity of the page
137      *
138      * @return the displayBreadcrumbsWhenOne
139      */
140     @BeanTagAttribute(name="displayBreadcrumbsWhenOne")
141     public boolean isDisplayBreadcrumbsWhenOne() {
142         return this.displayBreadcrumbsWhenOne;
143     }
144 
145     /**
146      * @param displayBreadcrumbsWhenOne the displayBreadcrumbsWhenOne to set
147      */
148     public void setDisplayBreadcrumbsWhenOne(boolean displayBreadcrumbsWhenOne) {
149         this.displayBreadcrumbsWhenOne = displayBreadcrumbsWhenOne;
150     }
151 
152 }