ref #8785: update descriptions in description list after merge
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / descriptiveDataSet / matrix / MatrixUtility.java
index 1e58f93caf87dcef0984169b90b813515189e35c..909d80fe3a16fe97941f28facecb418458a66078 100644 (file)
@@ -10,11 +10,15 @@ package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
 
 import java.util.Set;
 
 
 import java.util.Set;
 
-import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.QuantitativeData;
+import org.eclipse.swt.graphics.Image;
+
+import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
+import eu.etaxonomy.cdm.model.description.DescriptionType;
 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
+import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.model.ImageResources;
 
 /**
  * Utility class for the character matrix editor
 
 /**
  * Utility class for the character matrix editor
@@ -33,30 +37,18 @@ public class MatrixUtility {
         return feature.getLabel();
     }
 
         return feature.getLabel();
     }
 
-    /**
-     * Returns a string representation for the given {@link QuantitativeData}
-     * @param data the quantitative data
-     * @return a string representation of the data
-     */
-    public static String getQuantitativeLabel(QuantitativeData data) {
-        Float min = data.getMin();
-        Float max = data.getMax();
-        return getQuantitativeLabel(min, max);
-    }
-
     /**
      * Returns a string representation for the given min/max values
      * @param minTotal the min value
      * @param maxTotal the max value
      * @return a string representation of the data
      */
     /**
      * Returns a string representation for the given min/max values
      * @param minTotal the min value
      * @param maxTotal the max value
      * @return a string representation of the data
      */
-    public static String getQuantitativeLabel(Float min, Float max) {
-        return (min==null?"?":min.toString()) //$NON-NLS-1$
-                +" - " //$NON-NLS-1$
-                +(max==null?"?":max.toString()); //$NON-NLS-1$
+    public static String getQuantitativeLabel(Float min, Float exact, Float max) {
+        return (min==null?"":"("+min.toString()+")") //$NON-NLS-1$
+                +(exact==null?"":exact.toString()) //$NON-NLS-1$
+                +(max==null?"":"("+max.toString()+")"); //$NON-NLS-1$
     }
 
     }
 
-
     public static Classification getClassificationForDescriptiveDataSet(DescriptiveDataSet descriptiveDataSet){
         Set<TaxonNode> taxonSubtreeFilter = descriptiveDataSet.getTaxonSubtreeFilter();
         if(taxonSubtreeFilter!=null && !taxonSubtreeFilter.isEmpty()){
     public static Classification getClassificationForDescriptiveDataSet(DescriptiveDataSet descriptiveDataSet){
         Set<TaxonNode> taxonSubtreeFilter = descriptiveDataSet.getTaxonSubtreeFilter();
         if(taxonSubtreeFilter!=null && !taxonSubtreeFilter.isEmpty()){
@@ -64,5 +56,34 @@ public class MatrixUtility {
         }
         return null;
     }
         }
         return null;
     }
+
+    public static boolean isDefaultTaxonDescription(TaxonRowWrapperDTO taxonRowWrapperDTO){
+        return hasType(taxonRowWrapperDTO, DescriptionType.DEFAULT_VALUES_FOR_AGGREGATION);
+    }
+
+    public static boolean isAggregatedTaxonDescription(TaxonRowWrapperDTO taxonRowWrapperDTO){
+        return hasType(taxonRowWrapperDTO, DescriptionType.AGGREGATED_STRUC_DESC);
+    }
+
+    public static boolean isLiteratureTaxonDescription(TaxonRowWrapperDTO taxonRowWrapperDTO){
+        return hasType(taxonRowWrapperDTO, DescriptionType.SECONDARY_DATA);
+    }
+
+    private static boolean hasType(TaxonRowWrapperDTO taxonRowWrapperDTO, DescriptionType descriptionType){
+        return taxonRowWrapperDTO.getDescription().getDescription().getTypes().stream()
+        .anyMatch(type->type.equals(descriptionType));
+    }
+
+    public static Image getLiteratureDescriptionIcon() {
+        return ImageResources.getImage(ImageResources.HELP_TOPIC);
+    }
+
+    public static Image getAggregatedDescriptionIcon() {
+        return ImageResources.getImage(ImageResources.FUNNEL_ICON);
+    }
+
+    public static Image getDefaultDescriptionIcon() {
+        return ImageResources.getImage(ImageResources.VALIDATE_ICON);
+    }
 }
 
 }