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.layout;
17  
18  import java.util.List;
19  import java.util.Map;
20  import java.util.Set;
21  
22  import org.kuali.rice.krad.uif.component.Component;
23  import org.kuali.rice.krad.uif.container.Group;
24  import org.kuali.rice.krad.uif.element.Action;
25  import org.kuali.rice.krad.uif.element.Label;
26  import org.kuali.rice.krad.uif.field.Field;
27  import org.kuali.rice.krad.uif.field.FieldGroup;
28  import org.kuali.rice.krad.uif.util.ColumnCalculationInfo;
29  import org.kuali.rice.krad.uif.widget.RichTable;
30  
31  /**
32   * Layout manager that works with {@code CollectionGroup} components and renders the collection as a
33   * Table.
34   * 
35   * @author Kuali Rice Team (rice.collab@kuali.org)
36   */
37  public interface TableLayoutManager extends CollectionLayoutManager {
38  
39      /**
40       * Indicates the number of columns that should make up one row of data.
41       *
42       * <p>If the item count is greater than the number of columns, a new row will
43       * be created to render the remaining items (and so on until all items are
44       * placed).</p>
45       *
46       * <p>Note this does not include any generated columns by the layout manager,
47       * so the final column count could be greater (if label fields are
48       * separate).</p>
49       *
50       * @return int number of columns
51       */
52      int getNumberOfColumns();
53  
54      /**
55       * @see TableLayoutManager#getNumberOfColumns()
56       */
57      void setNumberOfColumns(int numberOfColumns);
58  
59      /**
60       * Indicates whether the number of columns for the table data should match
61       * the number of fields given in the container's items list (so that each
62       * field takes up one column without wrapping), this overrides the configured
63       * numberOfColumns.
64       *
65       * <p>If set to true during the initialize phase the number of columns will be
66       * set to the size of the container's field list, if false the configured
67       * number of columns is used</p>
68       *
69       * @return true if the column count should match the container's
70       *         field count, false to use the configured number of columns
71       */
72      boolean isSuppressLineWrapping();
73  
74      /**
75       * @see TableLayoutManager#isSuppressLineWrapping()
76       */
77      void setSuppressLineWrapping(boolean suppressLineWrapping);
78  
79      /**
80       * Indicates whether alternating row styles should be applied.
81       *
82       * <p>Indicator to layout manager templates to apply alternating row styles.
83       * See the configured template for the actual style classes used</p>
84       *
85       * @return true if alternating styles should be applied, false if
86       *         all rows should have the same style
87       */
88      boolean isApplyAlternatingRowStyles();
89  
90      /**
91       * @see TableLayoutManager#isApplyAlternatingRowStyles()
92       */
93      void setApplyAlternatingRowStyles(boolean applyAlternatingRowStyles);
94  
95      /**
96       * Indicates whether the manager should default the cell widths.
97       *
98       * <p>If true, the manager will set the cell width by equally dividing by the
99       * number of columns</p>
100      *
101      * @return true if default cell widths should be applied, false if
102      *         no defaults should be applied
103      */
104     boolean isApplyDefaultCellWidths();
105 
106     /**
107      * @see TableLayoutManager#isApplyDefaultCellWidths()
108      */
109     void setApplyDefaultCellWidths(boolean applyDefaultCellWidths);
110 
111     /**
112      * List of styles for each row.
113      *
114      * <p>Each entry in the list gives the style for the row with the same index. This style will be added to
115      * the <tr> tag when the table rows are rendered in the grid.tag. This is used to store the styles for newly added lines
116      * and other special cases like the add item row.</p>
117      *
118      * @return list of styles for the rows
119      */
120     List<String> getRowCssClasses();
121 
122     /**
123      * @see TableLayoutManager#getRowCssClasses()
124      */
125     void setRowCssClasses(List<String> rowCssClasses);
126 
127     /**
128      * List of data attributes for each row.
129      *
130      * <p>Each entry in the list gives the data attributes for the row with the same index. These data attributes will be added to
131      * the <tr> tag when the table rows are rendered in the grid.tag. This is used to store the data attributes for newly added lines
132      * and other special cases like the add item row.</p>
133      *
134      * @return list of styles for the rows
135      */
136     List<String> getRowDataAttributes();
137 
138     /**
139      * @see TableLayoutManager#getRowDataAttributes()
140      */
141     void setRowDataAttributes(List<String> rowDataAttributes);
142 
143     /**
144      * Indicates whether the short label for the collection field should be used as the table header
145      * or the regular label
146      *
147      * @return true if short label should be used, false if long label should be used
148      */
149     boolean isUseShortLabels();
150 
151     /**
152      * Setter for the use short label indicator
153      *
154      * @param useShortLabels
155      */
156     void setUseShortLabels(boolean useShortLabels);
157 
158     /**
159      * Indicates whether the header should be repeated before each collection row. If false the
160      * header is only rendered at the beginning of the table
161      *
162      * @return true if header should be repeated, false if it should only be rendered once
163      */
164     boolean isRepeatHeader();
165 
166     /**
167      * Setter for the repeat header indicator
168      *
169      * @param repeatHeader
170      */
171     void setRepeatHeader(boolean repeatHeader);
172 
173     /**
174      * {@code Label} instance to use as a prototype for creating the tables header fields. For each
175      * header field the prototype will be copied and adjusted as necessary
176      *
177      * @return Label instance to serve as prototype
178      */
179     Label getHeaderLabelPrototype();
180 
181     /**
182      * Setter for the header field prototype
183      *
184      * @param headerLabelPrototype
185      */
186     void setHeaderLabelPrototype(Label headerLabelPrototype);
187 
188     /**
189      * List of {@code Label} instances that should be rendered to make up the tables header
190      *
191      * @return List of label field instances
192      */
193     List<Label> getHeaderLabels();
194 
195     /**
196      * Indicates whether the sequence field should be rendered for the collection
197      *
198      * @return true if sequence field should be rendered, false if not
199      */
200     boolean isRenderSequenceField();
201 
202     /**
203      * Setter for the render sequence field indicator
204      *
205      * @param renderSequenceField
206      */
207     void setRenderSequenceField(boolean renderSequenceField);
208 
209     /**
210      * Attribute name to use as sequence value. For each collection line the value of this field on
211      * the line will be retrieved and used as the sequence value
212      *
213      * @return sequence property name
214      */
215     String getSequencePropertyName();
216 
217     /**
218      * Setter for the sequence property name
219      *
220      * @param sequencePropertyName
221      */
222     void setSequencePropertyName(String sequencePropertyName);
223 
224     /**
225      * Indicates whether the sequence field should be generated with the current line number
226      *
227      * <p>
228      * If set to true the sequence field prototype will be changed to a message field (if not
229      * already a message field) and the text will be set to the current line number
230      * </p>
231      *
232      * @return true if the sequence field should be generated from the line number, false if not
233      */
234     boolean isGenerateAutoSequence();
235 
236     /**
237      * Setter for the generate auto sequence field
238      *
239      * @param generateAutoSequence
240      */
241     void setGenerateAutoSequence(boolean generateAutoSequence);
242 
243     /**
244      * {@code Field} instance to serve as a prototype for the sequence field. For each collection
245      * line this instance is copied and adjusted as necessary
246      *
247      * @return Attribute field instance
248      */
249     Field getSequenceFieldPrototype();
250 
251     /**
252      * Setter for the sequence field prototype
253      *
254      * @param sequenceFieldPrototype
255      */
256     void setSequenceFieldPrototype(Field sequenceFieldPrototype);
257 
258     /**
259      * {@code FieldGroup} instance to serve as a prototype for the actions column. For each
260      * collection line this instance is copied and adjusted as necessary. Note the actual actions
261      * for the group come from the collection groups actions List
262      * (org.kuali.rice.krad.uif.container.CollectionGroup.getActions()). The FieldGroup prototype is
263      * useful for setting styling of the actions column and for the layout of the action fields.
264      * Note also the label associated with the prototype is used for the action column header
265      *
266      * @return GroupField instance
267      */
268     FieldGroup getActionFieldPrototype();
269 
270     /**
271      * Setter for the action field prototype
272      *
273      * @param actionFieldPrototype
274      */
275     void setActionFieldPrototype(FieldGroup actionFieldPrototype);
276 
277     /**
278      * Indicates whether the add line should be rendered in a separate group, or as part of the
279      * table (first line)
280      *
281      * <p>
282      * When separate add line is enabled, the fields for the add line will be placed in the
283      * {@link #getAddLineGroup()}. This group can be used to configure the add line presentation. In
284      * addition to the fields, the header on the group (unless already set) will be set to
285      * {@link org.kuali.rice.krad.uif.container.CollectionGroup#getAddLabel()} and the add line
286      * actions will be placed into the group's footer.
287      * </p>
288      *
289      * @return true if add line should be separated, false if it should be placed into the table
290      */
291     boolean isSeparateAddLine();
292 
293     /**
294      * Setter for the separate add line indicator
295      *
296      * @param separateAddLine
297      */
298     void setSeparateAddLine(boolean separateAddLine);
299 
300     /**
301      * List of {@link Field} instances that make up all the table's rows of data
302      *
303      * @return table body fields
304      */
305     List<Field> getAllRowFields();
306 
307     /**
308      * List of {@link Field} instances that make us the table's first row of data
309      *
310      * @return list of field instances
311      */
312     List<Field> getFirstRowFields();
313 
314     /**
315      * Widget associated with the table to add functionality such as sorting, paging, and export
316      *
317      * @return RichTable instance
318      */
319     RichTable getRichTable();
320 
321     /**
322      * Setter for the rich table widget
323      *
324      * @param richTable
325      */
326     void setRichTable(RichTable richTable);
327 
328     /**
329      * @return the numberOfDataColumns
330      */
331     int getNumberOfDataColumns();
332 
333     /**
334      * @param numberOfDataColumns the numberOfDataColumns to set
335      */
336     void setNumberOfDataColumns(int numberOfDataColumns);
337 
338     /**
339      * Gets a set of property names defining hidden columns.
340      * 
341      * @return set of property names
342      * @see org.kuali.rice.krad.uif.widget.RichTable#getHiddenColumns()
343      */
344     Set<String> getHiddenColumns();
345 
346     /**
347      * Setter for {@link #getHiddenColumns()}.
348      * 
349      * @param hiddenColumns set of property names
350      */
351     void setHiddenColumns(Set<String> hiddenColumns);
352 
353     /**
354      * Gets a set of property names defining sortable columns.
355      * 
356      * @return set of property names
357      * @see org.kuali.rice.krad.uif.widget.RichTable#getSortableColumns()
358      */
359     Set<String> getSortableColumns();
360 
361     /**
362      * Setterfor {@link #getSortableColumns()}.
363      * 
364      * @param sortableColumns set of property names
365      */
366     void setSortableColumns(Set<String> sortableColumns);
367 
368     /**
369      * Indicates the index of the action column
370      *
371      * @return the action column index
372      */
373     int getActionColumnIndex();
374 
375     /**
376      * Indicates the actions column placement
377      *
378      * <p>
379      * Valid values are 'LEFT', 'RIGHT' or any valid number. The default is 'RIGHT' or '-1'. The
380      * column placement index takes all displayed columns, including sequence and selection columns,
381      * into account.
382      * </p>
383      *
384      * @return the action column placement
385      */
386     String getActionColumnPlacement();
387 
388     /**
389      * Setter for the action column placement
390      *
391      * @param actionColumnPlacement action column placement string
392      */
393     void setActionColumnPlacement(String actionColumnPlacement);
394 
395     /**
396      * The row details info group to use when using a TableLayoutManager with the a richTable.
397      *
398      * <p>
399      * This group will be displayed when the user clicks the "Details" link/image on a row. This
400      * allows extra/long data to be hidden in table rows and then revealed during interaction with
401      * the table without the need to leave the page. Allows for any group content.
402      * </p>
403      *
404      * <p>
405      * Does not currently work with javascript required content.
406      * </p>
407      *
408      * @return rowDetailsGroup component
409      */
410     Group getRowDetailsGroup();
411 
412     /**
413      * Set the row details info group
414      *
415      * @param rowDetailsGroup row details group
416      */
417     void setRowDetailsGroup(Group rowDetailsGroup);
418 
419     /**
420      * A list of all the columns to be calculated
421      *
422      * <p>
423      * The list must contain valid column indexes. The indexes takes all displayed columns into
424      * account.
425      * </p>
426      *
427      * @return the total columns list
428      */
429     List<String> getColumnsToCalculate();
430 
431     /**
432      * Gets showTotal. showTotal shows/calculates the total field when true, otherwise it is not
433      * rendered. <br/>
434      * <b>Only used when renderOnlyLeftTotalLabels is TRUE, this overrides the
435      * ColumnConfigurationInfo setting. Otherwise, the ColumnConfigurationInfo setting takes
436      * precedence.</b>
437      *
438      * @return true if showing the total, false otherwise.
439      */
440     boolean isShowTotal();
441 
442     /**
443      * Sets showTotal. showTotal shows/calculates the total field when true, otherwise it is not
444      * rendered. <br/>
445      * <b>Only used when renderOnlyLeftTotalLabels is TRUE, this overrides the
446      * ColumnConfigurationInfo setting. Otherwise, the ColumnConfigurationInfo setting takes
447      * precedence.</b>
448      *
449      * @param showTotal
450      */
451     void setShowTotal(boolean showTotal);
452 
453     /**
454      * Gets showTotal. showTotal shows/calculates the total field when true, otherwise it is not
455      * rendered. <br/>
456      * <b>Only used when renderOnlyLeftTotalLabels is TRUE, this overrides the
457      * ColumnConfigurationInfo setting. Otherwise, the ColumnConfigurationInfo setting takes
458      * precedence.</b>
459      *
460      * @return true if showing the page total, false otherwise.
461      */
462     boolean isShowPageTotal();
463 
464     /**
465      * Sets showPageTotal. showPageTotal shows/calculates the total field for the page when true
466      * (and only when the table actually has pages), otherwise it is not rendered. <br/>
467      * <b>Only used when renderOnlyLeftTotalLabels is TRUE, this overrides the
468      * ColumnConfigurationInfo setting. Otherwise, the ColumnConfigurationInfo setting takes
469      * precedence.</b>
470      *
471      * @param showPageTotal
472      */
473     void setShowPageTotal(boolean showPageTotal);
474 
475     /**
476      * Gets showGroupTotal. showGroupTotal shows/calculates the total field for each grouping when
477      * true (and only when the table actually has grouping turned on), otherwise it is not rendered. <br/>
478      * <b>Only used when renderOnlyLeftTotalLabels is TRUE, this overrides the
479      * ColumnConfigurationInfo setting. Otherwise, the ColumnConfigurationInfo setting takes
480      * precedence.</b>
481      *
482      * @return true if showing the group total, false otherwise.
483      */
484     boolean isShowGroupTotal();
485 
486     /**
487      * Sets showGroupTotal. showGroupTotal shows/calculates the total field for each grouping when
488      * true (and only when the table actually has grouping turned on), otherwise it is not rendered. <br/>
489      * <b>Only used when renderOnlyLeftTotalLabels is TRUE, this overrides the
490      * ColumnConfigurationInfo setting. Otherwise, the ColumnConfigurationInfo setting takes
491      * precedence.</b>
492      *
493      * @param showGroupTotal
494      */
495     void setShowGroupTotal(boolean showGroupTotal);
496 
497     /**
498      * The total label to use when renderOnlyLeftTotalLabels is TRUE for total. This label will
499      * appear in the left most column.
500      *
501      * @return the totalLabel
502      */
503     Label getTotalLabel();
504 
505     /**
506      * Sets the total label to use when renderOnlyLeftTotalLabels is TRUE for total.
507      *
508      * @param totalLabel
509      */
510     void setTotalLabel(Label totalLabel);
511 
512     /**
513      * The pageTotal label to use when renderOnlyLeftTotalLabels is TRUE for total. This label will
514      * appear in the left most column.
515      *
516      * @return the totalLabel
517      */
518     Label getPageTotalLabel();
519 
520     /**
521      * Sets the pageTotal label to use when renderOnlyLeftTotalLabels is TRUE for total.
522      *
523      * @param pageTotalLabel
524      */
525     void setPageTotalLabel(Label pageTotalLabel);
526 
527     /**
528      * The groupTotal label to use when renderOnlyLeftTotalLabels is TRUE. This label will appear in
529      * the left most column.
530      *
531      * @return the totalLabel
532      */
533     Label getGroupTotalLabelPrototype();
534 
535     /**
536      * Sets the groupTotal label to use when renderOnlyLeftTotalLabels is TRUE.
537      *
538      * @param groupTotalLabelPrototype
539      */
540     void setGroupTotalLabelPrototype(Label groupTotalLabelPrototype);
541 
542     /**
543      * Gets the column calculations. This is a list of ColumnCalcuationInfo that when set provides
544      * calculations to be performed on the columns they specify. These calculations appear in the
545      * table's footer. This feature is only available when using richTable functionality.
546      *
547      * @return the columnCalculations to use
548      */
549     List<ColumnCalculationInfo> getColumnCalculations();
550 
551     /**
552      * Sets the columnCalculations.
553      *
554      * @param columnCalculations
555      */
556     void setColumnCalculations(List<ColumnCalculationInfo> columnCalculations);
557 
558     /**
559      * When true, labels for the totals fields will only appear in the left most column. Showing of
560      * the totals is controlled by the settings on the TableLayoutManager itself when this property
561      * is true.
562      *
563      * @return true when rendering totals footer labels in the left-most column, false otherwise
564      */
565     boolean isRenderOnlyLeftTotalLabels();
566 
567     /**
568      * Set the renderOnlyLeftTotalLabels flag for rendring total labels in the left-most column
569      *
570      * @param renderOnlyLeftTotalLabels
571      */
572     void setRenderOnlyLeftTotalLabels(boolean renderOnlyLeftTotalLabels);
573 
574     /**
575      * Gets the footer calculation components to be used by the layout. These are set by the
576      * framework and cannot be set directly.
577      *
578      * @return the list of components for the footer
579      */
580     List<Component> getFooterCalculationComponents();
581 
582     /**
583      * Gets the list of property names to use for grouping.
584      *
585      * <p>
586      * When this property is set, grouping for this collection will be enabled and the lines of the
587      * collection will be grouped by the propertyName(s) supplied. Supplying multiple property names
588      * will cause the grouping to be on multiple fields and ordered alphabetically on
589      * "propetyValue1, propertyValue2" (this is also how the group title will display for each
590      * group). The property names supplied must be relative to the line, so #lp SHOULD NOT be used
591      * (it is assumed automatically).
592      * </p>
593      *
594      * @return propertyNames to group on
595      */
596     List<String> getGroupingPropertyNames();
597 
598     /**
599      * Sets the list of property names to use for grouping.
600      *
601      * @param groupingPropertyNames
602      */
603     void setGroupingPropertyNames(List<String> groupingPropertyNames);
604 
605     /**
606      * Get the groupingTitle. The groupingTitle MUST contain a SpringEL expression to uniquely
607      * identify a group's line (ie it cannot be a static string because each group must be
608      * identified by some value). <b>This overrides groupingPropertyNames(if set) because it
609      * provides full control of grouping value used by the collection. SpringEL defined here must
610      * use #lp if referencing values of the line.</b>
611      *
612      * @return groupingTitle to be used
613      */
614     String getGroupingTitle();
615 
616     /**
617      * Set the groupingTitle. This will throw an exception if the title does not contain a SpringEL
618      * expression.
619      *
620      * @param groupingTitle
621      */
622     void setGroupingTitle(String groupingTitle);
623 
624     /**
625      * Get the groupingPrefix. The groupingPrefix is used to prefix the generated title (not used
626      * when groupingTitle is set directly) when using groupingPropertyNames.
627      *
628      * @return String
629      */
630     String getGroupingPrefix();
631 
632     /**
633      * Set the groupingPrefix. This is not used when groupingTitle is set directly.
634      *
635      * @param groupingPrefix
636      */
637     void setGroupingPrefix(String groupingPrefix);
638 
639     /**
640      * If true, all details will be opened by default when the table loads. Can only be used on
641      * tables that have row details setup.
642      *
643      * @return true if row details
644      */
645     boolean isRowDetailsOpen();
646 
647     /**
648      * Set if row details should be open on table load
649      *
650      * @param rowDetailsOpen
651      */
652     void setRowDetailsOpen(boolean rowDetailsOpen);
653 
654     /**
655      * If true, the toggleAllDetailsAction will be shown. This button allows all details to be
656      * open/closed simultaneously.
657      *
658      * @return true if the action button to toggle all row details opened/closed
659      */
660     boolean isShowToggleAllDetails();
661 
662     /**
663      * Set if the toggleAllDetailsAction should be shown
664      *
665      * @param showToggleAllDetails
666      */
667     void setShowToggleAllDetails(boolean showToggleAllDetails);
668 
669     /**
670      * The toggleAllDetailsAction action component used to toggle all row details open/closed. This
671      * property is set by the default configuration and should not be reset in most cases.
672      *
673      * @return Action component to use for the toggle action button
674      */
675     Action getToggleAllDetailsAction();
676 
677     /**
678      * Set the toggleAllDetailsAction action component used to toggle all row details open/closed.
679      * This property is set by the default configuration and should not be reset in most cases.
680      *
681      * @param toggleAllDetailsAction
682      */
683     void setToggleAllDetailsAction(Action toggleAllDetailsAction);
684 
685     /**
686      * If true, when a row details open action is performed, it will get the details content from
687      * the server the first time it is opened. The methodToCall will be a component "refresh" call
688      * by default (this can be set on expandDetailsActionPrototype) and the additional action
689      * parameters sent to the server will be those set on the expandDetailsActionPrototype
690      * (lineIndex will be sent by default).
691      *
692      * @return true if ajax row details retrieval will be used
693      */
694     boolean isAjaxDetailsRetrieval();
695 
696     /**
697      * Set if row details content should be retrieved fromt he server
698      *
699      * @param ajaxDetailsRetrieval
700      */
701     void setAjaxDetailsRetrieval(boolean ajaxDetailsRetrieval);
702 
703     /**
704      * The Action prototype used for the row details expand link. Should be set to
705      * "Uif-ExpandDetailsAction" or "Uif-ExpandDetailsImageAction". Properties can be configured to
706      * allow for different methodToCall and actionParameters to be set for ajax row details
707      * retrieval.
708      *
709      * @return the Action details link prototype
710      */
711     Action getExpandDetailsActionPrototype();
712 
713     /**
714      * Gets the grouping column index
715      *
716      * @return the grouping column index
717      */
718     int getGroupingColumnIndex();
719 
720     /**
721      * Set the expand details Action prototype link
722      *
723      * @param expandDetailsActionPrototype
724      */
725     void setExpandDetailsActionPrototype(Action expandDetailsActionPrototype);
726 
727     /**
728      * The row css classes for the rows of this layout
729      *
730      * <p>
731      * To set a css class on all rows, use "all" as a key. To set a class for even rows, use "even"
732      * as a key, for odd rows, use "odd". Use a one-based index to target a specific row by index.
733      * SpringEL can be used as a key and the expression will be evaluated; if evaluated to true, the
734      * class(es) specified will be applied.
735      * </p>
736      *
737      * @return a map which represents the css classes of the rows of this layout
738      */
739     Map<String, String> getConditionalRowCssClasses();
740 
741     /**
742      * Set the conditionalRowCssClasses
743      *
744      * @param conditionalRowCssClasses
745      */
746     void setConditionalRowCssClasses(Map<String, String> conditionalRowCssClasses);
747 
748     /**
749      * Gets a list of column calculation components.
750      * 
751      * @return list of column calculation components
752      */
753    List<Component> getColumnCalculationComponents();
754 
755 }