move source section to the bottom of typedesignation section
authorKatja Luther <k.luther@bgbm.org>
Tue, 22 Oct 2019 12:35:22 +0000 (14:35 +0200)
committerKatja Luther <k.luther@bgbm.org>
Tue, 22 Oct 2019 12:35:22 +0000 (14:35 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/AbstractTypeDesignationElement.java

index bdddbffb3e56c6ba5187b22b17c4c5f151667228..bc5ad43946d5f745c1b54eab93209d61501f7699 100644 (file)
@@ -74,7 +74,7 @@ public abstract class AbstractTypeDesignationElement<T extends TypeDesignationBa
        @Override
        public void setEntity(T entity){
            super.setEntity(entity);
-           sourceSection.setEntity(entity);
+           removeSourcesControls();
 
            if (this.entity != null && this.entity.hasDesignationSource()){
                if (selection_reference == null){
@@ -97,6 +97,9 @@ public abstract class AbstractTypeDesignationElement<T extends TypeDesignationBa
                 }
             }
         }
+           sourceSection = formFactory.createSourceSection(getConversationHolder(), formElement, StoreUtil.getSectionStyle(SourceSection.class, IdentifiableSource.class.getCanonicalName()));
+        sourceSection.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+        sourceSection.setEntity(entity);
         StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
 
        }
@@ -173,6 +176,34 @@ public abstract class AbstractTypeDesignationElement<T extends TypeDesignationBa
 
         }
 
+    }
+
+    public void removeSourcesControls(){
+        for (Iterator<ICdmFormElement> iterator = getElements().iterator();iterator.hasNext();) {
+            ICdmFormElement childElement = iterator.next();
+            // recursion
+           if (childElement instanceof SourceSection) {
+                childElement.removeElements();
+
+                getElements().remove(childElement);
+
+                // unregister selection arbitrator
+                if(childElement instanceof ISelectableElement){
+                    SelectionArbitrator selectionArbitrator = ((ISelectableElement) childElement).getSelectionArbitrator();
+                    if(selectionArbitrator != null){
+                        formFactory.destroySelectionArbitrator(selectionArbitrator);
+                    }
+                }
+
+                // unregister from property changes
+                formFactory.removePropertyChangeListener(childElement);
+                ((SourceSection)childElement).dispose();
+                sourceSection = null;
+                break;
+           }
+
+        }
+
     }
     @Override
     public void handleEvent(Object eventSource) {