Merge branch 'release/5.28.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / section / AbstractEntityCollectionElement.java
index 57f94cfc04415df18a5f85da1b16f0c7629135b3..7044b08db673fc3eada00ef359ee82f9a038aa94 100644 (file)
@@ -29,6 +29,7 @@ import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.IEnableableFormElement;
 import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
 import eu.etaxonomy.taxeditor.ui.element.ISelectable;
 import eu.etaxonomy.taxeditor.ui.element.LabelElement;
@@ -46,7 +47,7 @@ import eu.etaxonomy.taxeditor.ui.element.LayoutConstants;
 public abstract class AbstractEntityCollectionElement<ENTITY>
         extends AbstractCdmFormElement
         implements IEntityElement<ENTITY>, SelectionListener,
-              IConversationEnabled {
+              IConversationEnabled, IEnableableFormElement {
 
        protected ENTITY entity;
 
@@ -56,6 +57,10 @@ public abstract class AbstractEntityCollectionElement<ENTITY>
         * Composite "around" the actual content. Is used for control action like e.g. remove button
         */
        private final Composite box;
+       
+       private boolean isEnabled;
+
+       
 
        private Button btnRemove;
     protected Button btnChooseEntity;
@@ -106,11 +111,13 @@ public abstract class AbstractEntityCollectionElement<ENTITY>
                        btnRemove.setToolTipText("Remove");
 
                        btnRemove.addSelectionListener(removeListener);
+                       btnRemove.setEnabled(isEnabled);
                }
 
-               createControls(this, style);
+               
 
                setEntity(entity);
+               createControls(this, style);
        }
 
        /**
@@ -250,4 +257,26 @@ public abstract class AbstractEntityCollectionElement<ENTITY>
             warnForReferencedObjects.setVisible(isVisible);
         }
     }
+    
+    @Override
+       public void setEnabled(boolean enabled) {
+               this.isEnabled = enabled;
+               if (btnRemove != null){
+                       btnRemove.setEnabled(enabled);
+               }
+               if (btnChooseEntity != null){
+                       btnChooseEntity.setEnabled(enabled);
+               }
+               
+               for (ICdmFormElement element:this.getElements()){
+                       if (element instanceof IEnableableFormElement){
+                               ((IEnableableFormElement)element).setEnabled(enabled);
+                       }
+               }
+       }
+
+       @Override
+       public boolean isEnabled() {
+               return isEnabled;
+       }
 }