Revision c6db362d
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java | ||
---|---|---|
22 | 22 |
|
23 | 23 |
import eu.etaxonomy.cdm.api.service.IService; |
24 | 24 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
25 |
import eu.etaxonomy.cdm.model.agent.Institution; |
|
25 | 26 |
import eu.etaxonomy.cdm.model.agent.Person; |
26 | 27 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
27 | 28 |
import eu.etaxonomy.cdm.model.common.Annotation; |
... | ... | |
31 | 32 |
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider; |
32 | 33 |
import eu.etaxonomy.cdm.service.UserHelperAccess; |
33 | 34 |
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory; |
35 |
import eu.etaxonomy.cdm.vaadin.event.EditorActionTypeFilter; |
|
34 | 36 |
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent; |
37 |
import eu.etaxonomy.cdm.vaadin.event.InstitutionEditorAction; |
|
35 | 38 |
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction; |
36 | 39 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater; |
37 | 40 |
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader; |
41 |
import eu.etaxonomy.cdm.vaadin.view.common.InstitutionPopupEditor; |
|
38 | 42 |
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityField; |
39 | 43 |
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter; |
40 | 44 |
import eu.etaxonomy.vaadin.mvp.BeanInstantiator; |
45 |
import eu.etaxonomy.vaadin.mvp.BoundField; |
|
46 |
import eu.etaxonomy.vaadin.ui.view.PopupView; |
|
41 | 47 |
|
42 | 48 |
/** |
43 | 49 |
* @author a.kohlbecker |
... | ... | |
86 | 92 |
getView().getAuthorshipField().setFilterableTeamPagingProvider(teamOrPersonPagingProvider, this); |
87 | 93 |
getView().getAuthorshipField().setFilterablePersonPagingProvider(personPagingProvider, this); |
88 | 94 |
|
95 |
CdmFilterablePagingProvider<AgentBase, Institution> institutionPagingProvider = new CdmFilterablePagingProvider<AgentBase, Institution>(getRepo().getAgentService(), Institution.class); |
|
96 |
getView().getInstitutionCombobox().getSelect().loadFrom(institutionPagingProvider, institutionPagingProvider, institutionPagingProvider.getPageSize()); |
|
97 |
getView().getInstitutionCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Institution>(getView().getInstitutionCombobox(), this)); |
|
98 |
|
|
99 |
getView().getSchoolCombobox().getSelect().loadFrom(institutionPagingProvider, institutionPagingProvider, institutionPagingProvider.getPageSize()); |
|
100 |
getView().getSchoolCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Institution>(getView().getSchoolCombobox(), this)); |
|
101 |
|
|
89 | 102 |
getView().getAnnotationsField().setAnnotationTypeItemContainer(selectFieldFactory.buildTermItemContainer( |
90 | 103 |
AnnotationType.EDITORIAL().getUuid(), AnnotationType.TECHNICAL().getUuid())); |
91 | 104 |
} |
... | ... | |
152 | 165 |
/** |
153 | 166 |
* |
154 | 167 |
* @param editorAction |
155 |
* @throws EditorEntityBeanException
|
|
168 |
* @throws EditorEntityBeanException |
|
156 | 169 |
*/ |
157 | 170 |
@EventBusListenerMethod |
158 | 171 |
public void onReferenceEditorAction(ReferenceEditorAction editorAction) { |
... | ... | |
174 | 187 |
} |
175 | 188 |
} |
176 | 189 |
|
190 |
@EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class) |
|
191 |
public void onInstitutionEditorActionEdit(InstitutionEditorAction event) { |
|
192 |
|
|
193 |
if(!checkFromOwnView(event)){ |
|
194 |
return; |
|
195 |
} |
|
196 |
|
|
197 |
InstitutionPopupEditor institutionPopuEditor = openPopupEditor(InstitutionPopupEditor.class, event); |
|
198 |
|
|
199 |
institutionPopuEditor.grantToCurrentUser(this.crud); |
|
200 |
institutionPopuEditor.withDeleteButton(true); |
|
201 |
institutionPopuEditor.loadInEditor(event.getEntityUuid()); |
|
202 |
} |
|
203 |
|
|
204 |
@EventBusListenerMethod(filter = EditorActionTypeFilter.Add.class) |
|
205 |
public void onInstitutionEditorActionAdd(InstitutionEditorAction event) { |
|
206 |
|
|
207 |
if(!checkFromOwnView(event)){ |
|
208 |
return; |
|
209 |
} |
|
210 |
|
|
211 |
InstitutionPopupEditor institutionPopuEditor = openPopupEditor(InstitutionPopupEditor.class, event); |
|
212 |
|
|
213 |
institutionPopuEditor.grantToCurrentUser(this.crud); |
|
214 |
institutionPopuEditor.withDeleteButton(false); |
|
215 |
institutionPopuEditor.loadInEditor(null); |
|
216 |
} |
|
217 |
|
|
177 | 218 |
@EventBusListenerMethod |
178 | 219 |
public void onEntityChangeEvent(EntityChangeEvent<?> event){ |
179 | 220 |
|
180 |
if(event.getSourceView() == inReferencePopup){ |
|
181 |
if(event.isCreateOrModifiedType()){ |
|
182 |
getCache().load(event.getEntity()); |
|
183 |
getView().getInReferenceCombobox().reload(); |
|
221 |
BoundField boundTargetField = boundTargetField((PopupView) event.getSourceView()); |
|
222 |
|
|
223 |
if(boundTargetField != null){ |
|
224 |
if(boundTargetField.matchesPropertyIdPath("inReference")){ |
|
225 |
if(event.isCreateOrModifiedType()){ |
|
226 |
getCache().load(event.getEntity()); |
|
227 |
getView().getInReferenceCombobox().reload(); |
|
228 |
} |
|
229 |
if(event.isRemovedType()){ |
|
230 |
getView().getInReferenceCombobox().selectNewItem(null); |
|
231 |
} |
|
232 |
inReferencePopup = null; |
|
184 | 233 |
} |
185 |
if(event.isRemovedType()){ |
|
186 |
getView().getInReferenceCombobox().selectNewItem(null); |
|
234 |
else if(boundTargetField.matchesPropertyIdPath("institute")){ |
|
235 |
if(event.isCreateOrModifiedType()){ |
|
236 |
Institution newInstitution = (Institution) event.getEntity(); |
|
237 |
getCache().load(newInstitution); |
|
238 |
if(event.isCreatedType()){ |
|
239 |
getView().getInstitutionCombobox().setValue(newInstitution); |
|
240 |
} else { |
|
241 |
getView().getInstitutionCombobox().reload(); |
|
242 |
} |
|
243 |
} |
|
244 |
} else if(boundTargetField.matchesPropertyIdPath("school")){ |
|
245 |
if(event.isCreateOrModifiedType()){ |
|
246 |
Institution newInstitution = (Institution) event.getEntity(); |
|
247 |
getCache().load(newInstitution); |
|
248 |
if(event.isCreatedType()){ |
|
249 |
getView().getSchoolCombobox().setValue(newInstitution); |
|
250 |
} else { |
|
251 |
getView().getSchoolCombobox().reload(); |
|
252 |
} |
|
253 |
} |
|
187 | 254 |
} |
188 |
inReferencePopup = null; |
|
189 | 255 |
} |
190 | 256 |
|
191 | 257 |
} |
Also available in: Unified diff
fix #7480 implementing school, institute and school fields in Reference editor