- generalized adding MediaSpecimen in DerivateView
authorPatric Plitzner <p.plitzner@bgbm.org>
Thu, 3 Jul 2014 13:36:19 +0000 (13:36 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Thu, 3 Jul 2014 13:36:19 +0000 (13:36 +0000)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/contextMenu/CreateDerivateContextMenu.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/media/MediaSpecimenGeneralDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/derivateSearch/DerivateLabelProvider.java

index 06aaa37cd09f03aa3bef5c12de47665fbf5f8f24..bab27cfed83353fb37aa25949f082ea979737abf 100644 (file)
@@ -8,6 +8,7 @@ import java.util.Set;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.jface.viewers.TreeViewer;
@@ -88,7 +89,7 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
         viewer.setContentProvider(new DerivateContentProvider());
         labelProvider = new DerivateLabelProvider();
         viewer.setLabelProvider(labelProvider);
-        viewer.setAutoExpandLevel(2);
+        viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
         // Propagate selection from viewer
         getSite().setSelectionProvider(viewer);
 
index c21f3696a373be7372d9c2ab62fec5bd0e22ab96..b956e86c779337c9dc9e6335f021c44b07749fe0 100644 (file)
@@ -15,7 +15,6 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.actions.CompoundContributionItem;
 
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeCacheStrategy;
-import eu.etaxonomy.cdm.model.common.DefinedTerm;
 import eu.etaxonomy.cdm.model.media.Media;
 import eu.etaxonomy.cdm.model.molecular.DnaSample;
 import eu.etaxonomy.cdm.model.molecular.Sequence;
@@ -30,7 +29,6 @@ import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
-import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider;
 
 /**
  * Context menu for the creation of derivates in the derivate hierarchy.
@@ -47,9 +45,6 @@ public class CreateDerivateContextMenu extends CompoundContributionItem {
                 new ContributionItem() {
                     @Override
                     public void fill(Menu menu, int index) {
-                        DefinedTerm artworkTerm = DerivateLabelProvider.getArtworkTerm();
-                        DefinedTerm livingPlantPhotoTerm = DerivateLabelProvider.getLivingPlantPhotoTerm();
-                        DefinedTerm specimenScanTerm = DerivateLabelProvider.getSpecimenScanTerm();
                         MenuItem addItem = new MenuItem(menu, SWT.CASCADE);
                         addItem.setText("Add...");
                         Menu addMenu = new Menu(menu);
@@ -64,18 +59,14 @@ public class CreateDerivateContextMenu extends CompoundContributionItem {
                                 new MenuItem(addMenu, SWT.SEPARATOR);
                                 createMenuItem(addMenu, "Tissue Sample", selectedTreeNode, DerivedUnit.class, SpecimenOrObservationType.TissueSample);
                                 createMenuItem(addMenu, "DNA Sample", selectedTreeNode, DnaSample.class, SpecimenOrObservationType.DnaSample);
-                                createMenuItem(addMenu, "Specimen Scan", selectedTreeNode, MediaSpecimen.class, SpecimenOrObservationType.StillImage, specimenScanTerm);
-                                createMenuItem(addMenu, "Artwork", selectedTreeNode, MediaSpecimen.class, SpecimenOrObservationType.StillImage, artworkTerm);
-                                createMenuItem(addMenu, "Living Plant Photo", selectedTreeNode, MediaSpecimen.class, SpecimenOrObservationType.StillImage, livingPlantPhotoTerm);
+                                createMenuItem(addMenu, "Media Specimen", selectedTreeNode, MediaSpecimen.class, SpecimenOrObservationType.Media);
                             }
                             //context menu for Specimen
                             else if(selectedTreeNode.getValue() instanceof DerivedUnit && ((DerivedUnit)selectedTreeNode.getValue()).getRecordBasis()==SpecimenOrObservationType.PreservedSpecimen){
 
                                 createMenuItem(addMenu, "Tissue Sample", selectedTreeNode, DerivedUnit.class, SpecimenOrObservationType.TissueSample);
                                 createMenuItem(addMenu, "DNA Sample", selectedTreeNode, DnaSample.class, SpecimenOrObservationType.DnaSample);
-                                createMenuItem(addMenu, "Specimen Scan", selectedTreeNode, MediaSpecimen.class, SpecimenOrObservationType.StillImage, specimenScanTerm);
-                                createMenuItem(addMenu, "Artwork", selectedTreeNode, MediaSpecimen.class, SpecimenOrObservationType.StillImage, artworkTerm);
-                                createMenuItem(addMenu, "Living Plant Photo", selectedTreeNode, MediaSpecimen.class, SpecimenOrObservationType.StillImage, livingPlantPhotoTerm);
+                                createMenuItem(addMenu, "Media Specimen", selectedTreeNode, MediaSpecimen.class, SpecimenOrObservationType.Media);
                             }
                             //context menu for TissueSample
                             else if(selectedTreeNode.getValue() instanceof DerivedUnit && ((DerivedUnit)selectedTreeNode.getValue()).getRecordBasis()==SpecimenOrObservationType.TissueSample){
@@ -104,14 +95,10 @@ public class CreateDerivateContextMenu extends CompoundContributionItem {
         return contributionItems;
     }
 
-    private void createMenuItem(Menu menu, String menuLabel, TreeNode selectedNode, Class<?> childClass, SpecimenOrObservationType specimenType, DefinedTerm kindOfUnit) {
+    private void createMenuItem(Menu menu, String menuLabel, TreeNode selectedNode, Class<?> childClass, SpecimenOrObservationType specimenType) {
         MenuItem menuItem = new MenuItem(menu, SWT.NONE);
         menuItem.setText(menuLabel);
-        menuItem.addSelectionListener(new WidgetSelectionListener(selectedNode, childClass, specimenType, kindOfUnit));
-    }
-
-    private void createMenuItem(Menu menu, String menuLabel, TreeNode selectedNode, Class<?> childClass, SpecimenOrObservationType specimenType) {
-        createMenuItem(menu, menuLabel, selectedNode, childClass, specimenType, null);
+        menuItem.addSelectionListener(new WidgetSelectionListener(selectedNode, childClass, specimenType));
     }
 
     private class WidgetSelectionListener extends SelectionAdapter{
@@ -120,18 +107,15 @@ public class CreateDerivateContextMenu extends CompoundContributionItem {
         //TODO: we need a common interface for the generic like e.g. "IDerivateHierarchyNode"
         private final Class<?> childClass;
         private final SpecimenOrObservationType specimenType;
-        private final DefinedTerm kindOfUnit;
 
         /**
          * @param selectedNode
          * @param specimenType
-         * @param kindOfUnit
          */
-        public WidgetSelectionListener(TreeNode selectedNode, Class<?> childClass, SpecimenOrObservationType specimenType, DefinedTerm kindOfUnit) {
+        public WidgetSelectionListener(TreeNode selectedNode, Class<?> childClass, SpecimenOrObservationType specimenType) {
             this.selectedNode = selectedNode;
             this.childClass = childClass;
             this.specimenType = specimenType;
-            this.kindOfUnit = kindOfUnit;
         }
 
         /* (non-Javadoc)
@@ -159,7 +143,6 @@ public class CreateDerivateContextMenu extends CompoundContributionItem {
                     derivedUnit = MediaSpecimen.NewInstance(specimenType);
                     //a MediaSpecimen with no media attached does not make sense. Hence we add one
                     ((MediaSpecimen)derivedUnit).setMediaSpecimen(Media.NewInstance());
-                    derivedUnit.setKindOfUnit(kindOfUnit);
                 }
                 else{
                     derivedUnit = DerivedUnit.NewInstance(specimenType);
index b4da945659ff12b50d6ca930daaea5e924f1a99b..48df3b4ab47c1c6b16f9e7f3abcb3f876e5d7145 100644 (file)
@@ -64,6 +64,9 @@ public class MediaSpecimenGeneralDetailSection  extends AbstractCdmDetailSection
             else if(getEntity().getKindOfUnit().equals(DerivateLabelProvider.getSpecimenScanTerm())){
                 text = "Specimen Scan";
             }
+            else if(getEntity().getKindOfUnit().equals(DerivateLabelProvider.getDetailImageTerm())){
+                text = "Detail Image";
+            }
         }
         if(text!=null){
             super.setText(text);
index ba8fa96b552751ec7fba20ececd391dfbbf36a49..d628deaaac6e025d30594b0895c2e23e9fb64beb 100644 (file)
@@ -49,19 +49,23 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
     private static DefinedTerm photoTerm = null;
     private static DefinedTerm drawingTerm = null;
     private static DefinedTerm specimenScanTerm = null;
+    private static DefinedTerm detailImageTerm = null;
 
     private static void initializeTerms() {
         List<DefinedTerm> preferredTerms = CdmStore.getTermManager().getPreferredTerms(DefinedTerm.class);
         for (DefinedTerm definedTerm : preferredTerms) {
-            if(definedTerm.getUuid().equals(UUID.fromString("04673952-dab1-42ff-b47a-5e847c350eaf"))){//photo
+            if(definedTerm.getUuid().equals(UUID.fromString("c5c59c42-f254-471e-96c6-09f459f7c903"))){
                 photoTerm = definedTerm;
             }
-            else if(definedTerm.getUuid().equals(UUID.fromString("76204a15-098f-4afe-9e8f-fa344ee3fdbb"))){//drawing
+            else if(definedTerm.getUuid().equals(UUID.fromString("669b0409-4aa4-4695-aae4-a95ed27bad4c"))){
                 drawingTerm = definedTerm;
             }
-            else if(definedTerm.getUuid().equals(UUID.fromString("c0b127d6-c849-48f9-bbc3-29e3337c1d03"))){//cover TODO temporary until new term is created
+            else if(definedTerm.getUuid().equals(UUID.fromString("acda15be-c0e2-4ea8-8783-b9b0c4ad7f03"))){
                 specimenScanTerm = definedTerm;
             }
+            else if(definedTerm.getUuid().equals(UUID.fromString("31eb8d02-bf5d-437c-bcc6-87a626445f34"))){
+                detailImageTerm = definedTerm;
+            }
         }
     }
 
@@ -86,6 +90,13 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
         return specimenScanTerm;
     }
 
+    public static DefinedTerm getDetailImageTerm(){
+        if(detailImageTerm==null){
+            initializeTerms();
+        }
+        return detailImageTerm;
+    }
+
 
     /** {@inheritDoc} */
     @Override
@@ -214,7 +225,7 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
             else if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.PreservedSpecimen){
                 return ImageResources.getImage(ImageResources.SPECIMEN_DERIVATE);
             }
-            else if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.StillImage){
+            else if(derivedUnit.getRecordBasis()==SpecimenOrObservationType.Media){
                 if(derivedUnit.getKindOfUnit()!=null){
                     if(derivedUnit.getKindOfUnit().equals(getArtworkTerm())){
                         return ImageResources.getImage(ImageResources.ARTWORK_DERIVATE);
@@ -225,6 +236,9 @@ public class DerivateLabelProvider extends ColumnLabelProvider {
                     else if(derivedUnit.getKindOfUnit().equals(getSpecimenScanTerm())){
                         return ImageResources.getImage(ImageResources.SPECIMEN_SCAN_DERIVATE);
                     }
+                    else if(derivedUnit.getKindOfUnit().equals(getDetailImageTerm())){
+                        return ImageResources.getImage(ImageResources.DETAIL_IMAGE_DERIVATE);
+                    }
                 }
             }
         }