show media information for taxa in bulk editor
authorKatja Luther <k.luther@bgbm.org>
Tue, 17 Feb 2015 12:09:46 +0000 (12:09 +0000)
committerKatja Luther <k.luther@bgbm.org>
Tue, 17 Feb 2015 12:09:46 +0000 (12:09 +0000)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaContentProvider.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewPart.java

index 44c8ce7b68bfe028ab563b5ec34322f9f8a7b25d..cfb8f9d967d3c3be681d30980f81ecb746083a6d 100644 (file)
@@ -49,6 +49,8 @@ import eu.etaxonomy.taxeditor.model.IDerivedUnitFacadePart;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
+import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
+
 
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -63,7 +65,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  * @version 1.0
  */
 public class BulkEditor extends AnnotatedLineEditor implements IPartContentHasDetails,
-        IDirtyMarkable, IDerivedUnitFacadePart, IPartContentHasFactualData {
+        IDirtyMarkable, IDerivedUnitFacadePart, IPartContentHasFactualData, IPartContentHasMedia {
 
        /** Constant <code>ID="bulkeditor.editor"</code> */
        public static final String ID = "bulkeditor.editor";
index 9fda8be48f5dd208769fe2dece4ee55207c1ec04..0e4a261059b225fe59d662dbec7a4aef007943dd 100644 (file)
@@ -21,6 +21,7 @@ import org.eclipse.jface.viewers.Viewer;
 
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.SpecimenDescription;
@@ -29,6 +30,7 @@ import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 
@@ -47,8 +49,15 @@ public class MediaContentProvider implements ITreeContentProvider{
        @Override
     public Object[] getChildren(Object parentElement) {
 
-               if (parentElement instanceof TaxonEditorInput) {
-                       Taxon taxon = ((TaxonEditorInput) parentElement).getTaxon();
+               if (parentElement instanceof TaxonEditorInput || parentElement instanceof Taxon) {
+                       
+                       Taxon taxon = null;
+                       if (parentElement instanceof TaxonEditorInput){
+                               taxon = ((TaxonEditorInput) parentElement).getTaxon(); 
+                       } else{
+                               taxon = HibernateProxyHelper.deproxy(parentElement, Taxon.class);
+                       }
+                        
                        if(taxon == null){
                                MessagingUtils.error(getClass(), "Taxon is null", null);
                                return NO_CHILDREN;
index 77514d2c8de10db322cf85389cb2e164bc6c8089..809aa1e269c1e6563950b1ada1aab5c811d8cae4 100644 (file)
 
 package eu.etaxonomy.taxeditor.editor.view.media;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.eclipse.jface.action.GroupMarker;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.jface.viewers.TreeViewer;
@@ -28,11 +32,18 @@ import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IWorkbenchActionConstants;
 import org.eclipse.ui.IWorkbenchPart;
 
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.description.IDescribable;
+import eu.etaxonomy.cdm.model.media.IMediaDocumented;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveContentProvider;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
+import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
 import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
 import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
@@ -51,8 +62,9 @@ public class MediaViewPart extends AbstractCdmEditorViewPart implements IPartCon
        /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.view.medi"{trunked}</code> */
        public static final String ID = "eu.etaxonomy.taxeditor.editor.view.media";
 
-       private TreeViewer viewer;
 
+       private TreeViewer viewer;
+       
        /*
         * (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.model.AbstractCdmViewPart#createViewer(org.eclipse.swt.widgets.Composite)
@@ -63,7 +75,7 @@ public class MediaViewPart extends AbstractCdmEditorViewPart implements IPartCon
 
                viewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL
                                | SWT.V_SCROLL | SWT.FULL_SELECTION));
-
+               
                viewer.setContentProvider(new MediaContentProvider());
                viewer.setLabelProvider(new MediaLabelProvider());
                viewer.setAutoExpandLevel(2);
@@ -116,14 +128,18 @@ public class MediaViewPart extends AbstractCdmEditorViewPart implements IPartCon
                        IEditorInput input = ((IEditorPart) part).getEditorInput();
                        showViewer(part, new StructuredSelection(input));
                    }
-                   else if(selection instanceof IStructuredSelection){
-                       Object firstElement = ((IStructuredSelection) selection).getFirstElement();
+                   else if(selection instanceof IStructuredSelection
+                               && ((IStructuredSelection) selection).getFirstElement() instanceof IDescribable<?>
+                               && part instanceof IPartContentHasFactualData  && !(((IStructuredSelection) selection).getFirstElement() instanceof SpecimenOrObservationBase && part instanceof BulkEditor)){
+                       Object firstElement = ((IStructuredSelection) selection).getFirstElement();
                        if(firstElement instanceof TreeNode){
                            showViewer(part, new StructuredSelection(((TreeNode) firstElement).getValue()));
                        }
                        else{
                            showViewer(part, (IStructuredSelection) selection);
                        }
+                   }else{
+                       showEmptyPage();
                    }
                }
                else{