1
|
/**
|
2
|
* Copyright (C) 2017 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.vaadin.view.registration;
|
10
|
|
11
|
import static eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles.LABEL_NOWRAP;
|
12
|
|
13
|
import java.util.ArrayList;
|
14
|
import java.util.Collection;
|
15
|
import java.util.Collections;
|
16
|
import java.util.EnumSet;
|
17
|
import java.util.HashMap;
|
18
|
import java.util.Iterator;
|
19
|
import java.util.List;
|
20
|
import java.util.Map;
|
21
|
import java.util.Set;
|
22
|
import java.util.Stack;
|
23
|
import java.util.UUID;
|
24
|
|
25
|
import org.springframework.security.core.GrantedAuthority;
|
26
|
import org.vaadin.viritin.fields.LazyComboBox;
|
27
|
|
28
|
import com.vaadin.navigator.View;
|
29
|
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
|
30
|
import com.vaadin.server.FontAwesome;
|
31
|
import com.vaadin.server.Page;
|
32
|
import com.vaadin.shared.ui.label.ContentMode;
|
33
|
import com.vaadin.spring.annotation.SpringView;
|
34
|
import com.vaadin.ui.Alignment;
|
35
|
import com.vaadin.ui.Button;
|
36
|
import com.vaadin.ui.Component;
|
37
|
import com.vaadin.ui.CssLayout;
|
38
|
import com.vaadin.ui.GridLayout;
|
39
|
import com.vaadin.ui.HorizontalLayout;
|
40
|
import com.vaadin.ui.Label;
|
41
|
import com.vaadin.ui.Notification;
|
42
|
import com.vaadin.ui.Panel;
|
43
|
import com.vaadin.ui.UI;
|
44
|
import com.vaadin.ui.VerticalLayout;
|
45
|
import com.vaadin.ui.Window;
|
46
|
import com.vaadin.ui.themes.ValoTheme;
|
47
|
|
48
|
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
|
49
|
import eu.etaxonomy.cdm.api.service.dto.RegistrationType;
|
50
|
import eu.etaxonomy.cdm.api.service.dto.RegistrationWorkingSet;
|
51
|
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSetType;
|
52
|
import eu.etaxonomy.cdm.api.utility.RoleProber;
|
53
|
import eu.etaxonomy.cdm.model.name.Registration;
|
54
|
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
|
55
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
56
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
|
57
|
import eu.etaxonomy.cdm.ref.EntityReference;
|
58
|
import eu.etaxonomy.cdm.ref.TypedEntityReference;
|
59
|
import eu.etaxonomy.cdm.service.UserHelperAccess;
|
60
|
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem;
|
61
|
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemButtons;
|
62
|
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemNameAndTypeButtons;
|
63
|
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemNameAndTypeButtons.TypeDesignationWorkingSetButton;
|
64
|
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemsPanel;
|
65
|
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStatusFieldInstantiator;
|
66
|
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStatusLabel;
|
67
|
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles;
|
68
|
import eu.etaxonomy.cdm.vaadin.event.EditorActionContext;
|
69
|
import eu.etaxonomy.cdm.vaadin.event.RegistrationEditorAction;
|
70
|
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
|
71
|
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
|
72
|
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction;
|
73
|
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkingsetAction;
|
74
|
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
|
75
|
import eu.etaxonomy.cdm.vaadin.permission.PermissionDebugUtils;
|
76
|
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
|
77
|
import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
|
78
|
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
|
79
|
import eu.etaxonomy.vaadin.event.EditorActionType;
|
80
|
|
81
|
/**
|
82
|
* @author a.kohlbecker
|
83
|
* @since Mar 2, 2017
|
84
|
*
|
85
|
*/
|
86
|
@SpringView(name=RegistrationWorksetViewBean.NAME)
|
87
|
public class RegistrationWorksetViewBean extends AbstractPageView<RegistrationWorkingsetPresenter>
|
88
|
implements RegistrationWorkingsetView, View, AccessRestrictedView {
|
89
|
|
90
|
|
91
|
private static final int COL_INDEX_STATE_LABEL = 0;
|
92
|
|
93
|
private static final int COL_INDEX_REG_ITEM = 1;
|
94
|
|
95
|
private static final int COL_INDEX_BUTTON_GROUP = 2;
|
96
|
|
97
|
public static final String DOM_ID_WORKINGSET = "workingset";
|
98
|
|
99
|
public static final String TEXT_NAME_TYPIFICATION = "covering the name and typifications";
|
100
|
public static final String TEXT_TYPIFICATION_ONLY = "covering typifications only";
|
101
|
|
102
|
private static final long serialVersionUID = -213040114015958970L;
|
103
|
|
104
|
public static final String NAME = "workingset";
|
105
|
|
106
|
public RegistrationType regType = null;
|
107
|
|
108
|
private List<CssLayout> registrations = new ArrayList<>();
|
109
|
|
110
|
private String headerText = "Registration Workingset Editor";
|
111
|
private String subheaderText = "";
|
112
|
|
113
|
private UUID citationUuid;
|
114
|
|
115
|
private Button addNewNameRegistrationButton;
|
116
|
|
117
|
private LazyComboBox<TaxonName> existingNameCombobox;
|
118
|
|
119
|
private GridLayout registrationsGrid;
|
120
|
|
121
|
private Button addExistingNameButton;
|
122
|
|
123
|
private Label existingNameRegistrationTypeLabel;
|
124
|
|
125
|
private RegistrationItem workingsetHeader;
|
126
|
|
127
|
private Panel registrationListPanel;
|
128
|
|
129
|
/**
|
130
|
* uses the registrationId as key
|
131
|
*/
|
132
|
private Map<UUID, RegistrationDetailsItem> registrationItemMap = new HashMap<>();
|
133
|
|
134
|
/**
|
135
|
* uses the registrationId as key
|
136
|
*/
|
137
|
private Map<UUID, EntityReference> typifiedNamesMap = new HashMap<>();
|
138
|
|
139
|
private RegistrationStatusFieldInstantiator statusFieldInstantiator;
|
140
|
|
141
|
public RegistrationWorksetViewBean() {
|
142
|
super();
|
143
|
}
|
144
|
|
145
|
|
146
|
/**
|
147
|
* {@inheritDoc}
|
148
|
*/
|
149
|
@Override
|
150
|
protected void initContent() {
|
151
|
getLayout().setId(NAME);
|
152
|
updateHeader();
|
153
|
// all content is added in createRegistrationsList()
|
154
|
}
|
155
|
|
156
|
|
157
|
/**
|
158
|
* {@inheritDoc}
|
159
|
*/
|
160
|
@Override
|
161
|
public void enter(ViewChangeEvent event) {
|
162
|
if(event.getParameters() != null){
|
163
|
this.citationUuid = UUID.fromString(event.getParameters());
|
164
|
|
165
|
getPresenter().handleViewEntered();
|
166
|
}
|
167
|
}
|
168
|
|
169
|
/**
|
170
|
* {@inheritDoc}
|
171
|
*/
|
172
|
@Override
|
173
|
public void setWorkingset(RegistrationWorkingSet workingset) {
|
174
|
|
175
|
if(workingsetHeader != null){
|
176
|
getLayout().removeComponent(workingsetHeader);
|
177
|
getLayout().removeComponent(registrationListPanel);
|
178
|
}
|
179
|
workingsetHeader = new RegistrationItem(workingset, this, getPresenter().getCache());
|
180
|
addContentComponent(workingsetHeader, null);
|
181
|
|
182
|
registrationListPanel = createRegistrationsList(workingset);
|
183
|
registrationListPanel.setHeight("100%");
|
184
|
registrationListPanel.setStyleName("registration-list");
|
185
|
registrationListPanel.setCaption("Registrations");
|
186
|
addContentComponent(registrationListPanel, 1.0f);
|
187
|
|
188
|
}
|
189
|
|
190
|
@Override
|
191
|
public void setBlockingRegistrations(UUID registrationUuid, Set<RegistrationDTO> blockingRegDTOs) {
|
192
|
|
193
|
RegistrationDetailsItem regItem = registrationItemMap.get(registrationUuid);
|
194
|
|
195
|
boolean blockingRegAdded = false;
|
196
|
for(Iterator it = regItem.itemFooter.iterator(); it.hasNext(); ){
|
197
|
if(it.next() instanceof RegistrationItemsPanel){
|
198
|
blockingRegAdded = true;
|
199
|
break;
|
200
|
}
|
201
|
}
|
202
|
if(!blockingRegAdded){
|
203
|
regItem.itemFooter.addComponent(new RegistrationItemsPanel(this, "Blocked by", blockingRegDTOs, getPresenter().getCache()));
|
204
|
}
|
205
|
}
|
206
|
|
207
|
/**
|
208
|
* {@inheritDoc}
|
209
|
*/
|
210
|
@Override
|
211
|
@Deprecated // no longer needed
|
212
|
public void addBlockingRegistration(RegistrationDTO blocking) {
|
213
|
if(registrations == null) {
|
214
|
throw new RuntimeException("A Workingset must be present prior adding blocking registrations.");
|
215
|
}
|
216
|
// add the blocking registration
|
217
|
|
218
|
}
|
219
|
|
220
|
/**
|
221
|
* @param workingset
|
222
|
* @return
|
223
|
*/
|
224
|
public Panel createRegistrationsList(RegistrationWorkingSet workingset) {
|
225
|
|
226
|
registrationsGrid = new GridLayout(3, 1);
|
227
|
registrationsGrid.setWidth("100%");
|
228
|
// allow vertical scrolling:
|
229
|
registrationsGrid.setHeightUndefined();
|
230
|
|
231
|
//registrationsGrid.setColumnExpandRatio(0, 0.1f);
|
232
|
registrationsGrid.setColumnExpandRatio(1, 1f);
|
233
|
|
234
|
registrationItemMap.clear();
|
235
|
registrationsGrid.setRows(workingset.getRegistrationDTOs().size() * 2 + 3);
|
236
|
int row = 0;
|
237
|
for(RegistrationDTO dto : workingset.getRegistrationDTOs()) {
|
238
|
row = putRegistrationListComponent(row, dto);
|
239
|
}
|
240
|
|
241
|
// --- Footer with UI to create new registrations ----
|
242
|
Label addRegistrationLabel_1 = new Label("Add a new registration for a");
|
243
|
Label addRegistrationLabel_2 = new Label("or an");
|
244
|
|
245
|
addNewNameRegistrationButton = new Button("new name");
|
246
|
addNewNameRegistrationButton.setDescription("A name which is newly published in this publication.");
|
247
|
Stack<EditorActionContext> context = new Stack<EditorActionContext>();
|
248
|
context.push(new EditorActionContext(
|
249
|
new TypedEntityReference<>(Registration.class, null),
|
250
|
this)
|
251
|
);
|
252
|
addNewNameRegistrationButton.addClickListener(
|
253
|
e -> {
|
254
|
getViewEventBus().publish(this, new TaxonNameEditorAction(EditorActionType.ADD, null, addNewNameRegistrationButton, null, this, context));
|
255
|
|
256
|
}
|
257
|
);
|
258
|
|
259
|
existingNameRegistrationTypeLabel = new Label();
|
260
|
addExistingNameButton = new Button("existing name:");
|
261
|
addExistingNameButton.setEnabled(false);
|
262
|
addExistingNameButton.addClickListener(
|
263
|
e -> getViewEventBus().publish(this, new RegistrationWorkingsetAction(
|
264
|
citationUuid,
|
265
|
RegistrationWorkingsetAction.Action.start
|
266
|
)
|
267
|
)
|
268
|
);
|
269
|
|
270
|
existingNameCombobox = new LazyComboBox<TaxonName>(TaxonName.class);
|
271
|
existingNameCombobox.addValueChangeListener(
|
272
|
e -> {
|
273
|
boolean selectionNotEmpty = e.getProperty().getValue() != null;
|
274
|
addExistingNameButton.setEnabled(false);
|
275
|
existingNameRegistrationTypeLabel.setValue(null);
|
276
|
if(selectionNotEmpty){
|
277
|
TaxonName name = (TaxonName)e.getProperty().getValue();
|
278
|
if(getPresenter().canCreateNameRegistrationFor(name)){
|
279
|
existingNameRegistrationTypeLabel.setValue(TEXT_NAME_TYPIFICATION);
|
280
|
addExistingNameButton.setEnabled(true);
|
281
|
} else {
|
282
|
if(!getPresenter().checkWokingsetContainsProtologe(name)){
|
283
|
existingNameRegistrationTypeLabel.setValue(TEXT_TYPIFICATION_ONLY);
|
284
|
addExistingNameButton.setEnabled(true);
|
285
|
}
|
286
|
}
|
287
|
} else {
|
288
|
existingNameRegistrationTypeLabel.setValue(null);
|
289
|
}
|
290
|
}
|
291
|
);
|
292
|
|
293
|
HorizontalLayout buttonContainer = new HorizontalLayout(
|
294
|
addRegistrationLabel_1,
|
295
|
addNewNameRegistrationButton,
|
296
|
addRegistrationLabel_2,
|
297
|
addExistingNameButton,
|
298
|
existingNameCombobox,
|
299
|
existingNameRegistrationTypeLabel
|
300
|
);
|
301
|
buttonContainer.setSpacing(true);
|
302
|
// buttonContainer.setWidth(100, Unit.PERCENTAGE);
|
303
|
buttonContainer.setComponentAlignment(addRegistrationLabel_1, Alignment.MIDDLE_LEFT);
|
304
|
buttonContainer.setComponentAlignment(addRegistrationLabel_2, Alignment.MIDDLE_LEFT);
|
305
|
|
306
|
row++;
|
307
|
registrationsGrid.addComponent(buttonContainer, 0, row, COL_INDEX_BUTTON_GROUP, row);
|
308
|
registrationsGrid.setComponentAlignment(buttonContainer, Alignment.MIDDLE_RIGHT);
|
309
|
|
310
|
row++;
|
311
|
Label hint = new Label(
|
312
|
"For most names that already exist in the system, it is only possible to create a registration covering type designations. "
|
313
|
+ "In all other cases please choose <a href=\"registration#!regStart\">\"New\"</a> from the main menu and start a registration for the nomenclatural reference of the name to be registered.",
|
314
|
ContentMode.HTML);
|
315
|
registrationsGrid.addComponent(hint, 0, row, COL_INDEX_BUTTON_GROUP, row);
|
316
|
registrationsGrid.setComponentAlignment(hint, Alignment.MIDDLE_RIGHT);
|
317
|
|
318
|
Panel namesTypesPanel = new Panel(registrationsGrid);
|
319
|
namesTypesPanel.setStyleName(EditValoTheme.PANEL_CONTENT_PADDING_LEFT);
|
320
|
return namesTypesPanel;
|
321
|
}
|
322
|
|
323
|
|
324
|
protected int putRegistrationListComponent(int row, RegistrationDTO dto) {
|
325
|
|
326
|
EntityReference typifiedNameReference = dto.getTypifiedNameRef();
|
327
|
if(typifiedNameReference == null){
|
328
|
typifiedNameReference = dto.getNameRef();
|
329
|
}
|
330
|
typifiedNamesMap.put(dto.getUuid(), typifiedNameReference);
|
331
|
|
332
|
RegistrationItemNameAndTypeButtons regItemButtonGroup = new RegistrationItemNameAndTypeButtons(dto, getPresenter().getCache());
|
333
|
UUID registrationEntityUuid = dto.getUuid();
|
334
|
|
335
|
RegistrationItemButtons regItemButtons = new RegistrationItemButtons();
|
336
|
|
337
|
CssLayout footer = new CssLayout();
|
338
|
footer.setWidth(100, Unit.PERCENTAGE);
|
339
|
footer.setStyleName("item-footer");
|
340
|
|
341
|
RegistrationDetailsItem regDetailsItem = new RegistrationDetailsItem(regItemButtonGroup, regItemButtons, footer);
|
342
|
registrationItemMap.put(registrationEntityUuid, regDetailsItem);
|
343
|
|
344
|
Stack<EditorActionContext> context = new Stack<EditorActionContext>();
|
345
|
context.push(new EditorActionContext(
|
346
|
new TypedEntityReference<>(Registration.class, registrationEntityUuid),
|
347
|
this)
|
348
|
);
|
349
|
|
350
|
if(regItemButtonGroup.getNameButton() != null){
|
351
|
regItemButtonGroup.getNameButton().getButton().addClickListener(e -> {
|
352
|
UUID nameuUuid = regItemButtonGroup.getNameButton().getUuid();
|
353
|
getViewEventBus().publish(this, new TaxonNameEditorAction(
|
354
|
EditorActionType.EDIT,
|
355
|
nameuUuid,
|
356
|
e.getButton(),
|
357
|
null,
|
358
|
this,
|
359
|
context
|
360
|
)
|
361
|
);
|
362
|
});
|
363
|
}
|
364
|
|
365
|
for(TypeDesignationWorkingSetButton workingsetButton : regItemButtonGroup.getTypeDesignationButtons()){
|
366
|
workingsetButton.getButton().addClickListener(e -> {
|
367
|
TypedEntityReference baseEntityRef = workingsetButton.getBaseEntity();
|
368
|
EntityReference typifiedNameRef = typifiedNamesMap.get(registrationEntityUuid);
|
369
|
TypeDesignationWorkingSetType workingsetType = workingsetButton.getType();
|
370
|
getViewEventBus().publish(this, new TypeDesignationWorkingsetEditorAction(
|
371
|
baseEntityRef,
|
372
|
workingsetType,
|
373
|
registrationEntityUuid,
|
374
|
typifiedNameRef.getUuid(),
|
375
|
e.getButton(),
|
376
|
null,
|
377
|
this,
|
378
|
context
|
379
|
)
|
380
|
);
|
381
|
});
|
382
|
}
|
383
|
|
384
|
regItemButtonGroup.getAddTypeDesignationButton().addClickListener(
|
385
|
e -> chooseNewTypeRegistrationWorkingset(dto.getUuid())
|
386
|
);
|
387
|
|
388
|
|
389
|
Button blockingRegistrationButton = regItemButtons.getBlockingRegistrationButton();
|
390
|
blockingRegistrationButton.setStyleName(ValoTheme.BUTTON_TINY);
|
391
|
blockingRegistrationButton.setDescription("No blocking registrations");
|
392
|
if(dto.isBlocked()){
|
393
|
blockingRegistrationButton.setEnabled(true);
|
394
|
blockingRegistrationButton.setDescription("This registration is currently blocked by other registrations");
|
395
|
blockingRegistrationButton.addStyleName(EditValoTheme.BUTTON_HIGHLITE);
|
396
|
blockingRegistrationButton.addClickListener(e -> getViewEventBus().publish(
|
397
|
this,
|
398
|
new ShowDetailsEvent<RegistrationDTO, UUID>(
|
399
|
e,
|
400
|
RegistrationDTO.class,
|
401
|
dto.getUuid(),
|
402
|
RegistrationItem.BLOCKED_BY
|
403
|
)
|
404
|
));
|
405
|
}
|
406
|
|
407
|
Button validationProblemsButton = regItemButtons.getValidationProblemsButton();
|
408
|
validationProblemsButton.setStyleName(ValoTheme.BUTTON_TINY); // + " " + RegistrationStyles.STYLE_FRIENDLY_FOREGROUND);
|
409
|
|
410
|
if(!dto.getValidationProblems().isEmpty()){
|
411
|
validationProblemsButton.setEnabled(true);
|
412
|
validationProblemsButton.addClickListener(e -> getViewEventBus().publish(this,
|
413
|
new ShowDetailsEvent<RegistrationDTO, UUID>(
|
414
|
e,
|
415
|
RegistrationDTO.class,
|
416
|
dto.getUuid(),
|
417
|
RegistrationItem.VALIDATION_PROBLEMS
|
418
|
)
|
419
|
)
|
420
|
);
|
421
|
}
|
422
|
validationProblemsButton.setCaption("<span class=\"" + RegistrationStyles.BUTTON_BADGE +"\"> " + dto.getValidationProblems().size() + "</span>");
|
423
|
validationProblemsButton.setCaptionAsHtml(true);
|
424
|
|
425
|
Button messageButton = regItemButtons.getMessagesButton();
|
426
|
messageButton.addClickListener(e -> getViewEventBus().publish(this,
|
427
|
new ShowDetailsEvent<RegistrationDTO, UUID>(
|
428
|
e,
|
429
|
RegistrationDTO.class,
|
430
|
dto.getUuid(),
|
431
|
RegistrationItem.MESSAGES
|
432
|
)
|
433
|
)
|
434
|
);
|
435
|
messageButton.setStyleName(ValoTheme.BUTTON_TINY);
|
436
|
|
437
|
Component statusComponent;
|
438
|
if(statusFieldInstantiator != null){
|
439
|
statusComponent = statusFieldInstantiator.create(dto);
|
440
|
} else {
|
441
|
statusComponent = new RegistrationStatusLabel().update(dto.getStatus());
|
442
|
}
|
443
|
Label submitterLabel = new Label(dto.getSubmitterUserName());
|
444
|
submitterLabel.setStyleName(LABEL_NOWRAP + " submitter");
|
445
|
submitterLabel.setIcon(FontAwesome.USER);
|
446
|
submitterLabel.setContentMode(ContentMode.HTML);
|
447
|
CssLayout stateAndSubmitter = new CssLayout(statusComponent, submitterLabel);
|
448
|
|
449
|
|
450
|
if(UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION)) || UserHelperAccess.userHelper().userIsAdmin()) {
|
451
|
Button editRegistrationButton = new Button(FontAwesome.COG);
|
452
|
editRegistrationButton.setStyleName(ValoTheme.BUTTON_TINY);
|
453
|
editRegistrationButton.setDescription("Edit registration");
|
454
|
editRegistrationButton.addClickListener(e -> getViewEventBus().publish(this, new RegistrationEditorAction(
|
455
|
EditorActionType.EDIT,
|
456
|
dto.getUuid(),
|
457
|
e.getButton(),
|
458
|
null,
|
459
|
this
|
460
|
)));
|
461
|
regItemButtons.addComponent(editRegistrationButton);
|
462
|
}
|
463
|
|
464
|
PermissionDebugUtils.addGainPerEntityPermissionButton(regItemButtons, Registration.class, dto.getUuid(),
|
465
|
EnumSet.of(CRUD.UPDATE), RegistrationStatus.PREPARATION.name());
|
466
|
|
467
|
row++;
|
468
|
registrationsGrid.addComponent(stateAndSubmitter, COL_INDEX_STATE_LABEL, row);
|
469
|
// registrationsGrid.setComponentAlignment(stateLabel, Alignment.TOP_LEFT);
|
470
|
registrationsGrid.addComponent(regItemButtonGroup, COL_INDEX_REG_ITEM, row);
|
471
|
registrationsGrid.addComponent(regItemButtons, COL_INDEX_BUTTON_GROUP, row);
|
472
|
registrationsGrid.setComponentAlignment(regItemButtons, Alignment.TOP_LEFT);
|
473
|
|
474
|
row++;
|
475
|
registrationsGrid.addComponent(footer, 0, row, COL_INDEX_BUTTON_GROUP, row);
|
476
|
|
477
|
return row;
|
478
|
}
|
479
|
|
480
|
/**
|
481
|
* @param button
|
482
|
* @param registrationEntityId
|
483
|
*
|
484
|
*/
|
485
|
@Override
|
486
|
public void chooseNewTypeRegistrationWorkingset(UUID registrationEntityUuid){
|
487
|
Window typeDesignationTypeCooser = new Window();
|
488
|
typeDesignationTypeCooser.setModal(true);
|
489
|
typeDesignationTypeCooser.setResizable(false);
|
490
|
typeDesignationTypeCooser.setCaption("Add new type designation");
|
491
|
Label label = new Label("Please select kind of type designation to be created.");
|
492
|
Button newSpecimenTypeDesignationButton = new Button("Specimen type designation",
|
493
|
e -> addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET, registrationEntityUuid, typeDesignationTypeCooser, e.getButton()));
|
494
|
Button newNameTypeDesignationButton = new Button("Name type designation",
|
495
|
e -> addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET, registrationEntityUuid, typeDesignationTypeCooser, e.getButton()));
|
496
|
|
497
|
VerticalLayout layout = new VerticalLayout(label, newSpecimenTypeDesignationButton, newNameTypeDesignationButton);
|
498
|
layout.setMargin(true);
|
499
|
layout.setSpacing(true);
|
500
|
layout.setComponentAlignment(newSpecimenTypeDesignationButton, Alignment.MIDDLE_CENTER);
|
501
|
layout.setComponentAlignment(newNameTypeDesignationButton, Alignment.MIDDLE_CENTER);
|
502
|
typeDesignationTypeCooser.setContent(layout);
|
503
|
UI.getCurrent().addWindow(typeDesignationTypeCooser);
|
504
|
}
|
505
|
|
506
|
/**
|
507
|
* @param button
|
508
|
*
|
509
|
*/
|
510
|
protected void addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType newWorkingsetType, UUID registrationEntityUuid, Window typeDesignationTypeCooser, Button sourceButton) {
|
511
|
UI.getCurrent().removeWindow(typeDesignationTypeCooser);
|
512
|
EntityReference typifiedNameRef = typifiedNamesMap.get(registrationEntityUuid);
|
513
|
getViewEventBus().publish(this, new TypeDesignationWorkingsetEditorAction(
|
514
|
newWorkingsetType,
|
515
|
registrationEntityUuid,
|
516
|
typifiedNameRef.getUuid(),
|
517
|
sourceButton,
|
518
|
null,
|
519
|
this
|
520
|
));
|
521
|
}
|
522
|
|
523
|
/**
|
524
|
* {@inheritDoc}
|
525
|
*/
|
526
|
@Override
|
527
|
public void openReferenceEditor(UUID referenceUuid) {
|
528
|
// TODO Auto-generated method stub
|
529
|
|
530
|
}
|
531
|
|
532
|
/**
|
533
|
* {@inheritDoc}
|
534
|
*/
|
535
|
@Override
|
536
|
public void openNameEditor(UUID nameUuid) {
|
537
|
// TODO Auto-generated method stub
|
538
|
|
539
|
}
|
540
|
|
541
|
/**
|
542
|
* {@inheritDoc}
|
543
|
*/
|
544
|
@Override
|
545
|
protected String getHeaderText() {
|
546
|
return headerText;
|
547
|
}
|
548
|
|
549
|
/**
|
550
|
* {@inheritDoc}
|
551
|
*/
|
552
|
@Override
|
553
|
public void setHeaderText(String text) {
|
554
|
this.headerText = text;
|
555
|
updateHeader();
|
556
|
|
557
|
}
|
558
|
|
559
|
/**
|
560
|
* @return the subheaderText
|
561
|
*/
|
562
|
public String getSubheaderText() {
|
563
|
return subheaderText;
|
564
|
}
|
565
|
|
566
|
/**
|
567
|
* {@inheritDoc}
|
568
|
*/
|
569
|
@Override
|
570
|
public void setSubheaderText(String text) {
|
571
|
subheaderText = text;
|
572
|
updateHeader();
|
573
|
}
|
574
|
|
575
|
/**
|
576
|
* {@inheritDoc}
|
577
|
*/
|
578
|
@Override
|
579
|
protected String getSubHeaderText() {
|
580
|
return subheaderText;
|
581
|
}
|
582
|
|
583
|
/**
|
584
|
* {@inheritDoc}
|
585
|
*/
|
586
|
@Override
|
587
|
public void openDetailsPopup(String caption, List<String> messages) {
|
588
|
StringBuffer sb = new StringBuffer();
|
589
|
sb.append("<div class=\"details-popup-content\">");
|
590
|
messages.forEach(s -> sb.append(s).append("</br>"));
|
591
|
sb.append("</div>");
|
592
|
new Notification(caption, sb.toString(), Notification.Type.HUMANIZED_MESSAGE, true).show(Page.getCurrent());
|
593
|
}
|
594
|
|
595
|
/**
|
596
|
* {@inheritDoc}
|
597
|
*/
|
598
|
@Override
|
599
|
public boolean allowAnonymousAccess() {
|
600
|
return false;
|
601
|
}
|
602
|
|
603
|
/**
|
604
|
* {@inheritDoc}
|
605
|
*/
|
606
|
@Override
|
607
|
public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
|
608
|
return null;
|
609
|
}
|
610
|
|
611
|
/**
|
612
|
* @return the addNewNameRegistrationButton
|
613
|
*/
|
614
|
@Override
|
615
|
public Button getAddNewNameRegistrationButton() {
|
616
|
return addNewNameRegistrationButton;
|
617
|
}
|
618
|
|
619
|
@Override
|
620
|
public Button getAddExistingNameRegistrationButton() {
|
621
|
return addExistingNameButton;
|
622
|
}
|
623
|
|
624
|
@Override
|
625
|
public LazyComboBox<TaxonName> getAddExistingNameCombobox() {
|
626
|
return existingNameCombobox;
|
627
|
}
|
628
|
|
629
|
/**
|
630
|
* @return the citationID
|
631
|
*/
|
632
|
@Override
|
633
|
public UUID getCitationUuid() {
|
634
|
return citationUuid;
|
635
|
}
|
636
|
|
637
|
@Override
|
638
|
public Map<UUID, RegistrationDetailsItem> getRegistrationItemMap(){
|
639
|
return Collections.unmodifiableMap(registrationItemMap);
|
640
|
}
|
641
|
|
642
|
|
643
|
/**
|
644
|
* @param statusFieldInstantiator the statusFieldInstantiator to set
|
645
|
*/
|
646
|
@Override
|
647
|
public void setStatusComponentInstantiator(RegistrationStatusFieldInstantiator statusComponentInstantiator) {
|
648
|
this.statusFieldInstantiator = statusComponentInstantiator;
|
649
|
}
|
650
|
|
651
|
|
652
|
}
|