Project

General

Profile

Download (25.8 KB) Statistics
| Branch: | Tag: | Revision:
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.BadgeButton;
61
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem;
62
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemButtons;
63
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemNameAndTypeButtons;
64
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemNameAndTypeButtons.TypeDesignationWorkingSetButton;
65
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemsPanel;
66
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStatusFieldInstantiator;
67
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStatusLabel;
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 GridLayout registrationsGrid;
116

    
117
    private RegistrationItem workingsetHeader;
118

    
119
    private Panel registrationListPanel;
120

    
121
    private Button addNewNameRegistrationButton;
122

    
123
    private Button addExistingNameButton;
124

    
125
    private LazyComboBox<TaxonName> existingNameCombobox;
126

    
127
    private Label existingNameRegistrationTypeLabel;
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
    private String accessDeniedMessage;
142

    
143
    private Object existingNameEditor;
144

    
145
    public RegistrationWorksetViewBean() {
146
        super();
147
    }
148

    
149

    
150
    /**
151
     * {@inheritDoc}
152
     */
153
    @Override
154
    protected void initContent() {
155
        getLayout().setId(NAME);
156
        updateHeader();
157
        // all content is added in createRegistrationsList()
158
    }
159

    
160

    
161
    /**
162
     * {@inheritDoc}
163
     */
164
    @Override
165
    public void enter(ViewChangeEvent event) {
166
        if(event.getParameters() != null){
167
            this.citationUuid = UUID.fromString(event.getParameters());
168

    
169
            getPresenter().handleViewEntered();
170
        }
171
    }
172

    
173
    /**
174
     * {@inheritDoc}
175
     */
176
    @Override
177
    public void setWorkingset(RegistrationWorkingSet workingset) {
178

    
179
        if(workingsetHeader != null){
180
            getLayout().removeComponent(workingsetHeader);
181
            getLayout().removeComponent(registrationListPanel);
182
        }
183
        workingsetHeader = new RegistrationItem(workingset, this, getPresenter().getCache());
184
        addContentComponent(workingsetHeader, null);
185

    
186
        registrationListPanel = createRegistrationsList(workingset);
187
        registrationListPanel.setHeight("100%");
188
        registrationListPanel.setStyleName("registration-list");
189
        registrationListPanel.setCaption("Registrations");
190
        addContentComponent(registrationListPanel, 1.0f);
191

    
192
    }
193

    
194
    @Override
195
    public void setBlockingRegistrations(UUID registrationUuid, Set<RegistrationDTO> blockingRegDTOs) {
196

    
197
        RegistrationDetailsItem regItem = registrationItemMap.get(registrationUuid);
198

    
199
        boolean blockingRegAdded = false;
200
        for(Iterator it = regItem.itemFooter.iterator(); it.hasNext(); ){
201
            if(it.next() instanceof RegistrationItemsPanel){
202
                blockingRegAdded = true;
203
                break;
204
            }
205
        }
206
        if(!blockingRegAdded){
207
            regItem.itemFooter.addComponent(new RegistrationItemsPanel(this, "Blocked by", blockingRegDTOs, getPresenter().getCache()));
208
        }
209
    }
210

    
211
    /**
212
     * {@inheritDoc}
213
     */
214
    @Override
215
    @Deprecated // no longer needed
216
    public void addBlockingRegistration(RegistrationDTO blocking) {
217
        if(registrations == null) {
218
            throw new RuntimeException("A Workingset must be present prior adding blocking registrations.");
219
        }
220
        // add the blocking registration
221

    
222
    }
223

    
224
    /**
225
     * @param workingset
226
     * @return
227
     */
228
    public Panel createRegistrationsList(RegistrationWorkingSet workingset) {
229

    
230
        registrationsGrid = new GridLayout(3, 1);
231
        registrationsGrid.setWidth("100%");
232
        // allow vertical scrolling:
233
        registrationsGrid.setHeightUndefined();
234

    
235
        //registrationsGrid.setColumnExpandRatio(0, 0.1f);
236
        registrationsGrid.setColumnExpandRatio(1, 1f);
237

    
238
        registrationItemMap.clear();
239
        registrationsGrid.setRows(workingset.getRegistrationDTOs().size() * 2  + 3);
240
        int row = 0;
241
        for(RegistrationDTO dto : workingset.getRegistrationDTOs()) {
242
            row = putRegistrationListComponent(row, dto);
243
        }
244

    
245
        // --- Footer with UI to create new registrations ----
246
        Label addRegistrationLabel_1 = new Label("Add a new registration for a");
247
        Label addRegistrationLabel_2 = new Label("or an");
248

    
249
        addNewNameRegistrationButton = new Button("new name");
250
        addNewNameRegistrationButton.setDescription("A name which is newly published in this publication.");
251
        Stack<EditorActionContext> context = new Stack<EditorActionContext>();
252
        context.push(new EditorActionContext(
253
                    new TypedEntityReference<>(Registration.class, null),
254
                    this)
255
                    );
256
        addNewNameRegistrationButton.addClickListener(
257
                e -> {
258
                    getViewEventBus().publish(this, new TaxonNameEditorAction(EditorActionType.ADD, null, addNewNameRegistrationButton, null, this, context));
259

    
260
                }
261
        );
262

    
263
        existingNameRegistrationTypeLabel = new Label();
264
        addExistingNameButton = new Button("existing name:");
265
        addExistingNameButton.setEnabled(false);
266
        addExistingNameButton.addClickListener(e -> reviewExistingName());
267

    
268
        existingNameCombobox = new LazyComboBox<TaxonName>(TaxonName.class);
269
        existingNameCombobox.addValueChangeListener(
270
                e -> {
271
                    boolean selectionNotEmpty = e.getProperty().getValue() != null;
272
                    addExistingNameButton.setEnabled(false);
273
                    existingNameRegistrationTypeLabel.setValue(null);
274
                    if(selectionNotEmpty){
275
                        TaxonName name = (TaxonName)e.getProperty().getValue();
276
                        if(getPresenter().canCreateNameRegistrationFor(name)){
277
                            existingNameRegistrationTypeLabel.setValue(TEXT_NAME_TYPIFICATION);
278
                            addExistingNameButton.setEnabled(true);
279
                        } else {
280
                            if(!getPresenter().checkWokingsetContainsProtologe(name)){
281
                                existingNameRegistrationTypeLabel.setValue(TEXT_TYPIFICATION_ONLY);
282
                                addExistingNameButton.setEnabled(true);
283
                            }
284
                        }
285
                    } else {
286
                        existingNameRegistrationTypeLabel.setValue(null);
287
                    }
288
                }
289
                );
290

    
291
        HorizontalLayout buttonContainer = new HorizontalLayout(
292
                addRegistrationLabel_1,
293
                addNewNameRegistrationButton,
294
                addRegistrationLabel_2,
295
                addExistingNameButton,
296
                existingNameCombobox,
297
                existingNameRegistrationTypeLabel
298
                );
299
        buttonContainer.setSpacing(true);
300
//        buttonContainer.setWidth(100, Unit.PERCENTAGE);
301
        buttonContainer.setComponentAlignment(addRegistrationLabel_1, Alignment.MIDDLE_LEFT);
302
        buttonContainer.setComponentAlignment(addRegistrationLabel_2, Alignment.MIDDLE_LEFT);
303

    
304
        row++;
305
        registrationsGrid.addComponent(buttonContainer, 0, row, COL_INDEX_BUTTON_GROUP, row);
306
        registrationsGrid.setComponentAlignment(buttonContainer, Alignment.MIDDLE_RIGHT);
307

    
308
        row++;
309
        Label hint = new Label(
310
                "For most names that already exist in the system, it is only possible to create a registration covering type designations. "
311
                + "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.",
312
                ContentMode.HTML);
313
        registrationsGrid.addComponent(hint, 0, row, COL_INDEX_BUTTON_GROUP, row);
314
        registrationsGrid.setComponentAlignment(hint, Alignment.MIDDLE_RIGHT);
315

    
316
        Panel namesTypesPanel = new Panel(registrationsGrid);
317
        namesTypesPanel.setStyleName(EditValoTheme.PANEL_CONTENT_PADDING_LEFT);
318
        return namesTypesPanel;
319
    }
320

    
321
    private void reviewExistingName() {
322
        // call commit to make the selection available
323
        existingNameCombobox.commit();
324
        UUID uuid = existingNameCombobox.getValue().getUuid();
325
        Stack<EditorActionContext> context = new Stack<EditorActionContext>();
326
        context.push(new EditorActionContext(
327
                    new TypedEntityReference<>(TaxonName.class, uuid),
328
                    this)
329
                    );
330
        getViewEventBus().publish(
331
                this,
332
                new TaxonNameEditorAction(
333
                        EditorActionType.EDIT,
334
                        uuid,
335
                        addExistingNameButton,
336
                        existingNameCombobox,
337
                        this,
338
                        context)
339
        );
340

    
341
    }
342

    
343
    /**
344
     * publishes an event to the {@link RegistrationWorkingsetPresenter}
345
     * @deprecated no longer used but kept for reference
346
     * TODO remove for version 5.8 when not used again.
347
     */
348
    @Deprecated
349
    private void triggerRegistrationForExistingName() {
350
        getViewEventBus().publish(this, new RegistrationWorkingsetAction(
351
                citationUuid,
352
                RegistrationWorkingsetAction.Action.start
353
                )
354
        );
355
    }
356

    
357

    
358
    protected int putRegistrationListComponent(int row, RegistrationDTO dto) {
359

    
360
        EntityReference typifiedNameReference = dto.getTypifiedNameRef();
361
        if(typifiedNameReference == null){
362
            typifiedNameReference = dto.getNameRef();
363
        }
364
        typifiedNamesMap.put(dto.getUuid(), typifiedNameReference);
365

    
366
        RegistrationItemNameAndTypeButtons regItemButtonGroup = new RegistrationItemNameAndTypeButtons(dto, getPresenter().getCache());
367
        UUID registrationEntityUuid = dto.getUuid();
368

    
369
        RegistrationItemButtons regItemButtons = new RegistrationItemButtons();
370

    
371
        CssLayout footer = new CssLayout();
372
        footer.setWidth(100, Unit.PERCENTAGE);
373
        footer.setStyleName("item-footer");
374

    
375
        RegistrationDetailsItem regDetailsItem = new RegistrationDetailsItem(regItemButtonGroup, regItemButtons, footer);
376
        registrationItemMap.put(registrationEntityUuid, regDetailsItem);
377

    
378
        Stack<EditorActionContext> context = new Stack<EditorActionContext>();
379
        context.push(new EditorActionContext(
380
                    new TypedEntityReference<>(Registration.class, registrationEntityUuid),
381
                    this)
382
                    );
383

    
384
        if(regItemButtonGroup.getNameButton() != null){
385
            regItemButtonGroup.getNameButton().getButton().addClickListener(e -> {
386
                UUID nameuUuid = regItemButtonGroup.getNameButton().getUuid();
387
                getViewEventBus().publish(this, new TaxonNameEditorAction(
388
                    EditorActionType.EDIT,
389
                    nameuUuid,
390
                    e.getButton(),
391
                    null,
392
                    this,
393
                    context
394
                    )
395
                );
396
            });
397
        }
398

    
399
        for(TypeDesignationWorkingSetButton workingsetButton : regItemButtonGroup.getTypeDesignationButtons()){
400
            workingsetButton.getButton().addClickListener(e -> {
401
                TypedEntityReference baseEntityRef = workingsetButton.getBaseEntity();
402
                EntityReference typifiedNameRef = typifiedNamesMap.get(registrationEntityUuid);
403
                TypeDesignationWorkingSetType workingsetType = workingsetButton.getType();
404
                getViewEventBus().publish(this, new TypeDesignationWorkingsetEditorAction(
405
                        baseEntityRef,
406
                        workingsetType,
407
                        registrationEntityUuid,
408
                        typifiedNameRef.getUuid(),
409
                        e.getButton(),
410
                        null,
411
                        this,
412
                        context
413
                        )
414
                    );
415
            });
416
        }
417

    
418
        regItemButtonGroup.getAddTypeDesignationButton().addClickListener(
419
                e -> chooseNewTypeRegistrationWorkingset(dto.getUuid())
420
                );
421

    
422

    
423
        Button blockingRegistrationButton = regItemButtons.getBlockingRegistrationButton();
424
        blockingRegistrationButton.setStyleName(ValoTheme.BUTTON_TINY);
425
        blockingRegistrationButton.setDescription("No blocking registrations");
426
        if(dto.isBlocked()){
427
            blockingRegistrationButton.setEnabled(true);
428
            blockingRegistrationButton.setDescription("This registration is currently blocked by other registrations");
429
            blockingRegistrationButton.addStyleName(EditValoTheme.BUTTON_HIGHLITE);
430
            blockingRegistrationButton.addClickListener(e -> getViewEventBus().publish(
431
                    this,
432
                    new ShowDetailsEvent<RegistrationDTO, UUID>(
433
                            e,
434
                            RegistrationDTO.class,
435
                            dto.getUuid(),
436
                            RegistrationItem.BLOCKED_BY
437
                            )
438
                    ));
439
        }
440

    
441
        BadgeButton validationProblemsButton = regItemButtons.getValidationProblemsButton();
442
        validationProblemsButton.setStyleName(ValoTheme.BUTTON_TINY); //  + " " + RegistrationStyles.STYLE_FRIENDLY_FOREGROUND);
443

    
444
        if(!dto.getValidationProblems().isEmpty()){
445
            validationProblemsButton.setEnabled(true);
446
            validationProblemsButton.addClickListener(e -> getViewEventBus().publish(this,
447
                    new ShowDetailsEvent<RegistrationDTO, UUID>(
448
                        e,
449
                        RegistrationDTO.class,
450
                        dto.getUuid(),
451
                        RegistrationItem.VALIDATION_PROBLEMS
452
                        )
453
                    )
454
                );
455
        }
456
        int problemCount = dto.getValidationProblems().size();
457
        validationProblemsButton.setCaption(problemCount > 0 ? Integer.toString(problemCount) : null);
458

    
459
        Component statusComponent;
460
        if(statusFieldInstantiator != null){
461
            statusComponent = statusFieldInstantiator.create(dto);
462
        } else {
463
            statusComponent = new RegistrationStatusLabel().update(dto.getStatus());
464
        }
465
        Label submitterLabel = new Label(dto.getSubmitterUserName());
466
        submitterLabel.setStyleName(LABEL_NOWRAP + " submitter");
467
        submitterLabel.setIcon(FontAwesome.USER);
468
        submitterLabel.setContentMode(ContentMode.HTML);
469
        CssLayout stateAndSubmitter = new CssLayout(statusComponent, submitterLabel);
470

    
471

    
472
        if(UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION)) || UserHelperAccess.userHelper().userIsAdmin()) {
473

    
474
            Button editRegistrationButton = new Button(FontAwesome.COG);
475
            editRegistrationButton.setStyleName(ValoTheme.BUTTON_TINY);
476
            editRegistrationButton.setDescription("Edit registration");
477
            editRegistrationButton.addClickListener(e -> getViewEventBus().publish(this, new RegistrationEditorAction(
478
                EditorActionType.EDIT,
479
                dto.getUuid(),
480
                e.getButton(),
481
                null,
482
                this
483
                )));
484

    
485
            Button unlockButton = new Button(FontAwesome.LOCK);
486
            unlockButton.setStyleName(ValoTheme.BUTTON_TINY);
487
            unlockButton.setDescription("Unlock");
488
            unlockButton.addClickListener(e -> {
489
                regItemButtonGroup.setLockOverride(!regItemButtonGroup.isLockOverride());
490
                if(regItemButtonGroup.isRegistrationLocked()){
491
                    unlockButton.setIcon(regItemButtonGroup.isLockOverride() ? FontAwesome.UNLOCK_ALT : FontAwesome.LOCK);
492
                    unlockButton.setDescription(regItemButtonGroup.isLockOverride() ? "Click to unlock editing" : "Click to lock editing");
493
                }
494
            });
495
            unlockButton.setEnabled(regItemButtonGroup.isRegistrationLocked());
496
            regItemButtons.addComponents(unlockButton, editRegistrationButton);
497
        }
498

    
499
        PermissionDebugUtils.addGainPerEntityPermissionButton(regItemButtons, Registration.class, dto.getUuid(),
500
                EnumSet.of(CRUD.UPDATE), RegistrationStatus.PREPARATION.name());
501

    
502
        row++;
503
        registrationsGrid.addComponent(stateAndSubmitter, COL_INDEX_STATE_LABEL, row);
504
        // registrationsGrid.setComponentAlignment(stateLabel, Alignment.TOP_LEFT);
505
        registrationsGrid.addComponent(regItemButtonGroup, COL_INDEX_REG_ITEM, row);
506
        registrationsGrid.addComponent(regItemButtons, COL_INDEX_BUTTON_GROUP, row);
507
        registrationsGrid.setComponentAlignment(regItemButtons, Alignment.TOP_LEFT);
508

    
509
        row++;
510
        registrationsGrid.addComponent(footer, 0, row, COL_INDEX_BUTTON_GROUP, row);
511

    
512
        return row;
513
    }
514

    
515
    /**
516
     * @param button
517
     * @param registrationEntityId
518
     *
519
     */
520
    @Override
521
    public void chooseNewTypeRegistrationWorkingset(UUID registrationEntityUuid){
522
        Window typeDesignationTypeCooser = new Window();
523
        typeDesignationTypeCooser.setModal(true);
524
        typeDesignationTypeCooser.setResizable(false);
525
        typeDesignationTypeCooser.setCaption("Add new type designation");
526
        Label label = new Label("Please select kind of type designation to be created.");
527
        Button newSpecimenTypeDesignationButton = new Button("Specimen type designation",
528
                e -> addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET, registrationEntityUuid, typeDesignationTypeCooser, e.getButton()));
529
        Button newNameTypeDesignationButton = new Button("Name type designation",
530
                e -> addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET, registrationEntityUuid, typeDesignationTypeCooser, e.getButton()));
531

    
532
        VerticalLayout layout = new VerticalLayout(label, newSpecimenTypeDesignationButton, newNameTypeDesignationButton);
533
        layout.setMargin(true);
534
        layout.setSpacing(true);
535
        layout.setComponentAlignment(newSpecimenTypeDesignationButton, Alignment.MIDDLE_CENTER);
536
        layout.setComponentAlignment(newNameTypeDesignationButton, Alignment.MIDDLE_CENTER);
537
        typeDesignationTypeCooser.setContent(layout);
538
        UI.getCurrent().addWindow(typeDesignationTypeCooser);
539
    }
540

    
541
    /**
542
     * @param button
543
     *
544
     */
545
    protected void addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType newWorkingsetType, UUID registrationEntityUuid, Window typeDesignationTypeCooser, Button sourceButton) {
546
        UI.getCurrent().removeWindow(typeDesignationTypeCooser);
547
        EntityReference typifiedNameRef = typifiedNamesMap.get(registrationEntityUuid);
548
        getViewEventBus().publish(this, new TypeDesignationWorkingsetEditorAction(
549
                newWorkingsetType,
550
                registrationEntityUuid,
551
                typifiedNameRef.getUuid(),
552
                sourceButton,
553
                null,
554
                this
555
                ));
556
    }
557

    
558
    /**
559
     * {@inheritDoc}
560
     */
561
    @Override
562
    public void openReferenceEditor(UUID referenceUuid) {
563
        // TODO Auto-generated method stub
564

    
565
    }
566

    
567
    /**
568
     * {@inheritDoc}
569
     */
570
    @Override
571
    public void openNameEditor(UUID nameUuid) {
572
        // TODO Auto-generated method stub
573

    
574
    }
575

    
576
    /**
577
     * {@inheritDoc}
578
     */
579
    @Override
580
    protected String getHeaderText() {
581
        return headerText;
582
    }
583

    
584
    /**
585
     * {@inheritDoc}
586
     */
587
    @Override
588
    public void setHeaderText(String text) {
589
        this.headerText = text;
590
        updateHeader();
591

    
592
    }
593

    
594
    /**
595
     * @return the subheaderText
596
     */
597
    public String getSubheaderText() {
598
        return subheaderText;
599
    }
600

    
601
    /**
602
     * {@inheritDoc}
603
     */
604
    @Override
605
    public void setSubheaderText(String text) {
606
        subheaderText = text;
607
        updateHeader();
608
    }
609

    
610
    /**
611
     * {@inheritDoc}
612
     */
613
    @Override
614
    protected String getSubHeaderText() {
615
        return subheaderText;
616
    }
617

    
618
    /**
619
     * {@inheritDoc}
620
     */
621
    @Override
622
    public void openDetailsPopup(String caption, List<String> messages) {
623
        StringBuffer sb = new StringBuffer();
624
        sb.append("<div class=\"details-popup-content\">");
625
        messages.forEach(s -> sb.append(s).append("</br>"));
626
        sb.append("</div>");
627
        new Notification(caption, sb.toString(), Notification.Type.HUMANIZED_MESSAGE, true).show(Page.getCurrent());
628
    }
629

    
630
    @Override
631
    public boolean allowAnonymousAccess() {
632
        return false;
633
    }
634

    
635
    @Override
636
    public Collection<Collection<GrantedAuthority>> allowedGrantedAuthorities() {
637
        return null;
638
    }
639

    
640
    @Override
641
    public String getAccessDeniedMessage() {
642
        return accessDeniedMessage;
643
    }
644

    
645
    @Override
646
    public void setAccessDeniedMessage(String accessDeniedMessage) {
647
        this.accessDeniedMessage = accessDeniedMessage;
648
    }
649

    
650
    /**
651
     * @return the addNewNameRegistrationButton
652
     */
653
    @Override
654
    public Button getAddNewNameRegistrationButton() {
655
        return addNewNameRegistrationButton;
656
    }
657

    
658
    @Override
659
    public Button getAddExistingNameRegistrationButton() {
660
        return addExistingNameButton;
661
    }
662

    
663
    @Override
664
    public LazyComboBox<TaxonName> getAddExistingNameCombobox() {
665
        return existingNameCombobox;
666
    }
667

    
668
    /**
669
     * @return the citationID
670
     */
671
    @Override
672
    public UUID getCitationUuid() {
673
        return citationUuid;
674
    }
675

    
676
    @Override
677
    public Map<UUID, RegistrationDetailsItem> getRegistrationItemMap(){
678
        return Collections.unmodifiableMap(registrationItemMap);
679
    }
680

    
681

    
682
    /**
683
     * @param statusFieldInstantiator the statusFieldInstantiator to set
684
     */
685
    @Override
686
    public void setStatusComponentInstantiator(RegistrationStatusFieldInstantiator statusComponentInstantiator) {
687
        this.statusFieldInstantiator = statusComponentInstantiator;
688
    }
689

    
690

    
691
}
(12-12/18)