Project

General

Profile

« Previous | Next » 

Revision 5abdc016

Added by Andreas Kohlbecker over 5 years ago

fix #8070 ReferenceEditor: reference type constraints for inreferences by current referenceType

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java
10 10

  
11 11
import java.util.ArrayList;
12 12
import java.util.Arrays;
13
import java.util.EnumSet;
13 14
import java.util.List;
15
import java.util.Set;
14 16
import java.util.UUID;
15 17

  
16 18
import org.apache.log4j.Logger;
......
212 214
       }
213 215

  
214 216
       if(ToOneRelatedEntityField.class.isAssignableFrom(editorAction.getTarget().getClass())){
217
           Set<ReferenceType> applicableTypes = ReferenceType.inReferenceContraints((ReferenceType) getView().getTypeSelect().getValue());
215 218
           if(editorAction.isAddAction()){
216 219
               inReferencePopup = openPopupEditor(ReferencePopupEditor.class, editorAction);
220
               if(!applicableTypes.isEmpty()){
221
                   inReferencePopup.withReferenceTypes(EnumSet.copyOf(applicableTypes));
222
               }
217 223
               inReferencePopup.loadInEditor(null);
224
               if(!applicableTypes.isEmpty()){
225
                   inReferencePopup.getTypeSelect().setValue(applicableTypes.iterator().next());
226
               }
218 227
           }
219 228
           if(editorAction.isEditAction()){
220 229
               inReferencePopup = openPopupEditor(ReferencePopupEditor.class, editorAction);
230
               if(!applicableTypes.isEmpty()){
231
                   inReferencePopup.withReferenceTypes(EnumSet.copyOf(applicableTypes));
232
               }
221 233
               inReferencePopup.withDeleteButton(true);
222 234
               inReferencePopup.loadInEditor(editorAction.getEntityUuid());
223 235
           }

Also available in: Unified diff