adapt context menu to navigator changes
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / AbstractCdmViewPart.java
index 03acaeb247bdf7d4af4a919fcf122eb5820d784e..978859801b0b5929c1ebf2002f3627ac035f0aeb 100644 (file)
@@ -1,4 +1,3 @@
-// $Id$
 /**
  * Copyright (C) 2007 EDIT
  * European Distributed Institute of Taxonomy
@@ -12,6 +11,7 @@ package eu.etaxonomy.taxeditor.view;
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
@@ -23,7 +23,6 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.ui.ISelectionListener;
 import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.part.PageBook;
 import org.eclipse.ui.part.ViewPart;
 
@@ -50,7 +49,7 @@ public abstract class AbstractCdmViewPart extends ViewPart implements ISelection
 
     public static IStructuredSelection EMPTY_SELECTION = new StructuredSelection();
 
-    protected IWorkbenchPart part;
+    protected Object part;
 
     private PageBook pageBook;
 
@@ -75,11 +74,8 @@ public abstract class AbstractCdmViewPart extends ViewPart implements ISelection
         setInitialSelection();
     }
 
-    /**
-     *
-     */
     private void setInitialSelection() {
-        selectionChanged(AbstractUtility.getActivePart(), getInitialSelection());
+        selectionChanged(AbstractUtility.getActiveWorkbenchPart(), getInitialSelection());
     }
 
     /**
@@ -95,6 +91,7 @@ public abstract class AbstractCdmViewPart extends ViewPart implements ISelection
      * <p>showEmptyPage</p>
      */
     public void showEmptyPage(){
+       setPartName(createPartTitle(null));
         pageBook.showPage(emptySelectionLabel);
     }
 
@@ -104,13 +101,17 @@ public abstract class AbstractCdmViewPart extends ViewPart implements ISelection
      * @param part a {@link org.eclipse.ui.IWorkbenchPart} object.
      * @param selection a {@link org.eclipse.jface.viewers.ISelection} object.
      */
-    public void showViewer(IWorkbenchPart part, IStructuredSelection selection){
+    public void showViewer(Object part, IStructuredSelection selection){
         this.part = part;
 
         Object element = selection.getFirstElement();
+      //avoid widget is disposed exceptions
+        if (getViewer().getControl()==null || getViewer().getControl().isDisposed()){
+            return;
+        }
 
+        setPartName(createPartTitle(element));
         getViewer().setInput(element);
-
         showViewer();
     }
 
@@ -185,7 +186,7 @@ public abstract class AbstractCdmViewPart extends ViewPart implements ISelection
     }
 
     @Override
-    public  List<CdmBase> getRootEntities() {
+    public  List<? extends CdmBase> getRootEntities() {
         return Arrays.asList((CdmBase)getViewer().getInput());
     }
 
@@ -209,4 +210,23 @@ public abstract class AbstractCdmViewPart extends ViewPart implements ISelection
     public void forceDirty() {
         changed(null);
     }
+
+
+    /* (non-Javadoc)
+     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled#getPropertyPathsMap()
+     */
+    @Override
+    public Map<Object, List<String>> getPropertyPathsMap() {
+        // 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();
 }