Revision f393241e
Added by Andreas Kohlbecker over 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItem.java | ||
---|---|---|
34 | 34 |
import eu.etaxonomy.cdm.model.name.RegistrationStatus; |
35 | 35 |
import eu.etaxonomy.cdm.model.reference.Reference; |
36 | 36 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
37 |
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action; |
|
38 | 37 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
39 | 38 |
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent; |
40 | 39 |
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet; |
... | ... | |
45 | 44 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationDTO; |
46 | 45 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationTypeConverter; |
47 | 46 |
import eu.etaxonomy.cdm.vaadin.view.registration.RegistrationWorksetViewBean; |
47 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
|
48 | 48 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
49 | 49 |
import eu.etaxonomy.vaadin.ui.navigation.NavigationEvent; |
50 | 50 |
|
... | ... | |
191 | 191 |
ReferenceEditorAction referenceEditorAction = null; |
192 | 192 |
if(workingSet.getCitationId() != null){ |
193 | 193 |
if(UserHelper.fromSession().userHasPermission(Reference.class, workingSet.getCitationId(), CRUD.UPDATE)){ |
194 |
referenceEditorAction = new ReferenceEditorAction(Action.EDIT, workingSet.getCitationId());
|
|
194 |
referenceEditorAction = new ReferenceEditorAction(EditorActionType.EDIT, workingSet.getCitationId());
|
|
195 | 195 |
} |
196 | 196 |
PermissionDebugUtils.addGainPerEntityPermissionButton(this, Reference.class, workingSet.getCitationId(), EnumSet.of(CRUD.UPDATE, CRUD.DELETE), null); |
197 | 197 |
} else { |
198 | 198 |
if(UserHelper.fromSession().userHasPermission(Reference.class, CRUD.CREATE)){ |
199 |
referenceEditorAction = new ReferenceEditorAction(Action.ADD);
|
|
199 |
referenceEditorAction = new ReferenceEditorAction(EditorActionType.ADD);
|
|
200 | 200 |
} |
201 | 201 |
} |
202 | 202 |
TimePeriod datePublished = null; |
src/main/java/eu/etaxonomy/cdm/vaadin/event/AbstractEditorAction.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import com.vaadin.ui.Component; |
12 | 12 |
|
13 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
|
13 | 14 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
14 | 15 |
|
15 | 16 |
/** |
17 |
* Base implementation for an event which |
|
18 |
* which represents the request to start an editor to enable the |
|
19 |
* user to perform the <code>action</code> transported with this event. |
|
20 |
* |
|
16 | 21 |
* @author a.kohlbecker |
17 | 22 |
* @since Mar 22, 2017 |
18 | 23 |
* |
19 | 24 |
*/ |
20 |
public abstract class AbstractEditorAction extends AbstractEntityEvent<AbstractEditorAction.Action> { |
|
21 |
|
|
22 |
public enum Action { |
|
23 |
ADD, |
|
24 |
EDIT, |
|
25 |
REMOVE; |
|
26 |
} |
|
25 |
public abstract class AbstractEditorAction extends AbstractEntityEvent<EditorActionType> { |
|
27 | 26 |
|
28 | 27 |
private Component sourceComponent = null; |
29 | 28 |
|
30 | 29 |
private AbstractView sourceView = null; |
31 | 30 |
|
32 |
public AbstractEditorAction(Action action) {
|
|
31 |
public AbstractEditorAction(EditorActionType action) {
|
|
33 | 32 |
super(action, null); |
34 | 33 |
} |
35 | 34 |
|
36 |
public AbstractEditorAction(Action action, Component source) {
|
|
35 |
public AbstractEditorAction(EditorActionType action, Component source) {
|
|
37 | 36 |
this(action, null, source); |
38 | 37 |
} |
39 | 38 |
|
... | ... | |
41 | 40 |
* @param type |
42 | 41 |
* @param citationId |
43 | 42 |
*/ |
44 |
public AbstractEditorAction(Action action, Integer entityId) {
|
|
43 |
public AbstractEditorAction(EditorActionType action, Integer entityId) {
|
|
45 | 44 |
super(action, entityId); |
46 | 45 |
} |
47 | 46 |
|
48 |
public AbstractEditorAction(Action action, Integer entityId, Component source) {
|
|
47 |
public AbstractEditorAction(EditorActionType action, Integer entityId, Component source) {
|
|
49 | 48 |
super(action, entityId); |
50 | 49 |
this.sourceComponent = source; |
51 | 50 |
} |
52 | 51 |
|
53 |
public AbstractEditorAction(Action action, Integer entityId, Component source, AbstractView sourceView) {
|
|
52 |
public AbstractEditorAction(EditorActionType action, Integer entityId, Component source, AbstractView sourceView) {
|
|
54 | 53 |
super(action, entityId); |
55 | 54 |
this.sourceComponent = source; |
56 | 55 |
this.sourceView = sourceView; |
57 | 56 |
} |
58 | 57 |
|
59 | 58 |
public boolean isAddAction() { |
60 |
return type.equals(Action.ADD);
|
|
59 |
return type.equals(EditorActionType.ADD);
|
|
61 | 60 |
} |
62 | 61 |
|
63 | 62 |
public boolean isEditAction() { |
64 |
return type.equals(Action.EDIT);
|
|
63 |
return type.equals(EditorActionType.EDIT);
|
|
65 | 64 |
} |
66 | 65 |
|
67 | 66 |
public boolean isRemoveAction() { |
68 |
return type.equals(Action.REMOVE);
|
|
67 |
return type.equals(EditorActionType.REMOVE);
|
|
69 | 68 |
} |
70 | 69 |
|
71 | 70 |
public Component getSourceComponent(){ |
src/main/java/eu/etaxonomy/cdm/vaadin/event/CollectionEditorAction.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import com.vaadin.ui.Component; |
12 | 12 |
|
13 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
|
13 | 14 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
14 | 15 |
|
15 | 16 |
/** |
... | ... | |
21 | 22 |
/** |
22 | 23 |
* @param eventType |
23 | 24 |
*/ |
24 |
public CollectionEditorAction(Action type) {
|
|
25 |
public CollectionEditorAction(EditorActionType type) {
|
|
25 | 26 |
super(type); |
26 | 27 |
} |
27 | 28 |
|
... | ... | |
29 | 30 |
* @param edit |
30 | 31 |
* @param citationId |
31 | 32 |
*/ |
32 |
public CollectionEditorAction(Action type, Integer citationId) {
|
|
33 |
public CollectionEditorAction(EditorActionType type, Integer citationId) {
|
|
33 | 34 |
super(type, citationId); |
34 | 35 |
} |
35 | 36 |
|
... | ... | |
38 | 39 |
* @param entityId |
39 | 40 |
* @param source |
40 | 41 |
*/ |
41 |
public CollectionEditorAction(Action type, Integer entityId, Component source) {
|
|
42 |
public CollectionEditorAction(EditorActionType type, Integer entityId, Component source) {
|
|
42 | 43 |
super(type, entityId, source); |
43 | 44 |
} |
44 | 45 |
|
... | ... | |
46 | 47 |
* @param action |
47 | 48 |
* @param source |
48 | 49 |
*/ |
49 |
public CollectionEditorAction(Action action, Component source) {
|
|
50 |
public CollectionEditorAction(EditorActionType action, Component source) {
|
|
50 | 51 |
super(action, source); |
51 | 52 |
} |
52 | 53 |
|
... | ... | |
56 | 57 |
* @param source |
57 | 58 |
* @param sourceView |
58 | 59 |
*/ |
59 |
public CollectionEditorAction(Action action, Integer entityId, Component source, AbstractView sourceView) {
|
|
60 |
public CollectionEditorAction(EditorActionType action, Integer entityId, Component source, AbstractView sourceView) {
|
|
60 | 61 |
super(action, entityId, source, sourceView); |
61 | 62 |
} |
62 | 63 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/event/ReferenceEditorAction.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import com.vaadin.ui.Component; |
12 | 12 |
|
13 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
|
13 | 14 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
14 | 15 |
|
15 | 16 |
/** |
... | ... | |
21 | 22 |
/** |
22 | 23 |
* @param eventType |
23 | 24 |
*/ |
24 |
public ReferenceEditorAction(Action type) {
|
|
25 |
public ReferenceEditorAction(EditorActionType type) {
|
|
25 | 26 |
super(type); |
26 | 27 |
} |
27 | 28 |
|
... | ... | |
29 | 30 |
* @param edit |
30 | 31 |
* @param citationId |
31 | 32 |
*/ |
32 |
public ReferenceEditorAction(Action type, Integer citationId) {
|
|
33 |
public ReferenceEditorAction(EditorActionType type, Integer citationId) {
|
|
33 | 34 |
super(type, citationId); |
34 | 35 |
} |
35 | 36 |
|
... | ... | |
38 | 39 |
* @param entityId |
39 | 40 |
* @param source |
40 | 41 |
*/ |
41 |
public ReferenceEditorAction(Action type, Integer entityId, Component source) {
|
|
42 |
public ReferenceEditorAction(EditorActionType type, Integer entityId, Component source) {
|
|
42 | 43 |
super(type, entityId, source); |
43 | 44 |
} |
44 | 45 |
|
... | ... | |
46 | 47 |
* @param action |
47 | 48 |
* @param source |
48 | 49 |
*/ |
49 |
public ReferenceEditorAction(Action action, Component source) {
|
|
50 |
public ReferenceEditorAction(EditorActionType action, Component source) {
|
|
50 | 51 |
super(action, source); |
51 | 52 |
} |
52 | 53 |
|
... | ... | |
56 | 57 |
* @param source |
57 | 58 |
* @param sourceView |
58 | 59 |
*/ |
59 |
public ReferenceEditorAction(Action action, Integer entityId, Component source, AbstractView sourceView) {
|
|
60 |
public ReferenceEditorAction(EditorActionType action, Integer entityId, Component source, AbstractView sourceView) {
|
|
60 | 61 |
super(action, entityId, source, sourceView); |
61 | 62 |
} |
62 | 63 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/event/RegistrationEditorAction.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import com.vaadin.ui.Component; |
12 | 12 |
|
13 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
|
13 | 14 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
14 | 15 |
|
15 | 16 |
/** |
... | ... | |
21 | 22 |
/** |
22 | 23 |
* @param eventType |
23 | 24 |
*/ |
24 |
public RegistrationEditorAction(Action type) {
|
|
25 |
public RegistrationEditorAction(EditorActionType type) {
|
|
25 | 26 |
super(type); |
26 | 27 |
} |
27 | 28 |
|
... | ... | |
29 | 30 |
* @param edit |
30 | 31 |
* @param citationId |
31 | 32 |
*/ |
32 |
public RegistrationEditorAction(Action type, Integer enitityId) {
|
|
33 |
public RegistrationEditorAction(EditorActionType type, Integer enitityId) {
|
|
33 | 34 |
super(type, enitityId); |
34 | 35 |
} |
35 | 36 |
|
... | ... | |
37 | 38 |
* @param action |
38 | 39 |
* @param source |
39 | 40 |
*/ |
40 |
public RegistrationEditorAction(Action action, Component source) {
|
|
41 |
public RegistrationEditorAction(EditorActionType action, Component source) {
|
|
41 | 42 |
super(action, source); |
42 | 43 |
} |
43 | 44 |
|
... | ... | |
47 | 48 |
* @param source |
48 | 49 |
* @param sourceView |
49 | 50 |
*/ |
50 |
public RegistrationEditorAction(Action action, Integer entityId, Component source, AbstractView sourceView) {
|
|
51 |
public RegistrationEditorAction(EditorActionType action, Integer entityId, Component source, AbstractView sourceView) {
|
|
51 | 52 |
super(action, entityId, source, sourceView); |
52 | 53 |
} |
53 | 54 |
|
... | ... | |
56 | 57 |
* @param entityId |
57 | 58 |
* @param source |
58 | 59 |
*/ |
59 |
public RegistrationEditorAction(Action action, Integer entityId, Component source) {
|
|
60 |
public RegistrationEditorAction(EditorActionType action, Integer entityId, Component source) {
|
|
60 | 61 |
super(action, entityId, source); |
61 | 62 |
} |
62 | 63 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/event/TaxonNameEditorAction.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import com.vaadin.ui.Component; |
12 | 12 |
|
13 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
|
13 | 14 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
14 | 15 |
|
15 | 16 |
/** |
... | ... | |
20 | 21 |
public class TaxonNameEditorAction extends AbstractEditorAction { |
21 | 22 |
|
22 | 23 |
|
23 |
public TaxonNameEditorAction(Action eventType) {
|
|
24 |
public TaxonNameEditorAction(EditorActionType eventType) {
|
|
24 | 25 |
super(eventType); |
25 | 26 |
} |
26 | 27 |
|
... | ... | |
28 | 29 |
* @param type |
29 | 30 |
* @param entityId |
30 | 31 |
*/ |
31 |
public TaxonNameEditorAction(Action type, Integer entityId) {
|
|
32 |
public TaxonNameEditorAction(EditorActionType type, Integer entityId) {
|
|
32 | 33 |
super(type, entityId); |
33 | 34 |
} |
34 | 35 |
|
... | ... | |
37 | 38 |
* @param entityId |
38 | 39 |
* @param source |
39 | 40 |
*/ |
40 |
public TaxonNameEditorAction(Action type, Integer entityId, Component source) {
|
|
41 |
public TaxonNameEditorAction(EditorActionType type, Integer entityId, Component source) {
|
|
41 | 42 |
super(type, entityId, source); |
42 | 43 |
} |
43 | 44 |
|
... | ... | |
45 | 46 |
* @param action |
46 | 47 |
* @param source |
47 | 48 |
*/ |
48 |
public TaxonNameEditorAction(Action action, Component source) {
|
|
49 |
public TaxonNameEditorAction(EditorActionType action, Component source) {
|
|
49 | 50 |
super(action, source); |
50 | 51 |
// TODO Auto-generated constructor stub |
51 | 52 |
} |
... | ... | |
56 | 57 |
* @param source |
57 | 58 |
* @param sourceView |
58 | 59 |
*/ |
59 |
public TaxonNameEditorAction(Action action, Integer entityId, Component source, AbstractView sourceView) {
|
|
60 |
public TaxonNameEditorAction(EditorActionType action, Integer entityId, Component source, AbstractView sourceView) {
|
|
60 | 61 |
super(action, entityId, source, sourceView); |
61 | 62 |
// TODO Auto-generated constructor stub |
62 | 63 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/event/ToOneRelatedEntityReloader.java | ||
---|---|---|
53 | 53 |
return; |
54 | 54 |
} |
55 | 55 |
|
56 |
@SuppressWarnings("unchecked") |
|
56 | 57 |
CDM value = (CDM)event.getProperty().getValue(); |
57 | 58 |
if(value == null) { |
58 | 59 |
return; |
59 | 60 |
} |
60 | 61 |
value = HibernateProxyHelper.deproxy(value); |
61 | 62 |
|
63 |
if(!cachingPresenter.isCacheInitialized()){ |
|
64 |
// skips as long as the view has not completely loaded the bean |
|
65 |
return; |
|
66 |
} |
|
67 |
|
|
62 | 68 |
EntityCache cache = cachingPresenter.getCache(); |
63 | 69 |
if(cache != null){ |
64 | 70 |
cache.update(); |
... | ... | |
76 | 82 |
toOneRelatedEntityField.addValueChangeListener(this); |
77 | 83 |
onSettingReloadedEntity = false; |
78 | 84 |
} |
85 |
} else { |
|
86 |
throw new RuntimeException("The cache must not be null. See loadBeanById() in AbstractCdmEditorPresenter"); |
|
79 | 87 |
} |
80 | 88 |
} |
81 | 89 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/event/TypeDesignationEditorAction.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.event; |
10 | 10 |
|
11 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
|
12 |
|
|
11 | 13 |
/** |
12 | 14 |
* @author a.kohlbecker |
13 | 15 |
* @since Mar 22, 2017 |
... | ... | |
15 | 17 |
public class TypeDesignationEditorAction extends AbstractEditorAction { |
16 | 18 |
|
17 | 19 |
|
18 |
public TypeDesignationEditorAction(Action eventType) {
|
|
20 |
public TypeDesignationEditorAction(EditorActionType eventType) {
|
|
19 | 21 |
super(eventType); |
20 | 22 |
} |
21 | 23 |
|
... | ... | |
23 | 25 |
* @param type |
24 | 26 |
* @param entityId |
25 | 27 |
*/ |
26 |
public TypeDesignationEditorAction(Action type, Integer entityId) {
|
|
28 |
public TypeDesignationEditorAction(EditorActionType type, Integer entityId) {
|
|
27 | 29 |
super(type, entityId); |
28 | 30 |
} |
29 | 31 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/event/TypeDesignationWorkingsetEditorAction.java | ||
---|---|---|
11 | 11 |
import com.vaadin.ui.Component; |
12 | 12 |
|
13 | 13 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSetType; |
14 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
|
14 | 15 |
import eu.etaxonomy.vaadin.mvp.AbstractView; |
15 | 16 |
|
16 | 17 |
/** |
... | ... | |
33 | 34 |
* @param source |
34 | 35 |
* @param sourceView |
35 | 36 |
*/ |
36 |
public TypeDesignationWorkingsetEditorAction(Action action, Integer typeDesignationWorkingsetId, TypeDesignationWorkingSetType workingSetType, int registrationId,
|
|
37 |
public TypeDesignationWorkingsetEditorAction(EditorActionType action, Integer typeDesignationWorkingsetId, TypeDesignationWorkingSetType workingSetType, int registrationId,
|
|
37 | 38 |
Component source, AbstractView sourceView) { |
38 | 39 |
super(action, typeDesignationWorkingsetId, source, sourceView); |
39 | 40 |
this.registrationId = registrationId; |
... | ... | |
48 | 49 |
* @param source |
49 | 50 |
* @param sourceView |
50 | 51 |
*/ |
51 |
public TypeDesignationWorkingsetEditorAction(Action action, TypeDesignationWorkingSetType workingSetType, int registrationId,
|
|
52 |
public TypeDesignationWorkingsetEditorAction(EditorActionType action, TypeDesignationWorkingSetType workingSetType, int registrationId,
|
|
52 | 53 |
Component source, AbstractView sourceView) { |
53 | 54 |
super(action, null, source, sourceView); |
54 | 55 |
this.workingSetType = workingSetType; |
src/main/java/eu/etaxonomy/cdm/vaadin/view/occurrence/CollectionEditorPresenter.java | ||
---|---|---|
103 | 103 |
); |
104 | 104 |
} |
105 | 105 |
|
106 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD")
|
|
106 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).ADD")
|
|
107 | 107 |
public void onCollectionEditorActionAdd(CollectionEditorAction event) { |
108 | 108 |
|
109 | 109 |
if(!checkFromOwnView(event)){ |
... | ... | |
117 | 117 |
collectionPopuEditor.loadInEditor(null); |
118 | 118 |
} |
119 | 119 |
|
120 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT")
|
|
120 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).EDIT")
|
|
121 | 121 |
public void onCollectionEditorActionEdit(CollectionEditorAction event) { |
122 | 122 |
|
123 | 123 |
if(!checkFromOwnView(event)){ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/occurrence/CollectionPopupEditor.java | ||
---|---|---|
14 | 14 |
import com.vaadin.ui.TextField; |
15 | 15 |
|
16 | 16 |
import eu.etaxonomy.cdm.model.occurrence.Collection; |
17 |
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction; |
|
18 |
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action; |
|
19 | 17 |
import eu.etaxonomy.cdm.vaadin.event.CollectionEditorAction; |
20 | 18 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater; |
21 | 19 |
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView; |
22 | 20 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
23 | 21 |
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox; |
22 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
|
24 | 23 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor; |
25 | 24 |
|
26 | 25 |
/** |
... | ... | |
135 | 134 |
|
136 | 135 |
superCollectionCombobox = new ToOneRelatedEntityCombobox<Collection>("Super-collection", Collection.class); |
137 | 136 |
superCollectionCombobox.addClickListenerAddEntity(e -> getEventBus().publishEvent( |
138 |
new CollectionEditorAction(AbstractEditorAction.Action.ADD, null, superCollectionCombobox, this)
|
|
137 |
new CollectionEditorAction(EditorActionType.ADD, null, superCollectionCombobox, this)
|
|
139 | 138 |
)); |
140 | 139 |
superCollectionCombobox.addClickListenerEditEntity(e -> { |
141 | 140 |
if(superCollectionCombobox.getValue() != null){ |
142 | 141 |
getEventBus().publishEvent( |
143 | 142 |
new CollectionEditorAction( |
144 |
AbstractEditorAction.Action.EDIT,
|
|
143 |
EditorActionType.EDIT,
|
|
145 | 144 |
superCollectionCombobox.getValue().getId(), |
146 | 145 |
superCollectionCombobox, |
147 | 146 |
this) |
... | ... | |
160 | 159 |
|
161 | 160 |
superCollectionCombobox.addClickListenerAddEntity( e -> getEventBus().publishEvent( |
162 | 161 |
new CollectionEditorAction( |
163 |
Action.ADD,
|
|
162 |
EditorActionType.ADD,
|
|
164 | 163 |
null, |
165 | 164 |
superCollectionCombobox, |
166 | 165 |
this) |
... | ... | |
169 | 168 |
if(superCollectionCombobox.getValue() != null){ |
170 | 169 |
getEventBus().publishEvent( |
171 | 170 |
new CollectionEditorAction( |
172 |
Action.EDIT,
|
|
171 |
EditorActionType.EDIT,
|
|
173 | 172 |
superCollectionCombobox.getValue().getId(), |
174 | 173 |
superCollectionCombobox, |
175 | 174 |
this |
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferencePopupEditor.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.vaadin.component.TextFieldNFix; |
24 | 24 |
import eu.etaxonomy.cdm.vaadin.component.common.TeamOrPersonField; |
25 | 25 |
import eu.etaxonomy.cdm.vaadin.component.common.TimePeriodField; |
26 |
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction; |
|
27 | 26 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
28 | 27 |
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView; |
29 | 28 |
import eu.etaxonomy.cdm.vaadin.util.converter.DoiConverter; |
30 | 29 |
import eu.etaxonomy.cdm.vaadin.util.converter.UriConverter; |
31 | 30 |
import eu.etaxonomy.vaadin.component.SwitchableTextField; |
32 | 31 |
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox; |
32 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
|
33 | 33 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmPopupEditor; |
34 | 34 |
|
35 | 35 |
/** |
... | ... | |
128 | 128 |
inReferenceCombobox = new ToOneRelatedEntityCombobox<Reference>("In-reference", Reference.class); |
129 | 129 |
inReferenceCombobox.setWidth(100, Unit.PERCENTAGE); |
130 | 130 |
inReferenceCombobox.addClickListenerAddEntity(e -> getEventBus().publishEvent( |
131 |
new ReferenceEditorAction(AbstractEditorAction.Action.ADD, null, inReferenceCombobox, this)
|
|
131 |
new ReferenceEditorAction(EditorActionType.ADD, null, inReferenceCombobox, this)
|
|
132 | 132 |
)); |
133 | 133 |
inReferenceCombobox.addClickListenerEditEntity(e -> { |
134 | 134 |
if(inReferenceCombobox.getValue() != null){ |
135 | 135 |
getEventBus().publishEvent( |
136 | 136 |
new ReferenceEditorAction( |
137 |
AbstractEditorAction.Action.EDIT,
|
|
137 |
EditorActionType.EDIT,
|
|
138 | 138 |
inReferenceCombobox.getValue().getId(), |
139 | 139 |
inReferenceCombobox, |
140 | 140 |
this) |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java | ||
---|---|---|
201 | 201 |
} |
202 | 202 |
} |
203 | 203 |
|
204 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD && #event.sourceComponent == null")
|
|
204 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).ADD")
|
|
205 | 205 |
public void onReferenceEditorActionAdd(ReferenceEditorAction event) { |
206 |
|
|
207 |
if(!checkFromOwnView(event)){ |
|
208 |
return; |
|
209 |
} |
|
210 |
|
|
206 | 211 |
ReferencePopupEditor popup = getNavigationManager().showInPopup(ReferencePopupEditor.class); |
207 | 212 |
popup.loadInEditor(null); |
208 | 213 |
} |
209 | 214 |
|
210 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT && #event.sourceComponent == null")
|
|
215 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).EDIT")
|
|
211 | 216 |
public void onReferenceEditorActionEdit(ReferenceEditorAction event) { |
217 |
|
|
218 |
if(!checkFromOwnView(event)){ |
|
219 |
return; |
|
220 |
} |
|
212 | 221 |
ReferencePopupEditor popup = getNavigationManager().showInPopup(ReferencePopupEditor.class); |
213 | 222 |
popup.withDeleteButton(true); |
214 | 223 |
popup.loadInEditor(event.getEntityId()); |
215 | 224 |
} |
216 | 225 |
|
217 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT && #event.sourceComponent == null")
|
|
226 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).EDIT")
|
|
218 | 227 |
public void onRegistrationEditorAction(RegistrationEditorAction event) { |
228 |
|
|
229 |
if(!checkFromOwnView(event)){ |
|
230 |
return; |
|
231 |
} |
|
232 |
|
|
219 | 233 |
RegistrationPopupEditor popup = getNavigationManager().showInPopup(RegistrationPopupEditor.class); |
220 | 234 |
popup.loadInEditor(event.getEntityId()); |
221 | 235 |
} |
222 | 236 |
|
223 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT")
|
|
237 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).EDIT")
|
|
224 | 238 |
public void onTaxonNameEditorActionEdit(TaxonNameEditorAction event) { |
225 | 239 |
|
226 | 240 |
if(!checkFromOwnView(event)){ |
... | ... | |
238 | 252 |
} |
239 | 253 |
|
240 | 254 |
|
241 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD")
|
|
255 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).ADD")
|
|
242 | 256 |
public void onTaxonNameEditorActionAdd(TaxonNameEditorAction event) { |
243 | 257 |
|
258 |
if(!checkFromOwnView(event)){ |
|
259 |
return; |
|
260 |
} |
|
261 |
|
|
244 | 262 |
newTaxonNameForRegistration = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES()); |
245 | 263 |
newTaxonNameForRegistration.setNomenclaturalReference(getRepo().getReferenceService().find(workingset.getCitationId())); |
246 | 264 |
EntityChangeEvent nameSaveEvent = getTaxonNameStore().saveBean(newTaxonNameForRegistration); |
... | ... | |
327 | 345 |
|
328 | 346 |
} |
329 | 347 |
|
330 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).EDIT")
|
|
348 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).EDIT")
|
|
331 | 349 |
public void onTypeDesignationsEditorActionEdit(TypeDesignationWorkingsetEditorAction event) { |
332 | 350 |
|
333 | 351 |
if(!checkFromOwnView(event)){ |
... | ... | |
347 | 365 |
} |
348 | 366 |
} |
349 | 367 |
|
350 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD && #event.sourceComponent == null")
|
|
368 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).ADD && #event.sourceComponent == null")
|
|
351 | 369 |
public void onAddNewTypeDesignationWorkingset(TypeDesignationWorkingsetEditorAction event) { |
352 | 370 |
|
353 | 371 |
if(event.getWorkingSetType() == TypeDesignationWorkingSetType.SPECIMEN_TYPE_DESIGNATION_WORKINGSET){ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java | ||
---|---|---|
45 | 45 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItemEditButtonGroup.TypeDesignationWorkingSetButton; |
46 | 46 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStateLabel; |
47 | 47 |
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStyles; |
48 |
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction; |
|
49 |
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action; |
|
50 | 48 |
import eu.etaxonomy.cdm.vaadin.event.RegistrationEditorAction; |
51 | 49 |
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent; |
52 | 50 |
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction; |
... | ... | |
58 | 56 |
import eu.etaxonomy.cdm.vaadin.security.UserHelper; |
59 | 57 |
import eu.etaxonomy.cdm.vaadin.util.converter.TypeDesignationSetManager.TypeDesignationWorkingSetType; |
60 | 58 |
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView; |
59 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
|
61 | 60 |
|
62 | 61 |
/** |
63 | 62 |
* @author a.kohlbecker |
... | ... | |
184 | 183 |
addNewNameRegistrationButton = new Button("new name"); |
185 | 184 |
addNewNameRegistrationButton.setDescription("A name which is newly published in this publication."); |
186 | 185 |
addNewNameRegistrationButton.addClickListener( |
187 |
e -> eventBus.publishEvent(new TaxonNameEditorAction(Action.ADD, addNewNameRegistrationButton))
|
|
186 |
e -> eventBus.publishEvent(new TaxonNameEditorAction(EditorActionType.ADD, addNewNameRegistrationButton))
|
|
188 | 187 |
); |
189 | 188 |
|
190 | 189 |
addExistingNameButton = new Button("existing name:"); |
... | ... | |
251 | 250 |
editRegistrationButton.setStyleName(ValoTheme.BUTTON_TINY); |
252 | 251 |
editRegistrationButton.setDescription("Edit registration"); |
253 | 252 |
editRegistrationButton.addClickListener(e -> getEventBus().publishEvent(new RegistrationEditorAction( |
254 |
AbstractEditorAction.Action.EDIT,
|
|
253 |
EditorActionType.EDIT,
|
|
255 | 254 |
dto.getId(), |
256 | 255 |
null, |
257 | 256 |
this |
... | ... | |
270 | 269 |
editButtonGroup.getNameButton().getButton().addClickListener(e -> { |
271 | 270 |
Integer nameId = editButtonGroup.getNameButton().getId(); |
272 | 271 |
getEventBus().publishEvent(new TaxonNameEditorAction( |
273 |
AbstractEditorAction.Action.EDIT,
|
|
272 |
EditorActionType.EDIT,
|
|
274 | 273 |
nameId, |
275 | 274 |
e.getButton(), |
276 | 275 |
this |
... | ... | |
285 | 284 |
TypeDesignationWorkingSetType workingsetType = workingsetButton.getType(); |
286 | 285 |
Integer registrationEntityID = dto.getId(); |
287 | 286 |
getEventBus().publishEvent(new TypeDesignationWorkingsetEditorAction( |
288 |
AbstractEditorAction.Action.EDIT,
|
|
287 |
EditorActionType.EDIT,
|
|
289 | 288 |
typeDesignationWorkingsetId, |
290 | 289 |
workingsetType, |
291 | 290 |
registrationEntityID, |
... | ... | |
344 | 343 |
protected void addNewTypeDesignationWorkingset(TypeDesignationWorkingSetType newWorkingsetType, Integer registrationEntityId, Window typeDesignationTypeCooser) { |
345 | 344 |
UI.getCurrent().removeWindow(typeDesignationTypeCooser); |
346 | 345 |
getEventBus().publishEvent(new TypeDesignationWorkingsetEditorAction( |
347 |
AbstractEditorAction.Action.ADD,
|
|
346 |
EditorActionType.ADD,
|
|
348 | 347 |
newWorkingsetType, |
349 | 348 |
registrationEntityId, |
350 | 349 |
null, |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationPresenter.java | ||
---|---|---|
81 | 81 |
super.handleViewExit(); |
82 | 82 |
} |
83 | 83 |
|
84 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD")
|
|
84 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).ADD")
|
|
85 | 85 |
public void onReferenceEditorActionAdd(ReferenceEditorAction event) { |
86 | 86 |
|
87 | 87 |
if(getView() == null || getView().getNewPublicationButton() != event.getSourceComponent()){ |
... | ... | |
96 | 96 |
newReferencePopup.loadInEditor(null); |
97 | 97 |
} |
98 | 98 |
|
99 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).REMOVE")
|
|
99 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).REMOVE")
|
|
100 | 100 |
public void onReferenceEditorActionRemove(ReferenceEditorAction event) { |
101 | 101 |
|
102 | 102 |
if(getView().getRemoveNewPublicationButton() != event.getSourceComponent()){ |
... | ... | |
147 | 147 |
} |
148 | 148 |
} |
149 | 149 |
|
150 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD")
|
|
150 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.vaadin.event.EditorActionType).ADD")
|
|
151 | 151 |
public void onRegistrationEditorActionAdd(RegistrationEditorAction event) { |
152 | 152 |
|
153 | 153 |
if(getView().getContinueButton() != event.getSourceComponent()){ |
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationViewBean.java | ||
---|---|---|
25 | 25 |
import com.vaadin.ui.themes.ValoTheme; |
26 | 26 |
|
27 | 27 |
import eu.etaxonomy.cdm.model.reference.Reference; |
28 |
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action; |
|
29 | 28 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
30 | 29 |
import eu.etaxonomy.cdm.vaadin.event.RegistrationEditorAction; |
31 | 30 |
import eu.etaxonomy.cdm.vaadin.security.AccessRestrictedView; |
32 | 31 |
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView; |
32 |
import eu.etaxonomy.vaadin.event.EditorActionType; |
|
33 | 33 |
|
34 | 34 |
/** |
35 | 35 |
* @author a.kohlbecker |
... | ... | |
89 | 89 |
|
90 | 90 |
newPublicationButton = new Button("New"); |
91 | 91 |
newPublicationButton.addClickListener( e -> eventBus.publishEvent( |
92 |
new ReferenceEditorAction(Action.ADD, newPublicationButton)
|
|
92 |
new ReferenceEditorAction(EditorActionType.ADD, newPublicationButton)
|
|
93 | 93 |
)); |
94 | 94 |
newPublicationButton.setCaption("New"); |
95 | 95 |
newPublicationButton.setWidth(ELEMENT_WIDTH); |
... | ... | |
101 | 101 |
removeNewPublicationButton.setStyleName(ValoTheme.BUTTON_DANGER); |
102 | 102 |
removeNewPublicationButton.setWidth(ELEMENT_WIDTH); |
103 | 103 |
removeNewPublicationButton.addClickListener( e -> eventBus.publishEvent( |
104 |
new ReferenceEditorAction(Action.REMOVE, removeNewPublicationButton)
|
|
104 |
new ReferenceEditorAction(EditorActionType.REMOVE, removeNewPublicationButton)
|
|
105 | 105 |
)); |
106 | 106 |
|
107 | 107 |
removeNewPublicationButton.setVisible(false); |
... | ... | |
134 | 134 |
refId = referenceCombobox.getValue().getId(); |
135 | 135 |
} |
136 | 136 |
eventBus.publishEvent( |
137 |
new RegistrationEditorAction(Action.ADD,
|
|
137 |
new RegistrationEditorAction(EditorActionType.ADD,
|
|
138 | 138 |
// passing the refId is hack, bit for some reason the presenter is always referring to the wrong view |
139 | 139 |
refId, |
140 | 140 |
continueButton, |
src/main/java/eu/etaxonomy/vaadin/event/EditorActionType.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.vaadin.event; |
|
10 |
|
|
11 |
public enum EditorActionType { |
|
12 |
ADD, // TODO change to CREATE? |
|
13 |
EDIT, |
|
14 |
REMOVE; |
|
15 |
} |
src/main/java/eu/etaxonomy/vaadin/event/EntityEditorActionEvent.java | ||
---|---|---|
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.vaadin.event; |
|
10 |
|
|
11 |
import java.util.EnumSet; |
|
12 |
|
|
13 |
import com.vaadin.ui.AbstractField; |
|
14 |
|
|
15 |
/** |
|
16 |
* An Event |
|
17 |
* which represents the request to start an editor to enable the |
|
18 |
* user to perform the <code>action</code> transported with this event. |
|
19 |
* |
|
20 |
* @author a.kohlbecker |
|
21 |
* |
|
22 |
*/ |
|
23 |
public class EntityEditorActionEvent<T> { |
|
24 |
|
|
25 |
private Class<T> beanType; |
|
26 |
private EditorActionType action; |
|
27 |
private AbstractField<T> field; |
|
28 |
private T bean; |
|
29 |
|
|
30 |
/** |
|
31 |
* @param type |
|
32 |
* @param entityId |
|
33 |
* @param field |
|
34 |
*/ |
|
35 |
public EntityEditorActionEvent(EditorActionType action, Class<T> beanType, AbstractField<T> field) { |
|
36 |
this.action = action; |
|
37 |
this.beanType = beanType; |
|
38 |
this.field = field; |
|
39 |
} |
|
40 |
|
|
41 |
/** |
|
42 |
* |
|
43 |
* @param type |
|
44 |
* @param entityId |
|
45 |
* @param field |
|
46 |
*/ |
|
47 |
public EntityEditorActionEvent(EditorActionType action, Class<T> beanType, T bean, AbstractField<T> field) { |
|
48 |
this.action = action; |
|
49 |
this.beanType = beanType; |
|
50 |
if(EnumSet.of(EditorActionType.REMOVE, EditorActionType.EDIT).contains(action) && bean == null){ |
|
51 |
throw new NullPointerException("bean must not be null when creating an event with " + action); |
|
52 |
} |
|
53 |
this.bean = bean; |
|
54 |
this.field = field; |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* @return the beanType |
|
59 |
*/ |
|
60 |
public Class<?> getBeanType() { |
|
61 |
return beanType; |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* @return the action |
|
66 |
*/ |
|
67 |
public EditorActionType getAction() { |
|
68 |
return action; |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* @return the field which contains the bean |
|
73 |
*/ |
|
74 |
public AbstractField<T> getSource() { |
|
75 |
return field; |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* @return the bean |
|
80 |
*/ |
|
81 |
public T getBean() { |
|
82 |
return bean; |
|
83 |
} |
|
84 |
|
|
85 |
} |
src/main/java/eu/etaxonomy/vaadin/event/EntityEditorActionListener.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.vaadin.event; |
|
10 |
|
|
11 |
/** |
|
12 |
* @author a.kohlbecker |
|
13 |
* @since Jan 17, 2018 |
|
14 |
* |
|
15 |
*/ |
|
16 |
public interface EntityEditorActionListener { |
|
17 |
|
|
18 |
public void onEntityEditorActionEvent(EntityEditorActionEvent action); |
|
19 |
|
|
20 |
} |
Also available in: Unified diff
ref #7204 refactoring editor events and introducing generic EntityEditorActionEvent