001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.uif.widget; 017 018import org.kuali.rice.krad.service.KRADServiceLocatorWeb; 019import org.kuali.rice.krad.uif.view.HistoryEntry; 020import org.kuali.rice.krad.uif.view.View; 021import org.kuali.rice.krad.uif.component.Component; 022 023import java.util.ArrayList; 024import java.util.HashMap; 025import java.util.List; 026import java.util.Map; 027 028/** 029 * The breadcrumb widget contains various settings for setting up 030 * Breadcrumb/History support on the view. 031 * 032 * @author Kuali Rice Team (rice.collab@kuali.org) 033 */ 034public class BreadCrumbs extends WidgetBase { 035 private static final long serialVersionUID = -2864287914665842251L; 036 037 private boolean displayHomewardPath; 038 private boolean displayPassedHistory; 039 private boolean displayBreadcrumbsWhenOne; 040 private List<HistoryEntry> homewardPathList; 041 042 public BreadCrumbs() { 043 homewardPathList = new ArrayList<HistoryEntry>(); 044 } 045 046 /** 047 * The following updates are done here: 048 * 049 * <ul> 050 * <li>Evaluate expression on howeward path list</li> 051 * </ul> 052 * 053 * @see org.kuali.rice.krad.uif.component.Component#performApplyModel(org.kuali.rice.krad.uif.view.View, 054 * java.lang.Object) 055 */ 056 @Override 057 public void performApplyModel(View view, Object model, Component parent) { 058 super.performApplyModel(view, model, parent); 059 060 if (homewardPathList != null) { 061 Map<String, Object> context = new HashMap<String, Object>(); 062 context.putAll(view.getContext()); 063 064 for (HistoryEntry historyEntry : homewardPathList) { 065 KRADServiceLocatorWeb.getExpressionEvaluatorService().evaluateObjectExpressions(historyEntry, model, 066 context); 067 } 068 } 069 } 070 071 /** 072 * Determines if the homewardPath is to be displayed. Even when this is 073 * setting is on the code may determine to turn off homewardPath display 074 * based on user interaction and ui elements being displayed (ie lightbox) 075 * 076 * @return the displayHomewardPath 077 */ 078 public boolean isDisplayHomewardPath() { 079 return this.displayHomewardPath; 080 } 081 082 /** 083 * @param displayHomewardPath the displayHomewardPath to set 084 */ 085 public void setDisplayHomewardPath(boolean displayHomewardPath) { 086 this.displayHomewardPath = displayHomewardPath; 087 } 088 089 /** 090 * Determines if the passedHistory is to be displayed. In most cases this 091 * should not be set through the xml as this is toggled off and on through 092 * code during different ui procedures. 093 * 094 * @return the displayPassedHistory 095 */ 096 public boolean isDisplayPassedHistory() { 097 return this.displayPassedHistory; 098 } 099 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}