| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| CollectionGroup |
|
| 1.4423076923076923;1.442 |
| 1 | /** | |
| 2 | * Copyright 2005-2011 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 java.util.ArrayList; | |
| 19 | import java.util.List; | |
| 20 | ||
| 21 | import org.apache.commons.lang.StringUtils; | |
| 22 | import org.kuali.rice.krad.uif.UifConstants; | |
| 23 | import org.kuali.rice.krad.uif.UifParameters; | |
| 24 | import org.kuali.rice.krad.uif.component.BindingInfo; | |
| 25 | import org.kuali.rice.krad.uif.component.Component; | |
| 26 | import org.kuali.rice.krad.uif.component.DataBinding; | |
| 27 | import org.kuali.rice.krad.uif.field.ActionField; | |
| 28 | import org.kuali.rice.krad.uif.field.DataField; | |
| 29 | import org.kuali.rice.krad.uif.field.InputField; | |
| 30 | import org.kuali.rice.krad.uif.field.Field; | |
| 31 | import org.kuali.rice.krad.uif.field.LabelField; | |
| 32 | import org.kuali.rice.krad.uif.util.ComponentUtils; | |
| 33 | import org.kuali.rice.krad.uif.view.View; | |
| 34 | import org.kuali.rice.krad.uif.widget.QuickFinder; | |
| 35 | ||
| 36 | /** | |
| 37 | * Group that holds a collection of objects and configuration for presenting the | |
| 38 | * collection in the UI. Supports functionality such as add line, line actions, | |
| 39 | * and nested collections. | |
| 40 | * | |
| 41 | * <p> | |
| 42 | * Note the standard header/footer can be used to give a header to the | |
| 43 | * collection as a whole, or to provide actions that apply to the entire | |
| 44 | * collection | |
| 45 | * </p> | |
| 46 | * | |
| 47 | * <p> | |
| 48 | * For binding purposes the binding path of each row field is indexed. The name | |
| 49 | * property inherited from <code>ComponentBase</code> is used as the collection | |
| 50 | * name. The collectionObjectClass property is used to lookup attributes from | |
| 51 | * the data dictionary. | |
| 52 | * </p> | |
| 53 | * | |
| 54 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 55 | */ | |
| 56 | public class CollectionGroup extends Group implements DataBinding { | |
| 57 | private static final long serialVersionUID = -6496712566071542452L; | |
| 58 | ||
| 59 | private Class<?> collectionObjectClass; | |
| 60 | ||
| 61 | private String propertyName; | |
| 62 | private BindingInfo bindingInfo; | |
| 63 | ||
| 64 | private boolean renderAddLine; | |
| 65 | private String addLinePropertyName; | |
| 66 | private BindingInfo addLineBindingInfo; | |
| 67 | private LabelField addLineLabelField; | |
| 68 | private List<? extends Field> addLineFields; | |
| 69 | private List<ActionField> addLineActionFields; | |
| 70 | ||
| 71 | private boolean renderLineActions; | |
| 72 | private List<ActionField> actionFields; | |
| 73 | ||
| 74 | private boolean renderSelectField; | |
| 75 | private String selectPropertyName; | |
| 76 | ||
| 77 | private QuickFinder collectionLookup; | |
| 78 | ||
| 79 | private boolean showHideInactiveButton; | |
| 80 | private boolean showInactive; | |
| 81 | private CollectionFilter activeCollectionFilter; | |
| 82 | private List<CollectionFilter> filters; | |
| 83 | ||
| 84 | private List<CollectionGroup> subCollections; | |
| 85 | private String subCollectionSuffix; | |
| 86 | ||
| 87 | private CollectionGroupBuilder collectionGroupBuilder; | |
| 88 | ||
| 89 | 0 | public CollectionGroup() { |
| 90 | 0 | renderAddLine = true; |
| 91 | 0 | renderLineActions = true; |
| 92 | 0 | showInactive = false; |
| 93 | 0 | showHideInactiveButton = true; |
| 94 | 0 | renderSelectField = false; |
| 95 | ||
| 96 | 0 | filters = new ArrayList<CollectionFilter>(); |
| 97 | 0 | actionFields = new ArrayList<ActionField>(); |
| 98 | 0 | addLineFields = new ArrayList<Field>(); |
| 99 | 0 | addLineActionFields = new ArrayList<ActionField>(); |
| 100 | 0 | subCollections = new ArrayList<CollectionGroup>(); |
| 101 | 0 | } |
| 102 | ||
| 103 | /** | |
| 104 | * The following actions are performed: | |
| 105 | * | |
| 106 | * <ul> | |
| 107 | * <li>Set fieldBindModelPath to the collection model path (since the fields | |
| 108 | * have to belong to the same model as the collection)</li> | |
| 109 | * <li>Set defaults for binding</li> | |
| 110 | * <li>Default add line field list to groups items list</li> | |
| 111 | * <li>Sets default active collection filter if not set</li> | |
| 112 | * <li>Sets the dictionary entry (if blank) on each of the items to the | |
| 113 | * collection class</li> | |
| 114 | * </ul> | |
| 115 | * | |
| 116 | * @see org.kuali.rice.krad.uif.component.ComponentBase#performInitialization(org.kuali.rice.krad.uif.view.View, | |
| 117 | * java.lang.Object) | |
| 118 | */ | |
| 119 | @Override | |
| 120 | public void performInitialization(View view, Object model) { | |
| 121 | 0 | setFieldBindingObjectPath(getBindingInfo().getBindingObjectPath()); |
| 122 | ||
| 123 | 0 | super.performInitialization(view, model); |
| 124 | ||
| 125 | 0 | if (bindingInfo != null) { |
| 126 | 0 | bindingInfo.setDefaults(view, getPropertyName()); |
| 127 | } | |
| 128 | ||
| 129 | 0 | if (addLineBindingInfo != null) { |
| 130 | // add line binds to model property | |
| 131 | 0 | if (StringUtils.isNotBlank(addLinePropertyName)) { |
| 132 | 0 | addLineBindingInfo.setDefaults(view, getPropertyName()); |
| 133 | 0 | addLineBindingInfo.setBindingName(addLinePropertyName); |
| 134 | 0 | if (StringUtils.isNotBlank(getFieldBindByNamePrefix())) { |
| 135 | 0 | addLineBindingInfo.setBindByNamePrefix(getFieldBindByNamePrefix()); |
| 136 | } | |
| 137 | } | |
| 138 | } | |
| 139 | ||
| 140 | 0 | for (Component item : getItems()) { |
| 141 | 0 | if (item instanceof DataField) { |
| 142 | 0 | DataField field = (DataField) item; |
| 143 | ||
| 144 | 0 | if (StringUtils.isBlank(field.getDictionaryObjectEntry())) { |
| 145 | 0 | field.setDictionaryObjectEntry(collectionObjectClass.getName()); |
| 146 | } | |
| 147 | 0 | } |
| 148 | } | |
| 149 | ||
| 150 | 0 | if ((addLineFields == null) || addLineFields.isEmpty()) { |
| 151 | 0 | addLineFields = getItems(); |
| 152 | } | |
| 153 | ||
| 154 | // if active collection filter not set use default | |
| 155 | 0 | if (this.activeCollectionFilter == null) { |
| 156 | 0 | activeCollectionFilter = new ActiveCollectionFilter(); |
| 157 | } | |
| 158 | ||
| 159 | // set static collection path on items | |
| 160 | 0 | String collectionPath = ""; |
| 161 | 0 | if (StringUtils.isNotBlank(getBindingInfo().getCollectionPath())) { |
| 162 | 0 | collectionPath += getBindingInfo().getCollectionPath() + "."; |
| 163 | } | |
| 164 | 0 | if (StringUtils.isNotBlank(getBindingInfo().getBindByNamePrefix())) { |
| 165 | 0 | collectionPath += getBindingInfo().getBindByNamePrefix() + "."; |
| 166 | } | |
| 167 | 0 | collectionPath += getBindingInfo().getBindingName(); |
| 168 | ||
| 169 | 0 | List<DataField> collectionFields = ComponentUtils.getComponentsOfTypeDeep(getItems(), DataField.class); |
| 170 | 0 | for (DataField collectionField : collectionFields) { |
| 171 | 0 | collectionField.getBindingInfo().setCollectionPath(collectionPath); |
| 172 | } | |
| 173 | ||
| 174 | // add collection entry to abstract classes | |
| 175 | 0 | if (!view.getAbstractTypeClasses().containsKey(collectionPath)) { |
| 176 | 0 | view.getAbstractTypeClasses().put(collectionPath, getCollectionObjectClass()); |
| 177 | } | |
| 178 | ||
| 179 | // initialize container items and sub-collections (since they are not in | |
| 180 | // child list) | |
| 181 | 0 | for (Component item : getItems()) { |
| 182 | 0 | view.getViewHelperService().performComponentInitialization(view, model, item); |
| 183 | } | |
| 184 | ||
| 185 | 0 | for (CollectionGroup collectionGroup : getSubCollections()) { |
| 186 | 0 | collectionGroup.getBindingInfo().setCollectionPath(collectionPath); |
| 187 | 0 | view.getViewHelperService().performComponentInitialization(view, model, collectionGroup); |
| 188 | } | |
| 189 | 0 | } |
| 190 | ||
| 191 | /** | |
| 192 | * Calls the configured <code>CollectionGroupBuilder</code> to build the | |
| 193 | * necessary components based on the collection data | |
| 194 | * | |
| 195 | * @see org.kuali.rice.krad.uif.container.ContainerBase#performApplyModel(org.kuali.rice.krad.uif.view.View, | |
| 196 | * java.lang.Object, org.kuali.rice.krad.uif.component.Component) | |
| 197 | */ | |
| 198 | @Override | |
| 199 | public void performApplyModel(View view, Object model, Component parent) { | |
| 200 | 0 | super.performApplyModel(view, model, parent); |
| 201 | ||
| 202 | 0 | pushCollectionGroupToReference(); |
| 203 | ||
| 204 | 0 | getCollectionGroupBuilder().build(view, model, this); |
| 205 | ||
| 206 | // TODO: is this necessary to call again? | |
| 207 | 0 | pushCollectionGroupToReference(); |
| 208 | 0 | } |
| 209 | ||
| 210 | /** | |
| 211 | * Sets a reference in the context map for all nested components to the collection group | |
| 212 | * instance, and sets name as parameter for an action fields in the group | |
| 213 | */ | |
| 214 | protected void pushCollectionGroupToReference() { | |
| 215 | 0 | List<Component> components = this.getComponentsForLifecycle(); |
| 216 | ||
| 217 | 0 | ComponentUtils.pushObjectToContext(components, UifConstants.ContextVariableNames.COLLECTION_GROUP, this); |
| 218 | ||
| 219 | 0 | List<ActionField> actionFields = ComponentUtils.getComponentsOfTypeDeep(components, ActionField.class); |
| 220 | 0 | for (ActionField actionField : actionFields) { |
| 221 | 0 | actionField.addActionParameter(UifParameters.SELLECTED_COLLECTION_PATH, |
| 222 | this.getBindingInfo().getBindingPath()); | |
| 223 | } | |
| 224 | 0 | } |
| 225 | ||
| 226 | /** | |
| 227 | * New collection lines are handled in the framework by maintaining a map on | |
| 228 | * the form. The map contains as a key the collection name, and as value an | |
| 229 | * instance of the collection type. An entry is created here for the | |
| 230 | * collection represented by the <code>CollectionGroup</code> if an instance | |
| 231 | * is not available (clearExistingLine will force a new instance). The given | |
| 232 | * model must be a subclass of <code>UifFormBase</code> in order to find the | |
| 233 | * Map. | |
| 234 | * | |
| 235 | * @param model - Model instance that contains the new collection lines Map | |
| 236 | * @param clearExistingLine - boolean that indicates whether the line should be set to a | |
| 237 | * new instance if it already exists | |
| 238 | */ | |
| 239 | public void initializeNewCollectionLine(View view, Object model, CollectionGroup collectionGroup, | |
| 240 | boolean clearExistingLine) { | |
| 241 | 0 | getCollectionGroupBuilder().initializeNewCollectionLine(view, model, collectionGroup, clearExistingLine); |
| 242 | 0 | } |
| 243 | ||
| 244 | /** | |
| 245 | * @see org.kuali.rice.krad.uif.container.ContainerBase#getComponentsForLifecycle() | |
| 246 | */ | |
| 247 | @Override | |
| 248 | public List<Component> getComponentsForLifecycle() { | |
| 249 | 0 | List<Component> components = super.getComponentsForLifecycle(); |
| 250 | ||
| 251 | 0 | components.add(addLineLabelField); |
| 252 | 0 | components.addAll(actionFields); |
| 253 | 0 | components.addAll(addLineActionFields); |
| 254 | 0 | components.add(collectionLookup); |
| 255 | ||
| 256 | // remove the containers items because we don't want them as children | |
| 257 | // (they will become children of the layout manager as the rows are | |
| 258 | // created) | |
| 259 | 0 | for (Component item : getItems()) { |
| 260 | 0 | if (components.contains(item)) { |
| 261 | 0 | components.remove(item); |
| 262 | } | |
| 263 | } | |
| 264 | ||
| 265 | 0 | return components; |
| 266 | } | |
| 267 | ||
| 268 | /** | |
| 269 | * @see org.kuali.rice.krad.uif.component.Component#getComponentPrototypes() | |
| 270 | */ | |
| 271 | @Override | |
| 272 | public List<Component> getComponentPrototypes() { | |
| 273 | 0 | List<Component> components = super.getComponentPrototypes(); |
| 274 | ||
| 275 | 0 | components.addAll(getItems()); |
| 276 | 0 | components.addAll(getSubCollections()); |
| 277 | ||
| 278 | 0 | return components; |
| 279 | } | |
| 280 | ||
| 281 | /** | |
| 282 | * Object class the collection maintains. Used to get dictionary information | |
| 283 | * in addition to creating new instances for the collection when necessary | |
| 284 | * | |
| 285 | * @return Class<?> collection object class | |
| 286 | */ | |
| 287 | public Class<?> getCollectionObjectClass() { | |
| 288 | 0 | return this.collectionObjectClass; |
| 289 | } | |
| 290 | ||
| 291 | /** | |
| 292 | * Setter for the collection object class | |
| 293 | * | |
| 294 | * @param collectionObjectClass | |
| 295 | */ | |
| 296 | public void setCollectionObjectClass(Class<?> collectionObjectClass) { | |
| 297 | 0 | this.collectionObjectClass = collectionObjectClass; |
| 298 | 0 | } |
| 299 | ||
| 300 | /** | |
| 301 | * @see org.kuali.rice.krad.uif.component.DataBinding#getPropertyName() | |
| 302 | */ | |
| 303 | public String getPropertyName() { | |
| 304 | 0 | return this.propertyName; |
| 305 | } | |
| 306 | ||
| 307 | /** | |
| 308 | * Setter for the collections property name | |
| 309 | * | |
| 310 | * @param propertyName | |
| 311 | */ | |
| 312 | public void setPropertyName(String propertyName) { | |
| 313 | 0 | this.propertyName = propertyName; |
| 314 | 0 | } |
| 315 | ||
| 316 | /** | |
| 317 | * Determines the binding path for the collection. Used to get the | |
| 318 | * collection value from the model in addition to setting the binding path | |
| 319 | * for the collection attributes | |
| 320 | * | |
| 321 | * @see org.kuali.rice.krad.uif.component.DataBinding#getBindingInfo() | |
| 322 | */ | |
| 323 | public BindingInfo getBindingInfo() { | |
| 324 | 0 | return this.bindingInfo; |
| 325 | } | |
| 326 | ||
| 327 | /** | |
| 328 | * Setter for the binding info instance | |
| 329 | * | |
| 330 | * @param bindingInfo | |
| 331 | */ | |
| 332 | public void setBindingInfo(BindingInfo bindingInfo) { | |
| 333 | 0 | this.bindingInfo = bindingInfo; |
| 334 | 0 | } |
| 335 | ||
| 336 | /** | |
| 337 | * Action fields that should be rendered for each collection line. Example | |
| 338 | * line action is the delete action | |
| 339 | * | |
| 340 | * @return List<ActionField> line action fields | |
| 341 | */ | |
| 342 | public List<ActionField> getActionFields() { | |
| 343 | 0 | return this.actionFields; |
| 344 | } | |
| 345 | ||
| 346 | /** | |
| 347 | * Setter for the line action fields list | |
| 348 | * | |
| 349 | * @param actionFields | |
| 350 | */ | |
| 351 | public void setActionFields(List<ActionField> actionFields) { | |
| 352 | 0 | this.actionFields = actionFields; |
| 353 | 0 | } |
| 354 | ||
| 355 | /** | |
| 356 | * Indicates whether the action column for the collection should be rendered | |
| 357 | * | |
| 358 | * @return boolean true if the actions should be rendered, false if not | |
| 359 | * @see #getActionFields() | |
| 360 | */ | |
| 361 | public boolean isRenderLineActions() { | |
| 362 | 0 | return this.renderLineActions; |
| 363 | } | |
| 364 | ||
| 365 | /** | |
| 366 | * Setter for the render line actions indicator | |
| 367 | * | |
| 368 | * @param renderLineActions | |
| 369 | */ | |
| 370 | public void setRenderLineActions(boolean renderLineActions) { | |
| 371 | 0 | this.renderLineActions = renderLineActions; |
| 372 | 0 | } |
| 373 | ||
| 374 | /** | |
| 375 | * Indicates whether an add line should be rendered for the collection | |
| 376 | * | |
| 377 | * @return boolean true if add line should be rendered, false if it should | |
| 378 | * not be | |
| 379 | */ | |
| 380 | public boolean isRenderAddLine() { | |
| 381 | 0 | return this.renderAddLine; |
| 382 | } | |
| 383 | ||
| 384 | /** | |
| 385 | * Setter for the render add line indicator | |
| 386 | * | |
| 387 | * @param renderAddLine | |
| 388 | */ | |
| 389 | public void setRenderAddLine(boolean renderAddLine) { | |
| 390 | 0 | this.renderAddLine = renderAddLine; |
| 391 | 0 | } |
| 392 | ||
| 393 | /** | |
| 394 | * Convenience getter for the add line label field text. The text is used to | |
| 395 | * label the add line when rendered and its placement depends on the | |
| 396 | * <code>LayoutManager</code>. | |
| 397 | * <p> | |
| 398 | * For the <code>TableLayoutManager</code> the label appears in the sequence | |
| 399 | * column to the left of the add line fields. For the | |
| 400 | * <code>StackedLayoutManager</code> the label is placed into the group | |
| 401 | * header for the line. | |
| 402 | * </p> | |
| 403 | * | |
| 404 | * @return String add line label | |
| 405 | */ | |
| 406 | public String getAddLineLabel() { | |
| 407 | 0 | if (getAddLineLabelField() != null) { |
| 408 | 0 | return getAddLineLabelField().getLabelText(); |
| 409 | } | |
| 410 | ||
| 411 | 0 | return null; |
| 412 | } | |
| 413 | ||
| 414 | /** | |
| 415 | * Setter for the add line label text | |
| 416 | * | |
| 417 | * @param addLineLabel | |
| 418 | */ | |
| 419 | public void setAddLineLabel(String addLineLabel) { | |
| 420 | 0 | if (getAddLineLabelField() != null) { |
| 421 | 0 | getAddLineLabelField().setLabelText(addLineLabel); |
| 422 | } | |
| 423 | 0 | } |
| 424 | ||
| 425 | /** | |
| 426 | * <code>LabelField</code> instance for the add line label | |
| 427 | * | |
| 428 | * @return LabelField add line label field | |
| 429 | * @see #getAddLineLabel() | |
| 430 | */ | |
| 431 | public LabelField getAddLineLabelField() { | |
| 432 | 0 | return this.addLineLabelField; |
| 433 | } | |
| 434 | ||
| 435 | /** | |
| 436 | * Setter for the <code>LabelField</code> instance for the add line label | |
| 437 | * | |
| 438 | * @param addLineLabelField | |
| 439 | * @see #getAddLineLabel() | |
| 440 | */ | |
| 441 | public void setAddLineLabelField(LabelField addLineLabelField) { | |
| 442 | 0 | this.addLineLabelField = addLineLabelField; |
| 443 | 0 | } |
| 444 | ||
| 445 | /** | |
| 446 | * Name of the property that contains an instance for the add line. If set | |
| 447 | * this is used with the binding info to create the path to the add line. | |
| 448 | * Can be left blank in which case the framework will manage the add line | |
| 449 | * instance in a generic map. | |
| 450 | * | |
| 451 | * @return String add line property name | |
| 452 | */ | |
| 453 | public String getAddLinePropertyName() { | |
| 454 | 0 | return this.addLinePropertyName; |
| 455 | } | |
| 456 | ||
| 457 | /** | |
| 458 | * Setter for the add line property name | |
| 459 | * | |
| 460 | * @param addLinePropertyName | |
| 461 | */ | |
| 462 | public void setAddLinePropertyName(String addLinePropertyName) { | |
| 463 | 0 | this.addLinePropertyName = addLinePropertyName; |
| 464 | 0 | } |
| 465 | ||
| 466 | /** | |
| 467 | * <code>BindingInfo</code> instance for the add line property used to | |
| 468 | * determine the full binding path. If add line name given | |
| 469 | * {@link #getAddLineLabel()} then it is set as the binding name on the | |
| 470 | * binding info. Add line label and binding info are not required, in which | |
| 471 | * case the framework will manage the new add line instances through a | |
| 472 | * generic map (model must extend UifFormBase) | |
| 473 | * | |
| 474 | * @return BindingInfo add line binding info | |
| 475 | */ | |
| 476 | public BindingInfo getAddLineBindingInfo() { | |
| 477 | 0 | return this.addLineBindingInfo; |
| 478 | } | |
| 479 | ||
| 480 | /** | |
| 481 | * Setter for the add line binding info | |
| 482 | * | |
| 483 | * @param addLineBindingInfo | |
| 484 | */ | |
| 485 | public void setAddLineBindingInfo(BindingInfo addLineBindingInfo) { | |
| 486 | 0 | this.addLineBindingInfo = addLineBindingInfo; |
| 487 | 0 | } |
| 488 | ||
| 489 | /** | |
| 490 | * List of <code>Field</code> instances that should be rendered for the | |
| 491 | * collection add line (if enabled). If not set, the default group's items | |
| 492 | * list will be used | |
| 493 | * | |
| 494 | * @return List<? extends Field> add line field list | |
| 495 | */ | |
| 496 | public List<? extends Field> getAddLineFields() { | |
| 497 | 0 | return this.addLineFields; |
| 498 | } | |
| 499 | ||
| 500 | /** | |
| 501 | * Setter for the add line field list | |
| 502 | * | |
| 503 | * @param addLineFields | |
| 504 | */ | |
| 505 | public void setAddLineFields(List<? extends Field> addLineFields) { | |
| 506 | 0 | this.addLineFields = addLineFields; |
| 507 | 0 | } |
| 508 | ||
| 509 | /** | |
| 510 | * Action fields that should be rendered for the add line. This is generally | |
| 511 | * the add action (button) but can be configured to contain additional | |
| 512 | * actions | |
| 513 | * | |
| 514 | * @return List<ActionField> add line action fields | |
| 515 | */ | |
| 516 | public List<ActionField> getAddLineActionFields() { | |
| 517 | 0 | return this.addLineActionFields; |
| 518 | } | |
| 519 | ||
| 520 | /** | |
| 521 | * Setter for the add line action fields | |
| 522 | * | |
| 523 | * @param addLineActionFields | |
| 524 | */ | |
| 525 | public void setAddLineActionFields(List<ActionField> addLineActionFields) { | |
| 526 | 0 | this.addLineActionFields = addLineActionFields; |
| 527 | 0 | } |
| 528 | ||
| 529 | /** | |
| 530 | * Indicates whether lines of the collection group should be selected by rendering a | |
| 531 | * field for each line that will allow selection | |
| 532 | * | |
| 533 | * <p> | |
| 534 | * For example, having the select field enabled could allow selecting multiple lines from a search | |
| 535 | * to return (multi-value lookup) | |
| 536 | * </p> | |
| 537 | * | |
| 538 | * @return boolean true if select field should be rendered, false if not | |
| 539 | */ | |
| 540 | public boolean isRenderSelectField() { | |
| 541 | 0 | return renderSelectField; |
| 542 | } | |
| 543 | ||
| 544 | /** | |
| 545 | * Setter for the render selected field indicator | |
| 546 | * | |
| 547 | * @param renderSelectField | |
| 548 | */ | |
| 549 | public void setRenderSelectField(boolean renderSelectField) { | |
| 550 | 0 | this.renderSelectField = renderSelectField; |
| 551 | 0 | } |
| 552 | ||
| 553 | /** | |
| 554 | * When {@link #isRenderSelectField()} is true, gives the name of the property the select field | |
| 555 | * should bind to | |
| 556 | * | |
| 557 | * <p> | |
| 558 | * Note if no prefix is given in the property name, such as 'form.', it is assumed the property is | |
| 559 | * contained on the collection line. In this case the binding path to the collection line will be | |
| 560 | * appended. In other cases, it is assumed the property is a list or set of String that will hold the | |
| 561 | * selected identifier strings | |
| 562 | * </p> | |
| 563 | * | |
| 564 | * <p> | |
| 565 | * This property is not required. If not the set the framework will use a property contained on | |
| 566 | * <code>UifFormBase</code> | |
| 567 | * </p> | |
| 568 | * | |
| 569 | * @return String property name for select field | |
| 570 | */ | |
| 571 | public String getSelectPropertyName() { | |
| 572 | 0 | return selectPropertyName; |
| 573 | } | |
| 574 | ||
| 575 | /** | |
| 576 | * Setter for the property name that will bind to the select field | |
| 577 | * | |
| 578 | * @param selectPropertyName | |
| 579 | */ | |
| 580 | public void setSelectPropertyName(String selectPropertyName) { | |
| 581 | 0 | this.selectPropertyName = selectPropertyName; |
| 582 | 0 | } |
| 583 | ||
| 584 | /** | |
| 585 | * Instance of the <code>QuickFinder</code> widget that configures a multi-value lookup for the collection | |
| 586 | * | |
| 587 | * <p> | |
| 588 | * If the collection lookup is enabled (by the render property of the quick finder), {@link | |
| 589 | * #getCollectionObjectClass()} will be used as the data object class for the lookup (if not set). Field | |
| 590 | * conversions need to be set as usual and will be applied for each line returned | |
| 591 | * </p> | |
| 592 | * | |
| 593 | * @return QuickFinder instance configured for the collection lookup | |
| 594 | */ | |
| 595 | public QuickFinder getCollectionLookup() { | |
| 596 | 0 | return collectionLookup; |
| 597 | } | |
| 598 | ||
| 599 | /** | |
| 600 | * Setter for the collection lookup quickfinder instance | |
| 601 | * | |
| 602 | * @param collectionLookup | |
| 603 | */ | |
| 604 | public void setCollectionLookup(QuickFinder collectionLookup) { | |
| 605 | 0 | this.collectionLookup = collectionLookup; |
| 606 | 0 | } |
| 607 | ||
| 608 | /** | |
| 609 | * Indicates whether inactive collections lines should be displayed | |
| 610 | * | |
| 611 | * <p> | |
| 612 | * Setting only applies when the collection line type implements the | |
| 613 | * <code>Inactivatable</code> interface. If true and showInactive is | |
| 614 | * set to false, the collection will be filtered to remove any items | |
| 615 | * whose active status returns false | |
| 616 | * </p> | |
| 617 | * | |
| 618 | * @return boolean true to show inactive records, false to not render inactive records | |
| 619 | */ | |
| 620 | public boolean isShowInactive() { | |
| 621 | 0 | return showInactive; |
| 622 | } | |
| 623 | ||
| 624 | /** | |
| 625 | * Setter for the show inactive indicator | |
| 626 | * | |
| 627 | * @param showInactive boolean show inactive | |
| 628 | */ | |
| 629 | public void setShowInactive(boolean showInactive) { | |
| 630 | 0 | this.showInactive = showInactive; |
| 631 | 0 | } |
| 632 | ||
| 633 | /** | |
| 634 | * Collection filter instance for filtering the collection data when the | |
| 635 | * showInactive flag is set to false | |
| 636 | * | |
| 637 | * @return CollectionFilter | |
| 638 | */ | |
| 639 | public CollectionFilter getActiveCollectionFilter() { | |
| 640 | 0 | return activeCollectionFilter; |
| 641 | } | |
| 642 | ||
| 643 | /** | |
| 644 | * Setter for the collection filter to use for filter inactive records from the | |
| 645 | * collection | |
| 646 | * | |
| 647 | * @param activeCollectionFilter - CollectionFilter instance | |
| 648 | */ | |
| 649 | public void setActiveCollectionFilter(CollectionFilter activeCollectionFilter) { | |
| 650 | 0 | this.activeCollectionFilter = activeCollectionFilter; |
| 651 | 0 | } |
| 652 | ||
| 653 | /** | |
| 654 | * List of {@link CollectionFilter} instances that should be invoked to filter the collection before | |
| 655 | * displaying | |
| 656 | * | |
| 657 | * @return List<CollectionFilter> | |
| 658 | */ | |
| 659 | public List<CollectionFilter> getFilters() { | |
| 660 | 0 | return filters; |
| 661 | } | |
| 662 | ||
| 663 | /** | |
| 664 | * Setter for the List of collection filters for which the collection will be filtered against | |
| 665 | * | |
| 666 | * @param filters | |
| 667 | */ | |
| 668 | public void setFilters(List<CollectionFilter> filters) { | |
| 669 | 0 | this.filters = filters; |
| 670 | 0 | } |
| 671 | ||
| 672 | /** | |
| 673 | * List of <code>CollectionGroup</code> instances that are sub-collections | |
| 674 | * of the collection represented by this collection group | |
| 675 | * | |
| 676 | * @return List<CollectionGroup> sub collections | |
| 677 | */ | |
| 678 | public List<CollectionGroup> getSubCollections() { | |
| 679 | 0 | return this.subCollections; |
| 680 | } | |
| 681 | ||
| 682 | /** | |
| 683 | * Setter for the sub collection list | |
| 684 | * | |
| 685 | * @param subCollections | |
| 686 | */ | |
| 687 | public void setSubCollections(List<CollectionGroup> subCollections) { | |
| 688 | 0 | this.subCollections = subCollections; |
| 689 | 0 | } |
| 690 | ||
| 691 | /** | |
| 692 | * Suffix for IDs that identifies the collection line the sub-collection belongs to | |
| 693 | * | |
| 694 | * <p> | |
| 695 | * Built by the framework as the collection lines are being generated | |
| 696 | * </p> | |
| 697 | * | |
| 698 | * @return String id suffix for sub-collection | |
| 699 | */ | |
| 700 | public String getSubCollectionSuffix() { | |
| 701 | 0 | return subCollectionSuffix; |
| 702 | } | |
| 703 | ||
| 704 | /** | |
| 705 | * Setter for the sub-collection suffix (used by framework, should not be | |
| 706 | * set in configuration) | |
| 707 | * | |
| 708 | * @param subCollectionSuffix | |
| 709 | */ | |
| 710 | public void setSubCollectionSuffix(String subCollectionSuffix) { | |
| 711 | 0 | this.subCollectionSuffix = subCollectionSuffix; |
| 712 | 0 | } |
| 713 | ||
| 714 | /** | |
| 715 | * <code>CollectionGroupBuilder</code> instance that will build the | |
| 716 | * components dynamically for the collection instance | |
| 717 | * | |
| 718 | * @return CollectionGroupBuilder instance | |
| 719 | */ | |
| 720 | public CollectionGroupBuilder getCollectionGroupBuilder() { | |
| 721 | 0 | if (this.collectionGroupBuilder == null) { |
| 722 | 0 | this.collectionGroupBuilder = new CollectionGroupBuilder(); |
| 723 | } | |
| 724 | 0 | return this.collectionGroupBuilder; |
| 725 | } | |
| 726 | ||
| 727 | /** | |
| 728 | * Setter for the collection group building instance | |
| 729 | * | |
| 730 | * @param collectionGroupBuilder | |
| 731 | */ | |
| 732 | public void setCollectionGroupBuilder(CollectionGroupBuilder collectionGroupBuilder) { | |
| 733 | 0 | this.collectionGroupBuilder = collectionGroupBuilder; |
| 734 | 0 | } |
| 735 | ||
| 736 | /** | |
| 737 | * @see org.kuali.rice.krad.uif.container.ContainerBase#getItems() | |
| 738 | */ | |
| 739 | @SuppressWarnings("unchecked") | |
| 740 | @Override | |
| 741 | public List<? extends Field> getItems() { | |
| 742 | 0 | return (List<? extends Field>) super.getItems(); |
| 743 | } | |
| 744 | ||
| 745 | /** | |
| 746 | * @param showHideInactiveButton the showHideInactiveButton to set | |
| 747 | */ | |
| 748 | public void setShowHideInactiveButton(boolean showHideInactiveButton) { | |
| 749 | 0 | this.showHideInactiveButton = showHideInactiveButton; |
| 750 | 0 | } |
| 751 | ||
| 752 | /** | |
| 753 | * @return the showHideInactiveButton | |
| 754 | */ | |
| 755 | public boolean isShowHideInactiveButton() { | |
| 756 | 0 | return showHideInactiveButton; |
| 757 | } | |
| 758 | ||
| 759 | } |