Revision 0d0aa9f1
Added by Andreas Kohlbecker over 4 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/ui/RegistrationUIDefaults.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 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.ui; |
|
10 |
|
|
11 |
import java.util.EnumSet; |
|
12 |
|
|
13 |
import eu.etaxonomy.cdm.model.reference.ReferenceType; |
|
14 |
|
|
15 |
/** |
|
16 |
* @author a.kohlbecker |
|
17 |
* @since Jan 12, 2018 |
|
18 |
* |
|
19 |
*/ |
|
20 |
public class RegistrationUIDefaults { |
|
21 |
|
|
22 |
public static final EnumSet<ReferenceType> REFERENCE_TYPES = EnumSet.of( |
|
23 |
ReferenceType.Article, |
|
24 |
ReferenceType.Book, |
|
25 |
ReferenceType.InProceedings, |
|
26 |
ReferenceType.Journal, |
|
27 |
ReferenceType.PrintSeries, |
|
28 |
ReferenceType.Proceedings, |
|
29 |
ReferenceType.Section, |
|
30 |
ReferenceType.Thesis); |
|
31 |
|
|
32 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java | ||
---|---|---|
255 | 255 |
} |
256 | 256 |
} |
257 | 257 |
|
258 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT") |
|
259 |
public void onReferenceEditorActionEdit(ReferenceEditorAction event) { |
|
260 |
|
|
261 |
if(getView() == null || event.getSourceView() != getView() ){ |
|
262 |
return; |
|
263 |
} |
|
264 |
newReferencePopup = getNavigationManager().showInPopup(ReferencePopupEditor.class); |
|
265 |
|
|
266 |
newReferencePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE)); |
|
267 |
newReferencePopup.withDeleteButton(true); |
|
268 |
newReferencePopup.setBeanInstantiator(newReferenceInstantiator); |
|
269 |
newReferencePopup.loadInEditor(event.getEntityId()); |
|
270 |
if(newReferenceInstantiator != null){ |
|
271 |
// this is a bit clumsy, we actually need to inject something like a view configurer |
|
272 |
// which can enable, disable fields |
|
273 |
newReferencePopup.getInReferenceCombobox().setEnabled(false); |
|
274 |
newReferencePopup.getTypeSelect().setEnabled(false); |
|
275 |
} |
|
276 |
} |
|
277 |
|
|
258 | 278 |
@EventListener |
259 | 279 |
public void onDoneWithPopupEvent(DoneWithPopupEvent event){ |
260 | 280 |
if(event.getPopup() == newReferencePopup){ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditor.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.reference; |
10 | 10 |
|
11 |
import java.util.Arrays; |
|
12 | 11 |
import java.util.Collection; |
12 |
import java.util.EnumSet; |
|
13 | 13 |
|
14 | 14 |
import org.springframework.security.core.GrantedAuthority; |
15 | 15 |
|
... | ... | |
50 | 50 |
|
51 | 51 |
private TeamOrPersonField authorshipField; |
52 | 52 |
|
53 |
private EnumSet<ReferenceType> referenceTypes = EnumSet.allOf(ReferenceType.class); |
|
54 |
|
|
53 | 55 |
/** |
54 | 56 |
* @param layout |
55 | 57 |
* @param dtoType |
... | ... | |
91 | 93 |
"inReference" |
92 | 94 |
*/ |
93 | 95 |
int row = 0; |
94 |
typeSelect = new ListSelect("Reference type", Arrays.asList(ReferenceType.values())); |
|
96 |
typeSelect = new ListSelect("Reference type"); |
|
97 |
typeSelect.addItems(referenceTypes); |
|
95 | 98 |
typeSelect.setNullSelectionAllowed(false); |
96 | 99 |
typeSelect.setRows(1); |
97 | 100 |
typeSelect.addValueChangeListener(e -> updateFieldVisibility((ReferenceType)e.getProperty().getValue())); |
... | ... | |
107 | 110 |
titleField = addTextField("Title", "title", 0, row, GRID_COLS-1, row); |
108 | 111 |
titleField.setWidth(100, Unit.PERCENTAGE); |
109 | 112 |
row++; |
110 |
addTextField("NomenclaturalTitle", "abbrevTitle", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
|
|
113 |
addTextField("Nomenclatural title", "abbrevTitle", 0, row, GRID_COLS-1, row).setWidth(100, Unit.PERCENTAGE);
|
|
111 | 114 |
row++; |
112 | 115 |
authorshipField = new TeamOrPersonField("Author(s)"); |
113 | 116 |
authorshipField.setWidth(100, Unit.PERCENTAGE); |
... | ... | |
246 | 249 |
return authorshipField; |
247 | 250 |
} |
248 | 251 |
|
252 |
public void withReferenceTypes(EnumSet<ReferenceType> types){ |
|
253 |
this.referenceTypes = types; |
|
254 |
if(typeSelect != null){ |
|
255 |
typeSelect.removeAllItems(); |
|
256 |
typeSelect.addItems(referenceTypes); |
|
257 |
} |
|
258 |
} |
|
259 |
|
|
249 | 260 |
|
250 | 261 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationPresenter.java | ||
---|---|---|
20 | 20 |
|
21 | 21 |
import eu.etaxonomy.cdm.api.service.DeleteResult; |
22 | 22 |
import eu.etaxonomy.cdm.model.reference.Reference; |
23 |
import eu.etaxonomy.cdm.model.reference.ReferenceType; |
|
23 | 24 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
24 | 25 |
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider; |
25 | 26 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
26 | 27 |
import eu.etaxonomy.cdm.vaadin.event.RegistrationEditorAction; |
28 |
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults; |
|
27 | 29 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
28 | 30 |
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor; |
29 | 31 |
import eu.etaxonomy.vaadin.mvp.AbstractEditorPresenter; |
... | ... | |
86 | 88 |
return; |
87 | 89 |
} |
88 | 90 |
newReferencePopup = getNavigationManager().showInPopup(ReferencePopupEditor.class); |
89 |
|
|
91 |
EnumSet<ReferenceType> refTypes = RegistrationUIDefaults.REFERENCE_TYPES.clone(); |
|
92 |
refTypes.remove(ReferenceType.Section); |
|
93 |
newReferencePopup.withReferenceTypes(refTypes); |
|
90 | 94 |
newReferencePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE)); |
91 | 95 |
newReferencePopup.withDeleteButton(true); |
92 | 96 |
newReferencePopup.loadInEditor(null); |
Also available in: Unified diff
fix #7172 default ReferenceTypes for the registrationUI and disallowing section in StartRegistrationPresenter