Generalize title creation for cdm view parts
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 19 Sep 2016 10:37:44 +0000 (12:37 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 19 Sep 2016 12:39:08 +0000 (14:39 +0200)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/referencingobjects/ReferencingObjectsView.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/ConceptViewPart.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/graph/ConceptGraphView.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/MediaViewPart.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/AbstractCdmViewPart.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewPart.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/supplementaldata/SupplementalDataViewPart.java

index 75bf240efa6960ee7ea20b9c9c316f804dde4786..ff5b0a6dfc3a8ab721487348af9ddeebb4f669ed 100644 (file)
@@ -392,4 +392,9 @@ public class ReferencingObjectsView extends AbstractCdmViewPart {
 
        }
 
+       @Override
+       protected String getViewName() {
+               return "Referencing Objects";
+       }
+
 }
index 8fa2c650fcabf673b9cea369e06ea1202c11fe06..93c7cabaa43d7d70c1db2441b9657740b07e4cf7 100644 (file)
@@ -32,8 +32,8 @@ import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
 import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
+import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
 import eu.etaxonomy.taxeditor.editor.key.AbstractGraphKeyEditor;
-import eu.etaxonomy.taxeditor.editor.view.media.MediaViewPart;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
@@ -87,15 +87,20 @@ implements IPartContentHasDetails, IPartContentHasSupplementalData{
                                IEditorInput input = ((IEditorPart) part).getEditorInput();
                                showViewer(part, new StructuredSelection(input));
                        }
-                       else{
-                               showViewer();
-                       }
                }
                else {
                    showEmptyPage();
                }
 
        }
+       
+       @Override
+       protected String createPartTitle(Object selectedObject) {
+               if(selectedObject instanceof TaxonEditorInput){
+                       return super.createPartTitle(((TaxonEditorInput) selectedObject).getTaxon());
+               }
+               return super.createPartTitle(selectedObject);
+       }
 
        @Override
        public boolean onComplete() {
@@ -165,4 +170,9 @@ implements IPartContentHasDetails, IPartContentHasSupplementalData{
 
        }
 
+       @Override
+       protected String getViewName() {
+               return "Concept Relations";
+       }
+
 }
index 01ca52b887b002e49c861b3d5e9bc1b9bba5b3e9..356e9e5cddc2f1b4922ea04309376fce690f833a 100644 (file)
@@ -123,5 +123,10 @@ public class ConceptGraphView extends AbstractCdmEditorViewPart {
                return layoutAlgoritm;
        }
 
+       @Override
+       protected String getViewName() {
+               return "Concept Graph";
+       }
+
 
 }
index b61efaa48f9eef794f3922ebdcbdb45704cea269..cf0b7d927d6f6e2078faa4b7103d948826cc2b30 100644 (file)
@@ -56,7 +56,6 @@ import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
 import eu.etaxonomy.taxeditor.model.ImageResources;
-import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
 import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
 import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
@@ -156,7 +155,6 @@ public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IP
        @Override
     protected void selectionChanged_internal(IWorkbenchPart part, ISelection selection) {
                if(AbstractUtility.getActiveEditor() == null){
-                   setPartName(createPartTitle(null));
                        showEmptyPage();
                        return;
                }
@@ -187,27 +185,19 @@ public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IP
                        && ((IStructuredSelection) selection).getFirstElement() instanceof IDescribable<?>
                        && part instanceof IPartContentHasFactualData  && !(((IStructuredSelection) selection).getFirstElement() instanceof SpecimenOrObservationBase && part instanceof BulkEditor)){
                    featureNodeContainerCache.clear();
-               setPartName(createPartTitle(((IStructuredSelection) selection).getFirstElement()));
                    showViewer(part, (IStructuredSelection) selection);
                    return;
                }
                else{
-            setPartName(createPartTitle(null));
                    showEmptyPage();
                }
        }
-
+       @Override
        protected String getViewName(){
            return Messages.DescriptiveViewPart_FACTUAL_DATA;
        }
 
-       private String createPartTitle(Object selectedObject){
-           if(selectedObject!=null){
-               return getViewName()+": "+selectedObject; //$NON-NLS-1$
-           }
-        return getViewName();
-       }
-
        /**
         *
         * @author n.hoffmann
index 28beab559a53cd7205b2c1df62378d0effb27c8d..8d0e3e7772af4d849842e2374180e6d29c8c2d7a 100644 (file)
@@ -34,7 +34,6 @@ import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
-import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
 import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
 import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
@@ -152,4 +151,9 @@ public class MediaViewPart extends AbstractCdmEditorViewPart implements IPartCon
     public boolean onComplete() {
                return true;
        }
+
+       @Override
+       protected String getViewName() {
+               return "Media";
+       }
 }
index 4367e2b835c2863bbe8ffcac66720b81c2c1657d..5ea7369b2cfd87b06d806e34fac30e70aebd987d 100644 (file)
@@ -96,6 +96,7 @@ public abstract class AbstractCdmViewPart extends ViewPart implements ISelection
      * <p>showEmptyPage</p>
      */
     public void showEmptyPage(){
+       setPartName(createPartTitle(null));
         pageBook.showPage(emptySelectionLabel);
     }
 
@@ -113,6 +114,8 @@ public abstract class AbstractCdmViewPart extends ViewPart implements ISelection
         if (getViewer().getControl()==null || getViewer().getControl().isDisposed()){
             return;
         }
+
+        setPartName(createPartTitle(element));
         getViewer().setInput(element);
         showViewer();
     }
@@ -222,4 +225,13 @@ public abstract class AbstractCdmViewPart extends ViewPart implements ISelection
         // TODO Auto-generated method stub
         return null;
     }
+    
+       protected String createPartTitle(Object selectedObject){
+           if(selectedObject!=null){
+               return getViewName()+": "+selectedObject; //$NON-NLS-1$
+           }
+        return getViewName();
+       }
+       
+    protected abstract String getViewName();
 }
index 0f0df4522f04f5a863b8c5b756af12afdf544653..a7713c6f80ff5d6e0da2a406a7aa01ad779c3588 100644 (file)
@@ -70,7 +70,6 @@ public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartC
 
         if((part instanceof IEditorPart) || (part instanceof IPartContentHasDetails)) {
             if(structuredSelection.size() != 1){
-                setPartName(createPartTitle(null));
                 showEmptyPage();
                 return;
             }
@@ -80,26 +79,23 @@ public class DetailsViewPart extends AbstractCdmEditorViewPart implements IPartC
                 // do show the map for distributions
                 Feature feature = ((FeatureNodeContainer) ((IStructuredSelection) selection).getFirstElement()).getFeature();
                 if(!feature.equals(Feature.DISTRIBUTION())){
-                    setPartName(createPartTitle(null));
                     showEmptyPage();
                     return;
                 }
             }
-
-
-            setPartName(createPartTitle(((IStructuredSelection) selection).getFirstElement()));
             showViewer(part, structuredSelection);
         }else{
-            setPartName(createPartTitle(null));
             showEmptyPage();
         }
        }
 
-       private String getViewName(){
+       @Override
+       protected String getViewName(){
            return "Details";
        }
 
-       private String createPartTitle(Object selectedObject){
+       @Override
+       protected String createPartTitle(Object selectedObject){
            if(selectedObject!=null){
                if(selectedObject instanceof TreeNode){
                    selectedObject = ((TreeNode) selectedObject).getValue();
index 984c3c6f206199c1cc44e0afb2b28bdc8adff4e4..efb6648df9f0e767aa9d9aa85de5e384d246d4ac 100644 (file)
@@ -123,4 +123,10 @@ public class SupplementalDataViewPart extends AbstractCdmEditorViewPart {
                // TODO Auto-generated method stub
                return false;
        }
+
+
+       @Override
+       protected String getViewName() {
+               return "Supplemental Data";
+       }
 }