001/**
002 * Copyright 2005-2018 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.layout;
017
018import org.kuali.rice.krad.datadictionary.parse.BeanTag;
019import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
020import org.kuali.rice.krad.datadictionary.parse.BeanTags;
021import org.kuali.rice.krad.uif.component.Component;
022import org.kuali.rice.krad.uif.component.ListAware;
023import org.kuali.rice.krad.uif.container.Group;
024import org.kuali.rice.krad.uif.util.LifecycleElement;
025
026/**
027 * List layout manager is a layout manager for group types to output their items as either ordered or
028 * unordered lists.
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032@BeanTags({@BeanTag(name = "listLayout", parent = "Uif-ListLayout"),
033        @BeanTag(name = "orderedListLayout", parent = "Uif-OrderedListLayout")})
034public class ListLayoutManager extends LayoutManagerBase {
035    private static final long serialVersionUID = -8611267646944565117L;
036
037    private boolean orderedList;
038
039    public ListLayoutManager() {
040        super();
041    }
042
043    /**
044     * Iterates through the groups items and sets the rendered in list boolean.
045     *
046     * {@inheritDoc}
047     */
048    @Override
049    public void performApplyModel(Object model, LifecycleElement component) {
050        super.performApplyModel(model, component);
051
052        Group parentGroup = (Group) component;
053
054        for (Component item : parentGroup.getItems()) {
055            if (ListAware.class.isAssignableFrom(item.getClass())) {
056                ((ListAware) item).setRenderedInList(true);
057            }
058        }
059    }
060
061    /**
062     * If true, this list layout is an ordered list (ol).  Otherwise, the the layout is an unordered list (ul).
063     *
064     * @return true if orderedList, false if unordered
065     */
066    @BeanTagAttribute
067    public boolean isOrderedList() {
068        return orderedList;
069    }
070
071    /**
072     * Setter for {@link ListLayoutManager#isOrderedList()}.
073     * @param orderedList property value
074     */
075    public void setOrderedList(boolean orderedList) {
076        this.orderedList = orderedList;
077    }
078
079}