ref #7095 Fill matrix asynchronously
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 12 Apr 2018 13:57:24 +0000 (15:57 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 12 Apr 2018 14:41:27 +0000 (16:41 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrixPart.java

index 4a0016841ad240d437fe1d99e5468bee2a3f5051..6a0b25b14131a3b96ecf9ee47cf1f02aacf55433 100644 (file)
@@ -22,6 +22,8 @@ import java.util.Properties;
 import java.util.Set;
 
 import org.apache.commons.collections4.map.LinkedMap;
+import org.eclipse.core.runtime.ICoreRunnable;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.layout.GridDataFactory;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.ComboViewer;
@@ -112,8 +114,8 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 
+import ca.odell.glazedlists.BasicEventList;
 import ca.odell.glazedlists.EventList;
-import ca.odell.glazedlists.GlazedLists;
 import ca.odell.glazedlists.SortedList;
 import ca.odell.glazedlists.TreeList;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
@@ -402,7 +404,7 @@ public class CharacterMatrix extends Composite {
                     for (SpecimenOrObservationBase specimen : specimens) {
                         SpecimenDescription description = getDescriptionForWorkingSet(specimen);
                         if(!workingSet.getDescriptions().contains(description)){
-                            CharacterMatrix.this.descriptions.add(new RowWrapper(description));
+                            CharacterMatrix.this.descriptions.add(new RowWrapper(description, workingSet));
                             workingSet.addDescription(description);
                             hasAdded = true;
                         }
@@ -544,7 +546,7 @@ public class CharacterMatrix extends Composite {
                 categoricalFeatureToStateMap.put(feature, supportedStates);
             }
         });
-        descriptions = GlazedLists.eventList(getDescriptions(workingSet));
+        descriptions = new BasicEventList<>();
 
     }
 
@@ -1004,15 +1006,18 @@ public class CharacterMatrix extends Composite {
 
     }
 
-    private List<RowWrapper> getDescriptions(WorkingSet workingSet) {
-        List<RowWrapper> rowWrappers = new ArrayList<>();
-        Set<DescriptionBase> wsDescriptions = workingSet.getDescriptions();
-        for (DescriptionBase descriptionBase : wsDescriptions) {
-            if(descriptionBase instanceof SpecimenDescription){
-                rowWrappers.add(new RowWrapper((SpecimenDescription) descriptionBase));
+
+    public void loadDescriptions(WorkingSet workingSet) {
+        Job job = Job.create("Load character data", (ICoreRunnable) monitor -> {
+            List<RowWrapper> rowWrappers = new ArrayList<>();
+            Set<DescriptionBase> wsDescriptions = workingSet.getDescriptions();
+            for (DescriptionBase descriptionBase : wsDescriptions) {
+                if(descriptionBase instanceof SpecimenDescription){
+                    CharacterMatrix.this.descriptions.add(new RowWrapper((SpecimenDescription) descriptionBase, workingSet));
+                }
             }
-        }
-        return rowWrappers;
+        });
+        job.schedule();
     }
 
     public List<State> getSupportedStatesForCategoricalFeature(Feature feature){
index 4cac32e5ab5bfcafc707c59bddf6fb8643017fbc..e97c72f94f34ad6c5159516eb8616d39261eb09d 100644 (file)
@@ -107,6 +107,7 @@ ICdmEntitySessionEnabled{
             matrix.initWorkingSet(workingSet);
             matrix.createTable(treeView);
             thisPart.setLabel(workingSet.getLabel());
+            matrix.loadDescriptions(workingSet);
         }
     }