/
FocusProjectionsTabPanel.java
566 lines (487 loc) · 21.8 KB
/
FocusProjectionsTabPanel.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
/*
* 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.web.component.objectdetails;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
import org.apache.commons.lang.Validate;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.request.resource.PackageResourceReference;
import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition;
import com.evolveum.midpoint.common.refinery.RefinedResourceSchema;
import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl;
import com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel;
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.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismObjectDefinition;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.PrismPropertyValue;
import com.evolveum.midpoint.prism.PrismReferenceDefinition;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.dialog.ConfirmationPanel;
import com.evolveum.midpoint.web.component.dialog.Popupable;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenu;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction;
import com.evolveum.midpoint.web.component.prism.CheckTableHeader;
import com.evolveum.midpoint.web.component.prism.ContainerStatus;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.prism.ObjectWrapper;
import com.evolveum.midpoint.web.component.prism.PrismPanel;
import com.evolveum.midpoint.web.component.prism.PropertyWrapper;
import com.evolveum.midpoint.web.component.prism.SimpleErrorPanel;
import com.evolveum.midpoint.web.component.prism.ValueWrapper;
import com.evolveum.midpoint.web.component.util.ObjectWrapperUtil;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.model.ContainerWrapperListFromObjectWrapperModel;
import com.evolveum.midpoint.web.page.admin.PageAdminFocus;
import com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto;
import com.evolveum.midpoint.web.page.admin.users.dto.UserDtoStatus;
import com.evolveum.midpoint.web.resource.img.ImgResources;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LayerType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.LockoutStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
/**
* @author semancik
*/
public class FocusProjectionsTabPanel<F extends FocusType> extends AbstractObjectTabPanel<F> {
private static final long serialVersionUID = 1L;
private static final String ID_SHADOW_LIST = "shadowList";
private static final String ID_SHADOWS = "shadows";
private static final String ID_SHADOW_HEADER = "shadowHeader";
private static final String ID_SHADOW = "shadow";
private static final String ID_SHADOW_MENU = "shadowMenu";
private static final String ID_SHADOW_CHECK_ALL = "shadowCheckAll";
private static final String DOT_CLASS = FocusProjectionsTabPanel.class.getName() + ".";
private static final String OPERATION_ADD_ACCOUNT = DOT_CLASS + "addShadow";
private static final Trace LOGGER = TraceManager.getTrace(FocusProjectionsTabPanel.class);
private LoadableModel<List<FocusSubwrapperDto<ShadowType>>> projectionModel;
public FocusProjectionsTabPanel(String id, Form mainForm, LoadableModel<ObjectWrapper<F>> focusModel,
LoadableModel<List<FocusSubwrapperDto<ShadowType>>> projectionModel, PageBase page) {
super(id, mainForm, focusModel, page);
Validate.notNull(projectionModel, "Null projection model");
this.projectionModel = projectionModel;
initLayout(page);
}
private void initLayout(final PageBase page) {
final WebMarkupContainer shadows = new WebMarkupContainer(ID_SHADOWS);
shadows.setOutputMarkupId(true);
add(shadows);
InlineMenu accountMenu = new InlineMenu(ID_SHADOW_MENU, new Model((Serializable) createShadowMenu()));
accountMenu.setVisible(!getObjectWrapper().isReadonly());
shadows.add(accountMenu);
final ListView<FocusSubwrapperDto<ShadowType>> projectionList = new ListView<FocusSubwrapperDto<ShadowType>>(
ID_SHADOW_LIST, projectionModel) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<FocusSubwrapperDto<ShadowType>> item) {
PackageResourceReference packageRef;
final FocusSubwrapperDto<ShadowType> dto = item.getModelObject();
final PropertyModel<ObjectWrapper<ShadowType>> objectWrapperModel = new PropertyModel<ObjectWrapper<ShadowType>>(
item.getModel(), "object");
final Panel shadowPanel;
if (dto.isLoadedOK()) {
packageRef = new PackageResourceReference(ImgResources.class, ImgResources.HDD_PRISM);
shadowPanel = new PrismPanel<F>(ID_SHADOW,
new ContainerWrapperListFromObjectWrapperModel<>(objectWrapperModel,
WebComponentUtil.getShadowItemsToShow()), packageRef,
getMainForm(), itemWrapper -> WebComponentUtil.checkShadowActivationAndPasswordVisibility(itemWrapper, objectWrapperModel), getPageBase());
} else {
shadowPanel = new SimpleErrorPanel<ShadowType>(ID_SHADOW, item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
public void onShowMorePerformed(AjaxRequestTarget target) {
OperationResult fetchResult = dto.getResult();
if (fetchResult != null) {
showResult(fetchResult);
target.add(page.getFeedbackPanel());
}
}
};
}
shadowPanel.setOutputMarkupId(true);
shadowPanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
FocusSubwrapperDto<ShadowType> shadowWrapperDto = item.getModelObject();
ObjectWrapper<ShadowType> shadowWrapper = shadowWrapperDto.getObject();
return !shadowWrapper.isMinimalized();
}
});
item.add(shadowPanel);
CheckTableHeader<ShadowType> shadowHeader = new CheckTableHeader<ShadowType>(ID_SHADOW_HEADER,
objectWrapperModel) {
private static final long serialVersionUID = 1L;
@Override
protected void onClickPerformed(AjaxRequestTarget target) {
super.onClickPerformed(target);
onExpandCollapse(target, item.getModel());
target.add(shadows);
}
};
if (UserDtoStatus.DELETE.equals(dto.getStatus())) {
shadowHeader.add(new AttributeModifier("class", "box-header with-border delete"));
}
item.add(shadowHeader);
}
};
AjaxCheckBox accountCheckAll = new AjaxCheckBox(ID_SHADOW_CHECK_ALL, new Model()) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
for (FocusSubwrapperDto<ShadowType> dto : projectionList.getModelObject()) {
if (dto.isLoadedOK()) {
ObjectWrapper<ShadowType> accModel = dto.getObject();
accModel.setSelected(getModelObject());
}
}
target.add(shadows);
}
};
shadows.add(accountCheckAll);
shadows.add(projectionList);
}
private void onExpandCollapse(AjaxRequestTarget target, IModel<FocusSubwrapperDto<ShadowType>> dtoModel) {
FocusSubwrapperDto<ShadowType> shadowWrapperDto = dtoModel.getObject();
ObjectWrapper<ShadowType> shadowWrapper = shadowWrapperDto.getObject();
if (shadowWrapper.isMinimalized()) {
return;
}
if (WebModelServiceUtils.isNoFetch(shadowWrapper.getLoadOptions())) {
((PageAdminFocus) getPage()).loadFullShadow(shadowWrapperDto);
}
}
private void addSelectedAccountPerformed(AjaxRequestTarget target, List<ResourceType> newResources) {
getPageBase().hideMainPopup(target);
if (newResources.isEmpty()) {
warn(getString("pageUser.message.noResourceSelected"));
return;
}
for (ResourceType resource : newResources) {
try {
ShadowType shadow = new ShadowType();
shadow.setResource(resource);
RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(
resource.asPrismObject(), LayerType.PRESENTATION, getPrismContext());
if (refinedSchema == null) {
Task task = getPageBase().createSimpleTask(FocusPersonasTabPanel.class.getSimpleName() + ".loadResource");
OperationResult result = task.getResult();
PrismObject<ResourceType> loadedResource = WebModelServiceUtils.loadObject(ResourceType.class, resource.getOid(), getPageBase(), task, result);
result.recomputeStatus();
refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(
loadedResource, LayerType.PRESENTATION, getPrismContext());
if (refinedSchema == null) {
error(getString("pageAdminFocus.message.couldntCreateAccountNoSchema",
resource.getName()));
continue;
}
// resource = loadedResource.asObjectable();
shadow.setResource(loadedResource.asObjectable());
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Refined schema for {}\n{}", resource, refinedSchema.debugDump());
}
RefinedObjectClassDefinition accountDefinition = refinedSchema
.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT);
if (accountDefinition == null) {
error(getString("pageAdminFocus.message.couldntCreateAccountNoAccountSchema",
resource.getName()));
continue;
}
QName objectClass = accountDefinition.getObjectClassDefinition().getTypeName();
shadow.setObjectClass(objectClass);
getPrismContext().adopt(shadow);
Task task = getPageBase().createSimpleTask(OPERATION_ADD_ACCOUNT);
ObjectWrapper<ShadowType> wrapper = ObjectWrapperUtil.createObjectWrapper(
WebComponentUtil.getOrigStringFromPoly(resource.getName()), null,
shadow.asPrismObject(), ContainerStatus.ADDING, task, getPageBase());
if (wrapper.getResult() != null
&& !WebComponentUtil.isSuccessOrHandledError(wrapper.getResult())) {
showResult(wrapper.getResult(), false);
}
// wrapper.setShowEmpty(true);
wrapper.setMinimalized(true);
projectionModel.getObject().add(new FocusSubwrapperDto(wrapper, UserDtoStatus.ADD));
} catch (Exception ex) {
error(getString("pageAdminFocus.message.couldntCreateAccount", resource.getName(),
ex.getMessage()));
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create account", ex);
}
}
target.add(get(ID_SHADOWS));
}
private List<InlineMenuItem> createShadowMenu() {
List<InlineMenuItem> items = new ArrayList<InlineMenuItem>();
PrismObjectDefinition<F> def = getObjectWrapper().getObject().getDefinition();
PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
InlineMenuItem item;
if (ref.canRead() && ref.canAdd()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.addShadow"),
new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<QName> supportedTypes = new ArrayList<>(1);
supportedTypes.add(ResourceType.COMPLEX_TYPE);
PageBase pageBase = FocusProjectionsTabPanel.this.getPageBase();
ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<ResourceType>(
pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true,
pageBase) {
private static final long serialVersionUID = 1L;
@Override
protected void addPerformed(AjaxRequestTarget target, QName type,
List<ResourceType> selected) {
FocusProjectionsTabPanel.this.addSelectedAccountPerformed(target,
selected);
}
};
resourceSelectionPanel.setOutputMarkupId(true);
pageBase.showMainPopup(resourceSelectionPanel,
target);
}
});
items.add(item);
items.add(new InlineMenuItem());
}
PrismPropertyDefinition<ActivationStatusType> administrativeStatus = def
.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (administrativeStatus.canRead() && administrativeStatus.canModify()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.enable"),
new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateShadowActivation(target, getSelectedProjections(projectionModel), true);
}
});
items.add(item);
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.disable"),
new InlineMenuItemAction() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateShadowActivation(target, getSelectedProjections(projectionModel), false);
}
});
items.add(item);
}
if (ref.canRead() && ref.canAdd()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlink"),
new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
unlinkProjectionPerformed(target, projectionModel,
getSelectedProjections(projectionModel), ID_SHADOWS);
}
});
items.add(item);
}
PrismPropertyDefinition<LockoutStatusType> locakoutStatus = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS);
if (locakoutStatus.canRead() && locakoutStatus.canModify()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlock"),
new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
unlockShadowPerformed(target, projectionModel,
getSelectedProjections(projectionModel));
}
});
items.add(item);
}
if (administrativeStatus.canRead() && administrativeStatus.canModify()) {
items.add(new InlineMenuItem());
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.delete"),
new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteProjectionPerformed(target, projectionModel);
}
});
items.add(item);
}
return items;
}
private List<FocusSubwrapperDto<ShadowType>> getSelectedProjections(
IModel<List<FocusSubwrapperDto<ShadowType>>> projectionModel) {
List<FocusSubwrapperDto<ShadowType>> selected = new ArrayList<>();
List<FocusSubwrapperDto<ShadowType>> all = projectionModel.getObject();
for (FocusSubwrapperDto<ShadowType> shadow : all) {
if (shadow.isLoadedOK() && shadow.getObject().isSelected()) {
selected.add(shadow);
}
}
return selected;
}
private void deleteProjectionPerformed(AjaxRequestTarget target,
IModel<List<FocusSubwrapperDto<ShadowType>>> model) {
if (!isAnyProjectionSelected(target, model)) {
return;
}
showModalWindow(getDeleteProjectionPopupContent(),
target);
}
private boolean isAnyProjectionSelected(AjaxRequestTarget target,
IModel<List<FocusSubwrapperDto<ShadowType>>> model) {
List<FocusSubwrapperDto<ShadowType>> selected = getSelectedProjections(model);
if (selected.isEmpty()) {
warn(getString("pageAdminFocus.message.noAccountSelected"));
target.add(getFeedbackPanel());
return false;
}
return true;
}
private void updateShadowActivation(AjaxRequestTarget target,
List<FocusSubwrapperDto<ShadowType>> accounts, boolean enabled) {
if (!isAnyProjectionSelected(target, projectionModel)) {
return;
}
for (FocusSubwrapperDto<ShadowType> account : accounts) {
if (!account.isLoadedOK()) {
continue;
}
ObjectWrapper<ShadowType> wrapper = account.getObject();
ContainerWrapper<ActivationType> activation = wrapper
.findContainerWrapper(new ItemPath(ShadowType.F_ACTIVATION));
if (activation == null) {
warn(getString("pageAdminFocus.message.noActivationFound", wrapper.getDisplayName()));
continue;
}
PropertyWrapper enabledProperty = (PropertyWrapper) activation.getValues().iterator().next()
.findPropertyWrapper(ActivationType.F_ADMINISTRATIVE_STATUS);
if (enabledProperty == null || enabledProperty.getValues().size() != 1) {
warn(getString("pageAdminFocus.message.noEnabledPropertyFound", wrapper.getDisplayName()));
continue;
}
ValueWrapper value = (ValueWrapper) enabledProperty.getValues().get(0);
ActivationStatusType status = enabled ? ActivationStatusType.ENABLED
: ActivationStatusType.DISABLED;
((PrismPropertyValue) value.getValue()).setValue(status);
wrapper.setSelected(false);
}
target.add(getFeedbackPanel(), get(createComponentPath(ID_SHADOWS)));
}
private void unlockShadowPerformed(AjaxRequestTarget target,
IModel<List<FocusSubwrapperDto<ShadowType>>> model,
List<FocusSubwrapperDto<ShadowType>> selected) {
if (!isAnyProjectionSelected(target, model)) {
return;
}
for (FocusSubwrapperDto<ShadowType> account : selected) {
if (!account.isLoadedOK()) {
continue;
}
ObjectWrapper<ShadowType> wrapper = account.getObject();
wrapper.setSelected(false);
ContainerWrapper<ActivationType> activation = wrapper.findContainerWrapper(new ItemPath(ShadowType.F_ACTIVATION));
if (activation == null) {
warn(getString("pageAdminFocus.message.noActivationFound", wrapper.getDisplayName()));
continue;
}
PropertyWrapper lockedProperty = (PropertyWrapper) activation.getValues().iterator().next().findPropertyWrapper(ActivationType.F_LOCKOUT_STATUS);
if (lockedProperty == null || lockedProperty.getValues().size() != 1) {
warn(getString("pageAdminFocus.message.noLockoutStatusPropertyFound", wrapper.getDisplayName()));
continue;
}
ValueWrapper value = (ValueWrapper) lockedProperty.getValues().get(0);
((PrismPropertyValue) value.getValue()).setValue(LockoutStatusType.NORMAL);
info(getString("pageAdminFocus.message.unlocked", wrapper.getDisplayName())); // TODO only for really unlocked accounts
}
target.add(getFeedbackPanel(), get(createComponentPath(ID_SHADOWS)));
}
private void unlinkProjectionPerformed(AjaxRequestTarget target,
IModel<List<FocusSubwrapperDto<ShadowType>>> model, List<FocusSubwrapperDto<ShadowType>> selected,
String componentPath) {
if (!isAnyProjectionSelected(target, model)) {
return;
}
for (FocusSubwrapperDto projection : selected) {
if (UserDtoStatus.ADD.equals(projection.getStatus())) {
continue;
}
projection.setStatus(UserDtoStatus.UNLINK);
}
target.add(get(createComponentPath(componentPath)));
}
private Popupable getDeleteProjectionPopupContent() {
ConfirmationPanel dialog = new ConfirmationPanel(getPageBase().getMainPopupBodyId(),
new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return createStringResource("pageAdminFocus.message.deleteAccountConfirm",
getSelectedProjections(projectionModel).size()).getString();
}
}) {
private static final long serialVersionUID = 1L;
@Override
public void yesPerformed(AjaxRequestTarget target) {
ModalWindow modalWindow = findParent(ModalWindow.class);
if (modalWindow != null) {
modalWindow.close(target);
deleteAccountConfirmedPerformed(target, getSelectedProjections(projectionModel));
}
}
};
return dialog;
}
private void deleteAccountConfirmedPerformed(AjaxRequestTarget target,
List<FocusSubwrapperDto<ShadowType>> selected) {
List<FocusSubwrapperDto<ShadowType>> accounts = projectionModel.getObject();
for (FocusSubwrapperDto<ShadowType> account : selected) {
if (UserDtoStatus.ADD.equals(account.getStatus())) {
accounts.remove(account);
} else {
account.setStatus(UserDtoStatus.DELETE);
}
}
target.add(get(createComponentPath(ID_SHADOWS)));
}
}