Revision 1ff11053
Added by Andreas Kohlbecker almost 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkflowViewBean.java | ||
---|---|---|
14 | 14 |
import java.util.UUID; |
15 | 15 |
|
16 | 16 |
import org.springframework.security.core.GrantedAuthority; |
17 |
import org.vaadin.viritin.fields.LazyComboBox; |
|
17 | 18 |
|
18 | 19 |
import com.vaadin.navigator.View; |
19 | 20 |
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; |
... | ... | |
37 | 38 |
import com.vaadin.ui.Window; |
38 | 39 |
import com.vaadin.ui.themes.ValoTheme; |
39 | 40 |
|
41 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
40 | 42 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem; |
41 | 43 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemEditButtonGroup; |
42 | 44 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemEditButtonGroup.TypeDesignationWorkingSetButton; |
... | ... | |
50 | 52 |
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent; |
51 | 53 |
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction; |
52 | 54 |
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction; |
55 |
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkflowEvent; |
|
53 | 56 |
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet; |
54 | 57 |
import eu.etaxonomy.cdm.vaadin.model.registration.WorkflowStep; |
55 | 58 |
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView; |
... | ... | |
92 | 95 |
|
93 | 96 |
private Button addNewNameRegistrationButton; |
94 | 97 |
|
95 |
private Button addExistingNameRegistrationButton; |
|
98 |
private LazyComboBox<TaxonName> existingNameCombobox; |
|
99 |
|
|
100 |
// private Button addExistingNameRegistrationButton; |
|
96 | 101 |
|
97 | 102 |
private GridLayout registrationsGrid; |
98 | 103 |
|
104 |
private Button addExistingNameButton; |
|
105 |
|
|
99 | 106 |
public RegistrationWorkflowViewBean() { |
100 | 107 |
super(); |
101 | 108 |
} |
... | ... | |
205 | 212 |
} |
206 | 213 |
|
207 | 214 |
|
208 |
Label addRegistrationLabel = new Label("Add a registration for a"); |
|
215 |
Label addRegistrationLabel_1 = new Label("Add a new registration for a"); |
|
216 |
Label addRegistrationLabel_2 = new Label("or an"); |
|
209 | 217 |
|
210 | 218 |
addNewNameRegistrationButton = new Button("new name"); |
211 | 219 |
addNewNameRegistrationButton.setDescription("A name which is newly published in this publication."); |
212 |
addNewNameRegistrationButton.addClickListener(e -> eventBus.publishEvent(new TaxonNameEditorAction(Action.ADD, addNewNameRegistrationButton))); |
|
220 |
addNewNameRegistrationButton.addClickListener( |
|
221 |
e -> eventBus.publishEvent(new TaxonNameEditorAction(Action.ADD, addNewNameRegistrationButton)) |
|
222 |
); |
|
213 | 223 |
|
214 |
addExistingNameRegistrationButton = new Button("existing name"); |
|
215 |
addExistingNameRegistrationButton.setDescription("A name which was previously published in a earlier publication."); |
|
224 |
addExistingNameButton = new Button("existing name:"); |
|
225 |
addExistingNameButton.setDescription("A name which was previously published in a earlier publication."); |
|
226 |
addExistingNameButton.setEnabled(false); |
|
227 |
addExistingNameButton.addClickListener( |
|
228 |
e -> eventBus.publishEvent(new RegistrationWorkflowEvent(citationID, RegistrationWorkflowEvent.Action.start)) |
|
229 |
); |
|
216 | 230 |
|
231 |
existingNameCombobox = new LazyComboBox<TaxonName>(TaxonName.class); |
|
232 |
existingNameCombobox.addValueChangeListener( |
|
233 |
e -> addExistingNameButton.setEnabled(e.getProperty().getValue() != null) |
|
234 |
); |
|
217 | 235 |
|
218 |
HorizontalLayout buttonContainer = new HorizontalLayout(addRegistrationLabel, addNewNameRegistrationButton, addExistingNameRegistrationButton);
|
|
236 |
HorizontalLayout buttonContainer = new HorizontalLayout(addRegistrationLabel_1, addNewNameRegistrationButton, addRegistrationLabel_2, addExistingNameButton, existingNameCombobox);
|
|
219 | 237 |
buttonContainer.setSpacing(true); |
220 | 238 |
buttonContainer.setWidth(100, Unit.PERCENTAGE); |
221 |
buttonContainer.setComponentAlignment(addRegistrationLabel, Alignment.MIDDLE_LEFT); |
|
239 |
buttonContainer.setComponentAlignment(addRegistrationLabel_1, Alignment.MIDDLE_LEFT); |
|
240 |
buttonContainer.setComponentAlignment(addRegistrationLabel_2, Alignment.MIDDLE_LEFT); |
|
222 | 241 |
registrationsGrid.addComponent(buttonContainer, 1, row, 1, row); |
223 | 242 |
|
224 | 243 |
Panel namesTypesPanel = new Panel(registrationsGrid); |
... | ... | |
312 | 331 |
Component regItem; |
313 | 332 |
if(REG_ITEM_AS_BUTTON_GROUP){ |
314 | 333 |
RegistrationItemEditButtonGroup editButtonGroup = new RegistrationItemEditButtonGroup(dto); |
315 |
if(editButtonGroup.getNameButton() != null){ |
|
316 | 334 |
|
335 |
if(editButtonGroup.getNameButton() != null){ |
|
317 | 336 |
editButtonGroup.getNameButton().getButton().addClickListener(e -> { |
318 | 337 |
Integer nameId = editButtonGroup.getNameButton().getId(); |
319 | 338 |
getEventBus().publishEvent(new TaxonNameEditorAction( |
... | ... | |
324 | 343 |
) |
325 | 344 |
); |
326 | 345 |
}); |
346 |
} |
|
327 | 347 |
|
328 |
for(TypeDesignationWorkingSetButton workingsetButton : editButtonGroup.getTypeDesignationButtons()){ |
|
329 |
workingsetButton.getButton().addClickListener(e -> { |
|
330 |
Integer typeDesignationWorkingsetId = workingsetButton.getId(); |
|
331 |
TypeDesignationWorkingSetType workingsetType = workingsetButton.getType(); |
|
332 |
Integer registrationEntityID = dto.getId(); |
|
333 |
getEventBus().publishEvent(new TypeDesignationWorkingsetEditorAction( |
|
334 |
AbstractEditorAction.Action.EDIT, |
|
335 |
typeDesignationWorkingsetId, |
|
336 |
workingsetType, |
|
337 |
registrationEntityID, |
|
338 |
null, //e.getButton(), the listener method expects this to be null |
|
339 |
this |
|
340 |
) |
|
341 |
); |
|
342 |
}); |
|
343 |
} |
|
344 |
|
|
345 |
editButtonGroup.getAddTypeDesignationButton().addClickListener( |
|
346 |
e -> chooseNewTypeRegistrationWorkingset(e.getButton(), dto.getId()) |
|
348 |
for(TypeDesignationWorkingSetButton workingsetButton : editButtonGroup.getTypeDesignationButtons()){ |
|
349 |
workingsetButton.getButton().addClickListener(e -> { |
|
350 |
Integer typeDesignationWorkingsetId = workingsetButton.getId(); |
|
351 |
TypeDesignationWorkingSetType workingsetType = workingsetButton.getType(); |
|
352 |
Integer registrationEntityID = dto.getId(); |
|
353 |
getEventBus().publishEvent(new TypeDesignationWorkingsetEditorAction( |
|
354 |
AbstractEditorAction.Action.EDIT, |
|
355 |
typeDesignationWorkingsetId, |
|
356 |
workingsetType, |
|
357 |
registrationEntityID, |
|
358 |
null, //e.getButton(), the listener method expects this to be null |
|
359 |
this |
|
360 |
) |
|
347 | 361 |
); |
362 |
}); |
|
348 | 363 |
} |
364 |
|
|
365 |
editButtonGroup.getAddTypeDesignationButton().addClickListener( |
|
366 |
e -> chooseNewTypeRegistrationWorkingset(dto.getId()) |
|
367 |
); |
|
349 | 368 |
regItem = editButtonGroup; |
350 | 369 |
} else { |
351 | 370 |
regItem = new Label(dto.getSummary()); |
... | ... | |
363 | 382 |
* @param registrationEntityId |
364 | 383 |
* |
365 | 384 |
*/ |
366 |
protected void chooseNewTypeRegistrationWorkingset(Button button, Integer registrationEntityId) { |
|
385 |
@Override |
|
386 |
public void chooseNewTypeRegistrationWorkingset(Integer registrationEntityId) { |
|
367 | 387 |
|
368 | 388 |
Window typeDesignationTypeCooser = new Window(); |
369 | 389 |
typeDesignationTypeCooser.setModal(true); |
... | ... | |
371 | 391 |
typeDesignationTypeCooser.setCaption("Add new type designation"); |
372 | 392 |
Label label = new Label("Please select kind of type designation to be created."); |
373 | 393 |
Button newSpecimenTypeDesignationButton = new Button("Specimen type designation", |
374 |
e -> addNewTypeRegistrationWorkingset(TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET, registrationEntityId, typeDesignationTypeCooser));
|
|
394 |
e -> addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET, registrationEntityId, typeDesignationTypeCooser));
|
|
375 | 395 |
Button newNameTypeDesignationButton = new Button("Name type designation", |
376 |
e -> addNewTypeRegistrationWorkingset(TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET, registrationEntityId, typeDesignationTypeCooser));
|
|
396 |
e -> addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType.NAME_TYPE_DESIGNATION_WORKINGSET, registrationEntityId, typeDesignationTypeCooser));
|
|
377 | 397 |
newNameTypeDesignationButton.setEnabled(false); |
378 | 398 |
|
379 | 399 |
VerticalLayout layout = new VerticalLayout(label, newSpecimenTypeDesignationButton, newNameTypeDesignationButton); |
... | ... | |
389 | 409 |
* @param button |
390 | 410 |
* |
391 | 411 |
*/ |
392 |
protected void addNewTypeRegistrationWorkingset(TypeDesignationWorkingSetType newWorkingsetType, Integer registrationEntityId, Window typeDesignationTypeCooser) {
|
|
412 |
protected void addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType newWorkingsetType, Integer registrationEntityId, Window typeDesignationTypeCooser) {
|
|
393 | 413 |
UI.getCurrent().removeWindow(typeDesignationTypeCooser); |
394 | 414 |
getEventBus().publishEvent(new TypeDesignationWorkingsetEditorAction( |
395 | 415 |
AbstractEditorAction.Action.ADD, |
... | ... | |
533 | 553 |
return addNewNameRegistrationButton; |
534 | 554 |
} |
535 | 555 |
|
536 |
/** |
|
537 |
* @return the addExistingNameRegistrationButton |
|
538 |
*/ |
|
539 | 556 |
@Override |
540 | 557 |
public Button getAddExistingNameRegistrationButton() { |
541 |
return addExistingNameRegistrationButton; |
|
558 |
return addExistingNameButton; |
|
559 |
} |
|
560 |
|
|
561 |
@Override |
|
562 |
public LazyComboBox<TaxonName> getAddExistingNameCombobox() { |
|
563 |
return existingNameCombobox; |
|
542 | 564 |
} |
543 | 565 |
|
544 | 566 |
/** |
Also available in: Unified diff
ref #6169 feature completed: adding new type designation workingsets