Revision b36e8dd1
Added by Andreas Kohlbecker over 6 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.cdm.vaadin.view.name; |
10 | 10 |
|
11 | 11 |
import java.util.Arrays; |
12 |
import java.util.EnumSet; |
|
12 | 13 |
import java.util.List; |
13 | 14 |
import java.util.Set; |
14 | 15 |
|
15 | 16 |
import org.apache.log4j.Logger; |
17 |
import org.springframework.context.event.EventListener; |
|
16 | 18 |
|
17 | 19 |
import eu.etaxonomy.cdm.api.service.INameService; |
18 | 20 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
... | ... | |
23 | 25 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
24 | 26 |
import eu.etaxonomy.cdm.model.name.TaxonNameFactory; |
25 | 27 |
import eu.etaxonomy.cdm.model.reference.Reference; |
28 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
|
26 | 29 |
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider; |
27 | 30 |
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory; |
31 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
|
28 | 32 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater; |
29 | 33 |
import eu.etaxonomy.cdm.vaadin.security.UserHelper; |
30 | 34 |
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator; |
35 |
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor; |
|
31 | 36 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter; |
37 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent; |
|
38 |
import eu.etaxonomy.vaadin.ui.view.DoneWithPopupEvent.Reason; |
|
32 | 39 |
|
33 | 40 |
/** |
34 | 41 |
* @author a.kohlbecker |
... | ... | |
41 | 48 |
|
42 | 49 |
private static final Logger logger = Logger.getLogger(TaxonNameEditorPresenter.class); |
43 | 50 |
|
51 |
ReferencePopupEditor newReferencePopup = null; |
|
52 |
|
|
44 | 53 |
/** |
45 | 54 |
* {@inheritDoc} |
46 | 55 |
*/ |
... | ... | |
173 | 182 |
return getRepo().getNameService(); |
174 | 183 |
} |
175 | 184 |
|
185 |
@EventListener(condition = "#event.type == T(eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.Action).ADD") |
|
186 |
public void onReferenceEditorActionAdd(ReferenceEditorAction event) { |
|
187 |
|
|
188 |
if(getView() == null || event.getSourceView() != getView() ){ |
|
189 |
return; |
|
190 |
} |
|
191 |
newReferencePopup = getNavigationManager().showInPopup(ReferencePopupEditor.class); |
|
192 |
|
|
193 |
newReferencePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE)); |
|
194 |
newReferencePopup.withDeleteButton(true); |
|
195 |
newReferencePopup.loadInEditor(null); |
|
196 |
} |
|
197 |
|
|
198 |
@EventListener |
|
199 |
public void onDoneWithPopupEvent(DoneWithPopupEvent event){ |
|
200 |
if(event.getPopup() == newReferencePopup){ |
|
201 |
if(event.getReason() == Reason.SAVE){ |
|
202 |
|
|
203 |
Reference newReference = newReferencePopup.getBean(); |
|
204 |
|
|
205 |
// TODO the bean contained in the popup editor is not yet updated at this point. |
|
206 |
// so re reload it using the uuid since new beans will not have an Id at this point. |
|
207 |
newReference = getRepo().getReferenceService().find(newReference.getUuid()); |
|
208 |
getView().getNomReferenceCombobox().setValue(newReference); |
|
209 |
} |
|
210 |
|
|
211 |
newReferencePopup = null; |
|
212 |
} |
|
213 |
} |
|
214 |
|
|
176 | 215 |
|
177 | 216 |
|
178 | 217 |
} |
Also available in: Unified diff
fix #7149 implementing CollectionEditor