View Javadoc
1   /**
2    * Copyright 2005-2014 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.container;
17  
18  import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
19  import org.kuali.rice.krad.uif.component.BindingInfo;
20  import org.kuali.rice.krad.uif.component.Component;
21  import org.kuali.rice.krad.uif.component.ComponentSecurity;
22  import org.kuali.rice.krad.uif.component.DataBinding;
23  import org.kuali.rice.krad.uif.element.Action;
24  import org.kuali.rice.krad.uif.element.Message;
25  import org.kuali.rice.krad.uif.view.View;
26  import org.kuali.rice.krad.uif.widget.QuickFinder;
27  
28  import java.util.List;
29  
30  /**
31   * Interface representing an editable collection within a view. 
32   * 
33   * @author Kuali Rice Team (rice.collab@kuali.org)
34   */
35  public interface CollectionGroup extends Group, DataBinding {
36  
37      /**
38       * Sets a reference in the context map for all nested components in the collection group
39       * instance, and sets selected collection path and id data attributes on nested actions of this group.
40       */
41      void pushCollectionGroupToReference();
42  
43      /**
44       * New collection lines are handled in the framework by maintaining a map on
45       * the form. The map contains as a key the collection name, and as value an
46       * instance of the collection type. An entry is created here for the
47       * collection represented by the <code>CollectionGroup</code> if an instance
48       * is not available (clearExistingLine will force a new instance). The given
49       * model must be a subclass of <code>UifFormBase</code> in order to find the
50       * Map.
51       *
52       * @param model Model instance that contains the new collection lines Map
53       * @param clearExistingLine boolean that indicates whether the line should be set to a
54       * new instance if it already exists
55       */
56      void initializeNewCollectionLine(View view, Object model, CollectionGroup collectionGroup,
57              boolean clearExistingLine);
58  
59      /**
60       * Object class the collection maintains. Used to get dictionary information
61       * in addition to creating new instances for the collection when necessary
62       *
63       * @return collection object class
64       */
65      Class<?> getCollectionObjectClass();
66  
67      /**
68       * Setter for the collection object class
69       *
70       * @param collectionObjectClass
71       */
72      void setCollectionObjectClass(Class<?> collectionObjectClass);
73  
74      /**
75       * Setter for the collections property name
76       *
77       * @param propertyName
78       */
79      void setPropertyName(String propertyName);
80  
81      /**
82       * Action fields that should be rendered for each collection line. Example
83       * line action is the delete action
84       *
85       * @return line action fields
86       */
87      List<? extends Component> getLineActions();
88  
89      /**
90       * Setter for the line action fields list
91       *
92       * @param lineActions
93       */
94      void setLineActions(List<? extends Component> lineActions);
95  
96      /**
97       * Indicates whether the action column for the collection should be rendered
98       *
99       * @return true if the actions should be rendered, false if not
100      * @see #getLineActions()
101      */
102     boolean isRenderLineActions();
103 
104     /**
105      * Setter for the render line actions indicator
106      *
107      * @param renderLineActions
108      */
109     void setRenderLineActions(boolean renderLineActions);
110 
111     /**
112      * Indicates whether an add line should be rendered for the collection
113      *
114      * @return true if add line should be rendered, false if it should not be
115      */
116     boolean isRenderAddLine();
117 
118     /**
119      * Setter for the render add line indicator
120      *
121      * @param renderAddLine
122      */
123     void setRenderAddLine(boolean renderAddLine);
124 
125     /**
126      * Get the id of the add line action to invoke when the enter key is pressed.
127      *
128      * <p>Use '@DEFAULT' if supposed to use first action where 'defaultEnterKeyAction'
129      * property is set to true.</p>
130      * 
131      * @return id or '@DEFAULT'
132      */
133     String getAddLineEnterKeyAction();
134 
135     /**
136      * @see #getAddLineEnterKeyAction()
137      */
138     void setAddLineEnterKeyAction(String addLineEnterKeyAction);
139 
140     /**
141      * Get the id of the nonAdd line action to invoke when the enter key is pressed.
142      *
143      * <p>Use '@DEFAULT' if supposed to use first action where 'defaultEnterKeyAction'
144      * property is set to true. In a collection may have to use SpringEL to identify
145      * line ID values. Here is a sample value: DemoButton@{#lineSuffix}. Notice the use
146      * of '@{#lineSuffix}' to help append line suffix information.</p>
147      * 
148      * @return id or '@DEFAULT'
149      */
150     String getLineEnterKeyAction();
151 
152     /**
153      * @see #getLineEnterKeyAction()
154      */
155     void setLineEnterKeyAction(String lineEnterKeyAction);
156 
157     /**
158      * Convenience getter for the add line label field text. The text is used to
159      * label the add line when rendered and its placement depends on the
160      * <code>LayoutManager</code>
161      *
162      * <p>
163      * For the <code>TableLayoutManager</code> the label appears in the sequence
164      * column to the left of the add line fields. For the
165      * <code>StackedLayoutManager</code> the label is placed into the group
166      * header for the line.
167      * </p>
168      *
169      * @return add line label
170      */
171     String getAddLabel();
172 
173     /**
174      * Setter for the add line label text
175      *
176      * @param addLabelText
177      */
178     void setAddLabel(String addLabelText);
179 
180     /**
181      * <code>Message</code> instance for the add line label
182      *
183      * @return add line Message
184      * @see #getAddLabel
185      */
186     Message getAddLineLabel();
187 
188     /**
189      * Setter for the <code>Message</code> instance for the add line label
190      *
191      * @param addLineLabel
192      * @see #getAddLabel
193      */
194     void setAddLineLabel(Message addLineLabel);
195 
196     /**
197      * Name of the property that contains an instance for the add line. If set
198      * this is used with the binding info to create the path to the add line.
199      * Can be left blank in which case the framework will manage the add line
200      * instance in a generic map.
201      *
202      * @return add line property name
203      */
204     String getAddLinePropertyName();
205 
206     /**
207      * Setter for the add line property name
208      *
209      * @param addLinePropertyName
210      */
211     void setAddLinePropertyName(String addLinePropertyName);
212 
213     /**
214      * <code>BindingInfo</code> instance for the add line property used to
215      * determine the full binding path. If add line name given
216      * {@link #getAddLabel} then it is set as the binding name on the
217      * binding info. Add line label and binding info are not required, in which
218      * case the framework will manage the new add line instances through a
219      * generic map (model must extend UifFormBase)
220      *
221      * @return BindingInfo add line binding info
222      */
223     BindingInfo getAddLineBindingInfo();
224 
225     /**
226      * Setter for the add line binding info
227      *
228      * @param addLineBindingInfo
229      */
230     void setAddLineBindingInfo(BindingInfo addLineBindingInfo);
231 
232     /**
233      * List of <code>Component</code> instances that should be rendered for the
234      * collection add line (if enabled). If not set, the default group's items
235      * list will be used
236      *
237      * @return add line field list
238      * @see CollectionGroup#performInitialization(Object)
239      */
240     List<? extends Component> getAddLineItems();
241 
242     /**
243      * Setter for the add line field list
244      *
245      * @param addLineItems
246      */
247     void setAddLineItems(List<? extends Component> addLineItems);
248 
249     /**
250      * Component fields that should be rendered for the add line.
251      *
252      * <p>This is generally the add action (button) but can be configured to contain additional
253      * components
254      * </p>
255      *
256      * @return add line action fields
257      */
258     List<? extends Component> getAddLineActions();
259 
260     /**
261      * Setter for the add line action components fields
262      *
263      * @param addLineActions
264      */
265     void setAddLineActions(List<? extends Component> addLineActions);
266 
267     /**
268      * Indicates whether lines of the collection group should be selected by rendering a
269      * field for each line that will allow selection
270      *
271      * <p>
272      * For example, having the select field enabled could allow selecting multiple lines from a search
273      * to return (multi-value lookup)
274      * </p>
275      *
276      * @return true if select field should be rendered, false if not
277      */
278     boolean isIncludeLineSelectionField();
279 
280     /**
281      * Setter for the render selected field indicator
282      *
283      * @param includeLineSelectionField
284      */
285     void setIncludeLineSelectionField(boolean includeLineSelectionField);
286 
287     /**
288      * When {@link #isIncludeLineSelectionField()} is true, gives the name of the property the select field
289      * should bind to
290      *
291      * <p>
292      * Note if no prefix is given in the property name, such as 'form.', it is assumed the property is
293      * contained on the collection line. In this case the binding path to the collection line will be
294      * appended. In other cases, it is assumed the property is a list or set of String that will hold the
295      * selected identifier strings
296      * </p>
297      *
298      * <p>
299      * This property is not required. If not the set the framework will use a property contained on
300      * <code>UifFormBase</code>
301      * </p>
302      *
303      * @return property name for select field
304      */
305     String getLineSelectPropertyName();
306 
307     /**
308      * Setter for the property name that will bind to the select field
309      *
310      * @param lineSelectPropertyName
311      */
312     void setLineSelectPropertyName(String lineSelectPropertyName);
313 
314     /**
315      * Instance of the <code>QuickFinder</code> widget that configures a multi-value lookup for the collection
316      *
317      * <p>
318      * If the collection lookup is enabled (by the render property of the quick finder), {@link
319      * #getCollectionObjectClass()} will be used as the data object class for the lookup (if not set). Field
320      * conversions need to be set as usual and will be applied for each line returned
321      * </p>
322      *
323      * @return instance configured for the collection lookup
324      */
325     QuickFinder getCollectionLookup();
326 
327     /**
328      * Setter for the collection lookup quickfinder instance
329      *
330      * @param collectionLookup
331      */
332     void setCollectionLookup(QuickFinder collectionLookup);
333 
334     /**
335      * Indicates whether inactive collections lines should be displayed
336      *
337      * <p>
338      * Setting only applies when the collection line type implements the
339      * <code>Inactivatable</code> interface. If true and showInactive is
340      * set to false, the collection will be filtered to remove any items
341      * whose active status returns false
342      * </p>
343      *
344      * @return true to show inactive records, false to not render inactive records
345      */
346     boolean isShowInactiveLines();
347 
348     /**
349      * Setter for the show inactive indicator
350      *
351      * @param showInactiveLines boolean show inactive
352      */
353     void setShowInactiveLines(boolean showInactiveLines);
354 
355     /**
356      * Collection filter instance for filtering the collection data when the
357      * showInactive flag is set to false
358      *
359      * @return CollectionFilter
360      */
361     CollectionFilter getActiveCollectionFilter();
362 
363     /**
364      * Setter for the collection filter to use for filter inactive records from the
365      * collection
366      *
367      * @param activeCollectionFilter CollectionFilter instance
368      */
369     void setActiveCollectionFilter(CollectionFilter activeCollectionFilter);
370 
371     /**
372      * List of {@link CollectionFilter} instances that should be invoked to filter the collection before
373      * displaying
374      *
375      * @return List<CollectionFilter>
376      */
377     List<CollectionFilter> getFilters();
378 
379     /**
380      * Setter for the List of collection filters for which the collection will be filtered against
381      *
382      * @param filters
383      */
384     void setFilters(List<CollectionFilter> filters);
385 
386     /**
387      * List of property names that should be checked for duplicates in the collection.
388      *
389      * @return the list of property names that should be checked for duplicates in the collection
390      */
391     List<String> getDuplicateLinePropertyNames();
392 
393     /**
394      * @see CollectionGroup#getDuplicateLinePropertyNames()
395      */
396     void setDuplicateLinePropertyNames(List<String> duplicateLinePropertyNames);
397 
398     /**
399      *  List of {@link BindingInfo} instances that represent lines not authorized to be viewed or edited by the user.
400      */
401     List<BindingInfo> getUnauthorizedLineBindingInfos();
402 
403     /**
404      * @see CollectionGroup#getUnauthorizedLineBindingInfos()
405      */
406     void setUnauthorizedLineBindingInfos(List<BindingInfo> unauthorizedLineBindingInfos);
407 
408     /**
409      * List of <code>CollectionGroup</code> instances that are sub-collections
410      * of the collection represented by this collection group
411      *
412      * @return sub collections
413      */
414     List<CollectionGroup> getSubCollections();
415 
416     /**
417      * Setter for the sub collection list
418      *
419      * @param subCollections
420      */
421     void setSubCollections(List<CollectionGroup> subCollections);
422 
423     /**
424      * Collection Security object that indicates what authorization (permissions) exist for the collection
425      *
426      * @return CollectionGroupSecurity instance
427      */
428     CollectionGroupSecurity getCollectionGroupSecurity();
429 
430     /**
431      * Override to assert a {@link CollectionGroupSecurity} instance is set
432      *
433      * @param componentSecurity instance of CollectionGroupSecurity
434      */
435     void setComponentSecurity(ComponentSecurity componentSecurity);
436 
437     /**
438      * @see org.kuali.rice.krad.uif.container.CollectionGroupSecurity#isEditLineAuthz()
439      */
440     boolean isEditLineAuthz();
441 
442     /**
443      * @see org.kuali.rice.krad.uif.container.CollectionGroupSecurity#setEditLineAuthz(boolean)
444      */
445     void setEditLineAuthz(boolean editLineAuthz);
446 
447     /**
448      * @see org.kuali.rice.krad.uif.container.CollectionGroupSecurity#isViewLineAuthz()
449      */
450     boolean isViewLineAuthz();
451 
452     /**
453      * @see org.kuali.rice.krad.uif.container.CollectionGroupSecurity#setViewLineAuthz(boolean)
454      */
455     void setViewLineAuthz(boolean viewLineAuthz);
456 
457     /**
458      * <code>CollectionGroupBuilder</code> instance that will build the
459      * components dynamically for the collection instance
460      *
461      * @return CollectionGroupBuilder instance
462      */
463     CollectionGroupBuilder getCollectionGroupBuilder();
464 
465     /**
466      * Setter for the collection group building instance
467      *
468      * @param collectionGroupBuilder
469      */
470     void setCollectionGroupBuilder(CollectionGroupBuilder collectionGroupBuilder);
471 
472     /**
473      * @param renderInactiveToggleButton the showHideInactiveButton to set
474      */
475     void setRenderInactiveToggleButton(boolean renderInactiveToggleButton);
476 
477     /**
478      * @return the showHideInactiveButton
479      */
480     boolean isRenderInactiveToggleButton();
481 
482     /**
483      * The number of records to display for a collection
484      *
485      * @return int
486      */
487     int getDisplayCollectionSize();
488 
489     /**
490      * Setter for the display collection size
491      *
492      * @param displayCollectionSize
493      */
494     void setDisplayCollectionSize(int displayCollectionSize);
495 
496     /**
497      * Indicates whether new items should be styled with the #newItemsCssClass
498      *
499      * @return true if new items must be highlighted
500      */
501     boolean isHighlightNewItems();
502 
503     /**
504      * Setter for the flag that allows for different styling of new items
505      *
506      * @param highlightNewItems
507      */
508     void setHighlightNewItems(boolean highlightNewItems);
509 
510     /**
511      * The css style class that will be added on new items
512      *
513      * @return the new items css style class
514      */
515     String getNewItemsCssClass();
516 
517     /**
518      * Setter for the new items css style class
519      *
520      * @param newItemsCssClass
521      */
522     void setNewItemsCssClass(String newItemsCssClass);
523 
524     /**
525      * The css style class that will be added on the add item group or row
526      *
527      * @return the add item group or row css style class
528      */
529     String getAddItemCssClass();
530 
531     /**
532      * Setter for the add item css style class
533      *
534      * @param addItemCssClass
535      */
536     void setAddItemCssClass(String addItemCssClass);
537 
538     /**
539      * Indicates whether the add item group or row should be styled with the #addItemCssClass
540      *
541      * @return true if add item group or row must be highlighted
542      */
543     boolean isHighlightAddItem();
544 
545     /**
546      * Setter for the flag that allows for different styling of the add item group or row
547      *
548      * @param highlightAddItem
549      */
550     void setHighlightAddItem(boolean highlightAddItem);
551 
552     /**
553      * Indicates that a button will be rendered that allows the user to add blank lines to the collection
554      *
555      * <p>
556      * The button will be added separately from the collection items. The default add line wil not be rendered. The
557      * action of the button will call the controller, add the blank line to the collection and do a component refresh.
558      * </p>
559      *
560      * @return boolean
561      */
562     boolean isRenderAddBlankLineButton();
563 
564     /**
565      * Setter for the flag indicating that the add blank line button must be rendered
566      *
567      * @param renderAddBlankLineButton
568      */
569     void setRenderAddBlankLineButton(boolean renderAddBlankLineButton);
570 
571     /**
572      * The add blank line {@link Action} field rendered when renderAddBlankLineButton is true
573      *
574      * @return boolean
575      */
576     Action getAddBlankLineAction();
577 
578     /**
579      * Setter for the add blank line {@link Action} field
580      *
581      * @param addBlankLineAction
582      */
583     void setAddBlankLineAction(Action addBlankLineAction);
584 
585     /**
586      * Indicates the add line placement
587      *
588      * <p>
589      * Valid values are 'TOP' or 'BOTTOM'. The default is 'TOP'. When the value is 'BOTTOM' the blank line will be
590      * added
591      * to the end of the collection.
592      * </p>
593      *
594      * @return the add blank line action placement
595      */
596     String getAddLinePlacement();
597 
598     /**
599      * Setter for the add line placement
600      *
601      * @param addLinePlacement add line placement string
602      */
603     void setAddLinePlacement(String addLinePlacement);
604 
605     /**
606      * Indicates whether the save line actions should be rendered
607      *
608      * @return boolean
609      */
610     boolean isRenderSaveLineActions();
611 
612     /**
613      * Setter for the flag indicating whether the save actions should be rendered
614      *
615      * @param renderSaveLineActions
616      */
617     void setRenderSaveLineActions(boolean renderSaveLineActions);
618 
619     /**
620      * Indicates that a add action should be rendered and that the add group be displayed in a model dialog.
621      *
622      * @return boolean true if add should be through model dialog, false if not
623      */
624     boolean isAddWithDialog();
625 
626     /**
627      * @see CollectionGroup#isAddWithDialog()
628      */
629     void setAddWithDialog(boolean addWithDialog);
630 
631     /**
632      * The {@link Action} that will be displayed that will open the add line group in a dialog.
633      *
634      * @return Action
635      */
636     Action getAddWithDialogAction();
637 
638     /**
639      * @see CollectionGroup#getAddWithDialogAction()
640      */
641     void setAddWithDialogAction(Action addViaLightBoxAction);
642 
643     /**
644      * Dialog group to use for the add line when {@link CollectionGroup#isAddWithDialog()} is true.
645      *
646      * <p>If dialog group is not set by add with dialog is true, a default dialog group will be created.</p>
647      *
648      * <p>The add line items and actions are still used as usual, unless the items and footer items have been
649      * explicity set in the dialog group</p>
650      *
651      * @return dialog group instance for add line
652      */
653     DialogGroup getAddLineDialog();
654 
655     /**
656      * @see CollectionGroup#getAddLineDialog()
657      */
658     void setAddLineDialog(DialogGroup addLineDialog);
659 
660     /**
661      * Gets useServerPaging, the flag that indicates whether server side paging is enabled.  Defaults to false.
662      *
663      * @return true if server side paging is enabled.
664      */
665     boolean isUseServerPaging();
666 
667     /**
668      * Sets useServerPaging, the flag indicating whether server side paging is enabled.
669      *
670      * @param useServerPaging the useServerPaging value to set
671      */
672     void setUseServerPaging(boolean useServerPaging);
673 
674     int getPageSize();
675 
676     void setPageSize(int pageSize);
677 
678     /**
679      * Gets the displayStart, the index of the first item to display on the page (assuming useServerPaging is enabled).
680      *
681      * <p>if this field has not been set, the returned value will be -1</p>
682      *
683      * @return the index of the first item to display, or -1 if unset
684      */
685     int getDisplayStart();
686 
687     /**
688      * Sets the displayStart, the index of the first item to display on the page (assuming useServerPaging is enabled).
689      *
690      * @param displayStart the displayStart to set
691      */
692     void setDisplayStart(int displayStart);
693 
694     /**
695      * Gets the displayLength, the number of items to display on the page (assuming useServerPaging is enabled).
696      *
697      * <p>if this field has not been set, the returned value will be -1</p>
698      *
699      * @return the number of items to display on the page, or -1 if unset
700      */
701     int getDisplayLength();
702 
703     /**
704      * Sets the displayLength, the number of items to display on the page (assuming useServerPaging is enabled).
705      *
706      * @param displayLength the displayLength to set
707      */
708     void setDisplayLength(int displayLength);
709 
710     /**
711      * Gets the number of un-filtered elements from the model collection.
712      *
713      * <p>if this field has not been set, the returned value will be -1</p>
714      *
715      * @return the filtered collection size, or -1 if unset
716      */
717     int getFilteredCollectionSize();
718 
719     /**
720      * Sets the number of un-filtered elements from the model collection.
721      *
722      * <p>This value is used for display and rendering purposes, it has no effect on the model collection</p>
723      *
724      * @param filteredCollectionSize the filtered collection size
725      */
726     void setFilteredCollectionSize(int filteredCollectionSize);
727 
728     /**
729      * @see org.kuali.rice.krad.uif.component.Component#completeValidation
730      */
731     void completeValidation(ValidationTrace tracer);
732 
733     /**
734      * Indicates that an edit action should be rendered and that the edit group be displayed in a model dialog.
735      *
736      * @return boolean true if edit should be through model dialog, false if not
737      */
738     public boolean isEditWithDialog();
739 
740     /**
741      * @see CollectionGroup#isEditWithDialog()
742      */
743     public void setEditWithDialog(boolean editWithDialog);
744 
745     /**
746      * Indicates that a custom edit line dialog is provided by the user.
747      *
748      * @return boolean true if custom edit line dialog
749      */
750     public boolean isCustomEditLineDialog();
751 
752     /**
753      * @see org.kuali.rice.krad.uif.container.CollectionGroup#isCustomEditLineDialog()
754      */
755     public void setCustomEditLineDialog(boolean customEditLineDialog);
756 
757     /**
758      * Dialog group prototype to use to create the edit line dialog when {@link CollectionGroup#isEditWithDialog()}
759      * is true.
760      *
761      * <p>If not specified a default prototype edit line dialog will be created with the items from the collection.</p>
762      *
763      * @return dialog group prototype for edit line
764      */
765     public DialogGroup getEditLineDialogPrototype();
766 
767     /**
768      * @see CollectionGroup#getEditLineDialogPrototype()
769      */
770     public void setEditLineDialogPrototype(DialogGroup editLineDialogPrototype);
771 
772     /**
773      * The {@link Action} that will be displayed that will open the edit line group in a dialog.
774      *
775      * @return Action
776      */
777     public Action getEditWithDialogActionPrototype();
778 
779     /**
780      * @see CollectionGroup#getEditWithDialogActionPrototype()
781      */
782     public void setEditWithDialogActionPrototype(Action editWithDialogActionPrototype);
783 
784     /**
785      * The {@link Action} that will be displayed within the edit line group in a dialog.
786      *
787      * @return Action
788      */
789     public Action getEditInDialogSaveActionPrototype();
790 
791     /**
792      * @see CollectionGroup#getEditInDialogSaveActionPrototype()
793      */
794     public void setEditInDialogSaveActionPrototype(Action editInDialogSaveActionPrototype);
795 
796     /**
797      * List of dialog groups that are configured for a line in the collection.
798      *
799      * @return list of dialog group instances
800      */
801     public List<DialogGroup> getLineDialogs();
802 
803     /**
804      * @see CollectionGroup#getLineDialogs()
805      */
806     public void setLineDialogs(List<DialogGroup> dialogGroups);
807 
808 }