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