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.layout;
017
018import org.kuali.rice.krad.uif.container.CollectionGroup;
019import org.kuali.rice.krad.uif.field.FieldGroup;
020import org.kuali.rice.krad.uif.view.View;
021import org.kuali.rice.krad.uif.field.ActionField;
022import org.kuali.rice.krad.uif.field.Field;
023
024import java.util.List;
025
026/**
027 * Layout manager implementations that work with a collection (such as a table
028 * layout) should implement this interface for building the collection
029 * <code>Component</code> instances
030 * 
031 * <p>
032 * Unlike other <code>Group</code> instances, <code>CollectionGroup</code>
033 * instances need to generate new instances of the configured components for
034 * each line of the collection. The <code>Field</code> instances for each line
035 * are wrapped differently depending on what <code>LayoutManager</code> is being
036 * applied. Therefore as the collection lines are being built (during the
037 * applyModel phase) this method will be invoked on the manager so that it may
038 * setup the line as needed.
039 * </p>
040 * 
041 * @author Kuali Rice Team (rice.collab@kuali.org)
042 * @see org.kuali.rice.krad.uif.container.CollectionGroupBuilder
043 */
044public interface CollectionLayoutManager extends LayoutManager {
045
046        /**
047         * Call to the layout manager to build the components necessary for the
048         * given collection line
049         * 
050         * <p>
051         * As the collection is being iterated over by the
052         * <code>CollectionGroupBuilder</code> this method is invoked for each line.
053         * The builder will create copies of the configured fields and actions for
054         * the line and pass into the layout manager so they can be assembled
055         * </p>
056         * 
057         * @param view
058         *            - view instance the collection belongs to
059         * @param model
060         *            - object containing the data
061         * @param collectionGroup
062         *            - collection group the layout manager applies to
063         * @param lineFields
064         *            - the field instances for the collection line which were
065         *            copied from the collection groups items, id and binding
066         *            already updated
067         * @param subCollectionFields
068         *            - group field instances for each sub collection of the current
069         *            line
070         * @param bindingPath
071         *            - binding path for the groups items (if DataBinding)
072         * @param actions
073         *            - list of action instances for the collection line, with id
074         *            and binding updated
075         * @param idSuffix
076         *            - suffix to use for any generated items
077         * @param currentLine
078         *            - object instance for the current line, or null if add line
079         * @param lineIndex
080         *            - index of the collection line being iterated over, or -1 if
081         *            the add line
082         */
083        public void buildLine(View view, Object model, CollectionGroup collectionGroup, List<Field> lineFields,
084                        List<FieldGroup> subCollectionFields, String bindingPath, List<ActionField> actions, String idSuffix,
085                        Object currentLine, int lineIndex);
086
087        /**
088         * Field group instance that is used as a prototype for creating the
089         * sub-collection field groups. For each sub-collection a copy of the
090         * prototype is made and the list will be passed to the layout manager
091         * buildLine method
092         * 
093         * @return GroupField instance to use as prototype
094         */
095        public FieldGroup getSubCollectionFieldGroupPrototype();
096}