001/**
002 * Copyright 2005-2012 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.HashMap;
024import java.util.List;
025import java.util.Map;
026
027/**
028 * The breadcrumb widget contains various settings for setting up
029 * Breadcrumb/History support on the view.
030 *
031 * @author Kuali Rice Team (rice.collab@kuali.org)
032 */
033public class BreadCrumbs extends WidgetBase {
034    private static final long serialVersionUID = -2864287914665842251L;
035
036    private boolean displayHomewardPath;
037    private boolean displayPassedHistory;
038    private boolean displayBreadcrumbsWhenOne;
039    private List<HistoryEntry> homewardPathList;
040
041    /**
042     * The following updates are done here:
043     *
044     * <ul>
045     * <li>Evaluate expression on howeward path list</li>
046     * </ul>
047     *
048     * @see org.kuali.rice.krad.uif.component.Component#performApplyModel(org.kuali.rice.krad.uif.view.View,
049     *      java.lang.Object)
050     */
051    @Override
052    public void performApplyModel(View view, Object model, Component parent) {
053        super.performApplyModel(view, model, parent);
054
055        if (homewardPathList != null) {
056            Map<String, Object> context = new HashMap<String, Object>();
057            context.putAll(view.getContext());
058
059            for (HistoryEntry historyEntry : homewardPathList) {
060                KRADServiceLocatorWeb.getExpressionEvaluatorService().evaluateObjectExpressions(historyEntry, model,
061                        context);
062            }
063        }
064    }
065
066    /**
067     * Determines if the homewardPath is to be displayed. Even when this is
068     * setting is on the code may determine to turn off homewardPath display
069     * based on user interaction and ui elements being displayed (ie lightbox)
070     *
071     * @return the displayHomewardPath
072     */
073    public boolean isDisplayHomewardPath() {
074        return this.displayHomewardPath;
075    }
076
077    /**
078     * @param displayHomewardPath the displayHomewardPath to set
079     */
080    public void setDisplayHomewardPath(boolean displayHomewardPath) {
081        this.displayHomewardPath = displayHomewardPath;
082    }
083
084    /**
085     * Determines if the passedHistory is to be displayed. In most cases this
086     * should not be set through the xml as this is toggled off and on through
087     * code during different ui procedures.
088     *
089     * @return the displayPassedHistory
090     */
091    public boolean isDisplayPassedHistory() {
092        return this.displayPassedHistory;
093    }
094
095    /**
096     * @param displayPassedHistory the displayPassedHistory to set
097     */
098    public void setDisplayPassedHistory(boolean displayPassedHistory) {
099        this.displayPassedHistory = displayPassedHistory;
100    }
101
102    /**
103     * The homewardPath to be displayed on this representative of the logical
104     * "location" of the view within the site hierarchy, can be set to anything
105     * desired.
106     *
107     * @return the homewardPathList
108     */
109    public List<HistoryEntry> getHomewardPathList() {
110        return this.homewardPathList;
111    }
112
113    /**
114     * @param homewardPathList the homewardPathList to set
115     */
116    public void setHomewardPathList(List<HistoryEntry> homewardPathList) {
117        this.homewardPathList = homewardPathList;
118    }
119
120    /**
121     * If true, breadcrumbs will not be displayed if only one breadcrumb is
122     * going to be shown, this improves visual clarity of the page
123     *
124     * @return the displayBreadcrumbsWhenOne
125     */
126    public boolean isDisplayBreadcrumbsWhenOne() {
127        return this.displayBreadcrumbsWhenOne;
128    }
129
130    /**
131     * @param displayBreadcrumbsWhenOne the displayBreadcrumbsWhenOne to set
132     */
133    public void setDisplayBreadcrumbsWhenOne(boolean displayBreadcrumbsWhenOne) {
134        this.displayBreadcrumbsWhenOne = displayBreadcrumbsWhenOne;
135    }
136
137}