-
Notifications
You must be signed in to change notification settings - Fork 188
/
ObjectListPanel.java
679 lines (564 loc) · 23.5 KB
/
ObjectListPanel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
/*
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.gui.api.component;
import java.util.*;
import java.util.Objects;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.*;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.prism.query.ObjectOrdering;
import com.evolveum.midpoint.prism.query.ObjectPaging;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.data.BaseSortableDataProvider;
import com.evolveum.midpoint.web.component.data.BoxedTablePanel;
import com.evolveum.midpoint.web.component.data.SelectableBeanObjectDataProvider;
import com.evolveum.midpoint.web.component.data.Table;
import com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn;
import com.evolveum.midpoint.web.component.data.column.ColumnUtils;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
import com.evolveum.midpoint.web.component.search.Search;
import com.evolveum.midpoint.web.component.search.SearchFactory;
import com.evolveum.midpoint.web.component.search.SearchFormPanel;
import com.evolveum.midpoint.web.component.util.ListDataProvider2;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.session.PageStorage;
import com.evolveum.midpoint.web.session.UserProfileStorage.TableId;
import org.jetbrains.annotations.NotNull;
import static java.util.Collections.singleton;
/**
* @author katkav
*/
public abstract class ObjectListPanel<O extends ObjectType> extends BasePanel<O> {
private static final long serialVersionUID = 1L;
private static final String ID_MAIN_FORM = "mainForm";
private static final String ID_TABLE = "table";
private static final Trace LOGGER = TraceManager.getTrace(ObjectListPanel.class);
private static final String DOT_CLASS = ObjectListPanel.class.getName() + ".";
private static final String OPERATION_LOAD_CUSTOM_MENU_ITEMS = DOT_CLASS + "loadCustomMenuItems";
private ObjectTypes type;
private PageBase parentPage;
private LoadableModel<Search> searchModel;
private Collection<SelectorOptions<GetOperationOptions>> options;
private boolean multiselect;
private TableId tableId;
private String addutionalBoxCssClasses;
public Class<? extends O> getType() {
return (Class) type.getClassDefinition();
}
/**
* @param defaultType specifies type of the object that will be selected by default. It can be changed.
*/
public ObjectListPanel(String id, Class<? extends O> defaultType, TableId tableId, Collection<SelectorOptions<GetOperationOptions>> options,
PageBase parentPage) {
this(id, defaultType, tableId, options, false, parentPage);
}
/**
* @param defaultType specifies type of the object that will be selected by default. It can be changed.
*/
ObjectListPanel(String id, Class<? extends O> defaultType, TableId tableId, boolean multiselect, PageBase parentPage) {
this(id, defaultType, tableId, null, multiselect, parentPage);
}
public ObjectListPanel(String id, Class<? extends O> defaultType, TableId tableId, Collection<SelectorOptions<GetOperationOptions>> options,
boolean multiselect, PageBase parentPage) {
super(id);
this.type = defaultType != null ? ObjectTypes.getObjectType(defaultType) : null;
this.parentPage = parentPage;
this.options = options;
this.multiselect = multiselect;
this.tableId = tableId;
initLayout();
}
public boolean isMultiselect() {
return multiselect;
}
public int getSelectedObjectsCount(){
List<O> selectedList = getSelectedObjects();
return selectedList.size();
}
@SuppressWarnings("unchecked")
@NotNull
public List<O> getSelectedObjects() {
BaseSortableDataProvider<SelectableBean<O>> dataProvider = getDataProvider();
if (dataProvider instanceof SelectableBeanObjectDataProvider) {
return ((SelectableBeanObjectDataProvider<O>) dataProvider).getSelectedData();
} else if (dataProvider instanceof ListDataProvider2) {
return ((ListDataProvider2) dataProvider).getSelectedObjects();
}
return new ArrayList<>();
}
private void initLayout() {
Form<O> mainForm = new com.evolveum.midpoint.web.component.form.Form<>(ID_MAIN_FORM);
add(mainForm);
searchModel = initSearchModel();
BoxedTablePanel<SelectableBean<O>> table = createTable();
mainForm.add(table);
}
private LoadableModel<Search> initSearchModel(){
return new LoadableModel<Search>(false) {
private static final long serialVersionUID = 1L;
@Override
public Search load() {
String storageKey = getStorageKey();
Search search = null;
if (StringUtils.isNotEmpty(storageKey)) {
PageStorage storage = getPageStorage(storageKey);
if (storage != null) {
search = storage.getSearch();
}
}
if (search == null) {
search = createSearch();
}
return search;
}
};
}
protected Search createSearch() {
return SearchFactory.createSearch(type.getClassDefinition(), parentPage);
}
private BoxedTablePanel<SelectableBean<O>> createTable() {
List<IColumn<SelectableBean<O>, String>> columns;
if (isCustomColumnsListConfigured()){
columns = initCustomColumns();
} else {
columns = initColumns();
}
List<InlineMenuItem> menuItems = createInlineMenu();
if (menuItems == null) {
menuItems = new ArrayList<>();
}
addCustomActions(menuItems, () -> getSelectedObjects());
if (!menuItems.isEmpty()) {
InlineMenuButtonColumn<SelectableBean<O>> actionsColumn = new InlineMenuButtonColumn<>(menuItems, parentPage);
columns.add(actionsColumn);
}
BaseSortableDataProvider<SelectableBean<O>> provider = initProvider();
BoxedTablePanel<SelectableBean<O>> table = new BoxedTablePanel<SelectableBean<O>>(ID_TABLE, provider,
columns, tableId, tableId == null ? 10 : parentPage.getSessionStorage().getUserProfile().getPagingSize(tableId)) {
private static final long serialVersionUID = 1L;
@Override
protected WebMarkupContainer createHeader(String headerId) {
return ObjectListPanel.this.createHeader(headerId);
}
@Override
public String getAdditionalBoxCssClasses() {
return ObjectListPanel.this.getAdditionalBoxCssClasses();
}
@Override
protected WebMarkupContainer createButtonToolbar(String id) {
WebMarkupContainer bar = ObjectListPanel.this.createTableButtonToolbar(id);
return bar != null ? bar : super.createButtonToolbar(id);
}
};
table.setOutputMarkupId(true);
String storageKey = getStorageKey();
if (StringUtils.isNotEmpty(storageKey)) {
PageStorage storage = getPageStorage(storageKey);
if (storage != null) {
table.setCurrentPage(storage.getPaging());
}
}
return table;
}
protected WebMarkupContainer createHeader(String headerId) {
return initSearch(headerId);
}
protected List<IColumn<SelectableBean<O>, String>> initCustomColumns() {
LOGGER.trace("Start to init custom columns for table of type {}", type);
List<IColumn<SelectableBean<O>, String>> columns = new ArrayList<>();
List<GuiObjectColumnType> customColumns = getGuiObjectColumnTypeList();
if (customColumns == null){
return columns;
}
CheckBoxHeaderColumn<SelectableBean<O>> checkboxColumn = (CheckBoxHeaderColumn<SelectableBean<O>>) createCheckboxColumn();
if (checkboxColumn != null) {
columns.add(checkboxColumn);
}
IColumn<SelectableBean<O>, String> iconColumn = (IColumn) ColumnUtils.createIconColumn(type.getClassDefinition());
columns.add(iconColumn);
columns.addAll(getCustomColumnsTransformed(customColumns));
LOGGER.trace("Finished to init custom columns, created columns {}", columns);
return columns;
}
protected List<IColumn<SelectableBean<O>, String>> getCustomColumnsTransformed(List<GuiObjectColumnType> customColumns){
List<IColumn<SelectableBean<O>, String>> columns = new ArrayList<>();
if (customColumns == null || customColumns.isEmpty()) {
return columns;
}
IColumn<SelectableBean<O>, String> column;
for (GuiObjectColumnType customColumn : customColumns) {
if (customColumn.getPath() == null) {
continue;
}
ItemPath columnPath = customColumn.getPath().getItemPath();
// TODO this throws an exception for some kinds of invalid paths like e.g. fullName/norm (but we probably should fix prisms in that case!)
ItemDefinition itemDefinition = parentPage.getPrismContext().getSchemaRegistry()
.findObjectDefinitionByCompileTimeClass(type.getClassDefinition())
.findItemDefinition(columnPath);
if (itemDefinition == null) {
LOGGER.warn("Unknown path '{}' in a definition of column '{}'", columnPath, customColumn.getName());
continue;
}
if (WebComponentUtil.getElementVisibility(customColumn.getVisibility())) {
IModel<String> columnDisplayModel =
customColumn.getDisplay() != null && customColumn.getDisplay().getLabel() != null ?
Model.of(customColumn.getDisplay().getLabel()) :
createStringResource(getItemDisplayName(customColumn));
if (customColumns.indexOf(customColumn) == 0) {
// TODO what if a complex path is provided here?
column = createNameColumn(columnDisplayModel, customColumn.getPath().toString());
} else {
column = new AbstractColumn<SelectableBean<O>, String>(columnDisplayModel, null) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(org.apache.wicket.markup.repeater.Item<ICellPopulator<SelectableBean<O>>> item,
String componentId, IModel<SelectableBean<O>> rowModel) {
item.add(new Label(componentId, getDataModel(rowModel)));
}
private IModel<?> getDataModel(IModel<SelectableBean<O>> rowModel) {
Item<?, ?> item = rowModel.getObject().getValue().asPrismContainerValue().findItem(columnPath);
if (item != null) {
if (item.getDefinition() != null && item.getDefinition().getValueEnumerationRef() != null &&
item.getDefinition().getValueEnumerationRef().getOid() != null){
String lookupTableOid = item.getDefinition().getValueEnumerationRef().getOid();
Task task = getPageBase().createSimpleTask("loadLookupTable");
OperationResult result = task.getResult();
Collection<SelectorOptions<GetOperationOptions>> options = WebModelServiceUtils
.createLookupTableRetrieveOptions();
PrismObject<LookupTableType> lookupTable = WebModelServiceUtils.loadObject(LookupTableType.class,
lookupTableOid, options, getPageBase(), task, result);
return getItemValuesString(item, lookupTable);
} else {
return getItemValuesString(item, null);
}
} else {
return Model.of("");
}
}
};
}
columns.add(column);
}
}
return columns;
}
private IModel<String> getItemValuesString(Item<?, ?> item, PrismObject<LookupTableType> lookupTable){
return Model.of(item.getValues().stream()
.filter(Objects::nonNull)
.map(itemValue -> {
if (itemValue instanceof PrismPropertyValue) {
if (lookupTable == null) {
return String.valueOf(((PrismPropertyValue<?>) itemValue).getValue());
} else {
String lookupTableKey = ((PrismPropertyValue<?>) itemValue).getValue().toString();
LookupTableType lookupTableObject = lookupTable.getValue().asObjectable();
String rowLabel = "";
for (LookupTableRowType lookupTableRow : lookupTableObject.getRow()){
if (lookupTableRow.getKey().equals(lookupTableKey)){
rowLabel = lookupTableRow.getLabel() != null ? lookupTableRow.getLabel().getOrig() : lookupTableRow.getValue();
break;
}
}
return rowLabel;
}
} else {
return itemValue.toString() + " "; // TODO why + " "?
}
})
.collect(Collectors.joining(", ")));
}
protected List<IColumn<SelectableBean<O>, String>> initColumns() {
LOGGER.trace("Start to init columns for table of type {}", type);
List<IColumn<SelectableBean<O>, String>> columns = new ArrayList<>();
CheckBoxHeaderColumn<SelectableBean<O>> checkboxColumn = (CheckBoxHeaderColumn<SelectableBean<O>>) createCheckboxColumn();
if (checkboxColumn != null) {
columns.add(checkboxColumn);
}
IColumn<SelectableBean<O>, String> iconColumn = (IColumn) ColumnUtils.createIconColumn(type.getClassDefinition());
columns.add(iconColumn);
IColumn<SelectableBean<O>, String> nameColumn = createNameColumn(null, null);
columns.add(nameColumn);
List<IColumn<SelectableBean<O>, String>> others = createColumns();
columns.addAll(others);
LOGGER.trace("Finished to init columns, created columns {}", columns);
return columns;
}
protected BaseSortableDataProvider<SelectableBean<O>> initProvider() {
List<O> preSelectedObjectList = getPreselectedObjectList();
SelectableBeanObjectDataProvider<O> provider = new SelectableBeanObjectDataProvider<O>(
parentPage, (Class) type.getClassDefinition(), preSelectedObjectList == null ? null : new HashSet<>(preSelectedObjectList)) {
private static final long serialVersionUID = 1L;
@Override
protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
String storageKey = getStorageKey();
if (StringUtils.isNotEmpty(storageKey)) {
PageStorage storage = getPageStorage(storageKey);
if (storage != null) {
storage.setPaging(paging);
}
}
}
@Override
public SelectableBean<O> createDataObjectWrapper(O obj) {
SelectableBean<O> bean = super.createDataObjectWrapper(obj);
List<InlineMenuItem> inlineMenu = createInlineMenu();
if (inlineMenu != null) {
bean.getMenuItems().addAll(inlineMenu);
}
if (obj.getOid() != null) {
addCustomActions(bean.getMenuItems(), () -> singleton(obj));
}
return bean;
}
@NotNull
@Override
protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
List<ObjectOrdering> customOrdering = createCustomOrdering(sortParam);
if (customOrdering != null) {
return customOrdering;
}
return super.createObjectOrderings(sortParam);
}
};
if (options == null){
if (ResourceType.class.equals(type.getClassDefinition())) {
options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch());
}
} else {
if (ResourceType.class.equals(type.getClassDefinition())) {
GetOperationOptions root = SelectorOptions.findRootOptions(options);
root.setNoFetch(Boolean.TRUE);
}
provider.setOptions(options);
}
provider.setQuery(getQuery());
return provider;
}
protected List<O> getPreselectedObjectList(){
return null;
}
protected List<ObjectOrdering> createCustomOrdering(SortParam<String> sortParam) {
return null;
}
private SearchFormPanel initSearch(String headerId) {
SearchFormPanel searchPanel = new SearchFormPanel(headerId, searchModel) {
private static final long serialVersionUID = 1L;
@Override
protected void searchPerformed(ObjectQuery query, AjaxRequestTarget target) {
ObjectListPanel.this.searchPerformed(query, target);
}
};
return searchPanel;
}
public String getAdditionalBoxCssClasses() {
return addutionalBoxCssClasses;
}
public void setAdditionalBoxCssClasses(String boxCssClasses) {
this.addutionalBoxCssClasses = boxCssClasses;
}
/**
* there's no way to do it properly...
*/
@Deprecated
protected WebMarkupContainer createTableButtonToolbar(String id) {
return null;
}
private String getStorageKey() {
String storageKey = WebComponentUtil.getStorageKeyForPage(parentPage.getClass());
if (storageKey == null) {
storageKey = WebComponentUtil.getStorageKeyForTableId(tableId);
}
return storageKey;
}
private PageStorage getPageStorage(String storageKey){
PageStorage storage = getSession().getSessionStorage().getPageStorageMap().get(storageKey);
if (storage == null) {
storage = getSession().getSessionStorage().initPageStorage(storageKey);
}
return storage;
}
@SuppressWarnings("unchecked")
protected BaseSortableDataProvider<SelectableBean<O>> getDataProvider() {
BoxedTablePanel<SelectableBean<O>> table = getTable();
BaseSortableDataProvider<SelectableBean<O>> provider = (BaseSortableDataProvider<SelectableBean<O>>) table
.getDataTable().getDataProvider();
return provider;
}
@SuppressWarnings("unchecked")
protected BoxedTablePanel<SelectableBean<O>> getTable() {
return (BoxedTablePanel<SelectableBean<O>>) get(createComponentPath(ID_MAIN_FORM, ID_TABLE));
}
@SuppressWarnings("deprecation")
private void searchPerformed(ObjectQuery query, AjaxRequestTarget target) {
BaseSortableDataProvider<SelectableBean<O>> provider = getDataProvider();
// note: we ignore 'query' parameter, as the 'customQuery' already contains its content (MID-3271)
ObjectQuery customQuery = getQuery();
// if (customQuery == null){
// customQuery = query;
// } else {
// if (query != null){
// customQuery.addFilter(query.getFilter());
// }
// }
provider.setQuery(customQuery);
String storageKey = getStorageKey();
if (StringUtils.isNotEmpty(storageKey)) {
PageStorage storage = getPageStorage(storageKey);
if (storage != null) {
storage.setSearch(searchModel.getObject());
storage.setPaging(null);
}
}
Table table = getTable();
table.setCurrentPage(null);
target.add((Component) table);
target.add(parentPage.getFeedbackPanel());
}
public void refreshTable(Class<O> newTypeClass, AjaxRequestTarget target) {
ObjectTypes newType = newTypeClass != null ? ObjectTypes.getObjectType(newTypeClass) : null;
BaseSortableDataProvider<SelectableBean<O>> provider = getDataProvider();
provider.setQuery(getQuery());
if (newType != null && provider instanceof SelectableBeanObjectDataProvider) {
((SelectableBeanObjectDataProvider<O>) provider).setType(newTypeClass);
}
BoxedTablePanel<SelectableBean<O>> table = getTable();
((WebMarkupContainer) table.get("box")).addOrReplace(initSearch("header"));
if (newType != null && !this.type.equals(newType)) {
this.type = newType;
resetSearchModel();
table.setCurrentPage(null);
} else {
saveSearchModel(getCurrentTablePaging());
}
target.add((Component) table);
target.add(parentPage.getFeedbackPanel());
}
public void resetSearchModel(){
String storageKey = getStorageKey();
if (StringUtils.isNotEmpty(storageKey)) {
PageStorage storage = getPageStorage(storageKey);
storage.setSearch(null);
storage.setPaging(null);
}
searchModel.reset();
}
private void saveSearchModel(ObjectPaging paging) {
String storageKey = getStorageKey();
if (StringUtils.isNotEmpty(storageKey)) {
PageStorage storage = getPageStorage(storageKey);
if (storage != null) {
storage.setSearch(searchModel.getObject());
storage.setPaging(paging);
}
}
}
public void clearCache() {
WebComponentUtil.clearProviderCache(getDataProvider());
}
public ObjectQuery getQuery() {
ObjectQuery customQuery = createContentQuery();
return customQuery;
}
protected ObjectQuery createContentQuery() {
Search search = searchModel.getObject();
ObjectQuery query = search.createObjectQuery(parentPage.getPrismContext());
query = addFilterToContentQuery(query);
return query;
}
protected ObjectQuery addFilterToContentQuery(ObjectQuery query) {
return query;
}
public StringResourceModel createStringResource(String resourceKey, Object... objects) {
return PageBase.createStringResourceStatic(this, resourceKey, objects);
}
protected abstract IColumn<SelectableBean<O>, String> createCheckboxColumn();
protected abstract IColumn<SelectableBean<O>, String> createNameColumn(IModel<String> columnNameModel, String itemPath);
protected abstract List<IColumn<SelectableBean<O>, String>> createColumns();
protected abstract List<InlineMenuItem> createInlineMenu();
protected void addCustomActions(@NotNull List<InlineMenuItem> actionsList, Supplier<Collection<? extends ObjectType>> objectsSupplier) {
GuiObjectListViewType guiObjectListViewType = getGuiObjectListViewType();
if (guiObjectListViewType != null && !guiObjectListViewType.getAction().isEmpty()) {
actionsList.addAll(WebComponentUtil.createMenuItemsFromActions(guiObjectListViewType.getAction(),
OPERATION_LOAD_CUSTOM_MENU_ITEMS, parentPage, objectsSupplier));
}
}
public void addPerformed(AjaxRequestTarget target, List<O> selected) {
parentPage.hideMainPopup(target);
}
private List<GuiObjectColumnType> getGuiObjectColumnTypeList(){
GuiObjectListViewType guiObjectListViewType = getGuiObjectListViewType();
return guiObjectListViewType != null ? guiObjectListViewType.getColumn() : null;
}
private GuiObjectListViewType getGuiObjectListViewType(){
AdminGuiConfigurationType adminGuiConfig = parentPage.getPrincipal().getAdminGuiConfiguration();
if (adminGuiConfig != null && adminGuiConfig.getObjectLists() != null &&
adminGuiConfig.getObjectLists().getObjectList() != null){
for (GuiObjectListViewType object : adminGuiConfig.getObjectLists().getObjectList()){
if (object.getType() != null &&
!type.getClassDefinition().getSimpleName().equals(object.getType().getLocalPart())){
continue;
}
return object;
}
}
return null;
}
private boolean isCustomColumnsListConfigured(){
List<GuiObjectColumnType> columnList = getGuiObjectColumnTypeList();
return columnList != null && !columnList.isEmpty();
}
private String getItemDisplayName(GuiObjectColumnType column){
ItemDefinition itemDefinition = parentPage.getPrismContext().getSchemaRegistry()
.findObjectDefinitionByCompileTimeClass(type.getClassDefinition()).findItemDefinition(column.getPath().getItemPath());
return itemDefinition == null ? "" : itemDefinition.getDisplayName();
}
public ObjectPaging getCurrentTablePaging(){
String storageKey = getStorageKey();
if (StringUtils.isEmpty(storageKey)){
return null;
}
PageStorage storage = getPageStorage(storageKey);
if (storage == null) {
return null;
}
return storage.getPaging();
}
}