ref #9821: all sources of description should be disabled
authorKatja Luther <k.luther@bgbm.org>
Tue, 26 Oct 2021 08:18:36 +0000 (10:18 +0200)
committerKatja Luther <k.luther@bgbm.org>
Tue, 26 Oct 2021 08:18:36 +0000 (10:18 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementSourceElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementSourceSection.java

index 27f29c201e30556ff7bf2b1a75338bc2aec1f249..a75e1bd98f4e45bc0a6b7933b6968030e5ba82f5 100644 (file)
@@ -34,8 +34,6 @@ import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
  * @version 1.0
  */
 public class DescriptionElementSourceElement extends
-//        AbstractEntityCollectionElement<Reference> {
-
                AbstractOriginalSourceElement<DescriptionElementSource> implements
                IEntityElement<DescriptionElementSource>{//, IEnableableFormElement {
     private EntitySelectionElement<Reference> selection_descriptionElementSource;
index d3a7f0863765ba27d4a2345c23f0f17c87587aa0..54063aa4435efedb149a135a036a833ea1fa23c7 100644 (file)
@@ -15,12 +15,20 @@ import java.util.Comparator;
 import java.util.HashSet;
 import java.util.List;
 
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
 import eu.etaxonomy.cdm.model.reference.OriginalSourceBase;
 import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
 import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.preference.Resources;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
@@ -89,8 +97,7 @@ public class DescriptionElementSourceSection extends
                }else{
                    List<OriginalSourceBase> elements = new ArrayList<>(collectionDescription);
                    Collections.sort(elements, getComparator());
-                       createDynamicContents(elements);
-                       getEntityCollectionElement().setEnabled(false);
+                   createDynamicContentsDisabled(elements);                    
                        forceExpansion = true;
                }
 
@@ -163,4 +170,23 @@ public class DescriptionElementSourceSection extends
            return sources;
            
        }
+       
+       
+       private void createDynamicContentsDisabled(Collection<OriginalSourceBase> elements)
+       {
+               int i = 0;
+               for(final OriginalSourceBase element : elements){
+                       SelectionAdapter removeListener = new SelectionAdapter(){
+                               @Override
+                               public void widgetSelected(SelectionEvent e) {
+                                       removeElement(element);
+                                       internalUpdateSection(true);
+                               }
+                       };
+                       boolean modulo = i++%2 == 0;
+                       String colorResource = modulo ? Resources.COLOR_LIST_EVEN : Resources.COLOR_LIST_ODD;
+                       createElementComposite(element, removeListener, AbstractUtility.getColor(colorResource));
+                       getEntityCollectionElement().setEnabled(false);
+               }
+       }
 }
\ No newline at end of file