- added context menu entry for editing classifications
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / CdmViewerChooser.java
index a862b694640103098dda6844f3a2bcb5bb5875d0..3b3909385445adf05e0d0ad3d47bb5aabc711996 100644 (file)
@@ -13,6 +13,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IExtensionRegistry;
@@ -50,6 +51,7 @@ public class CdmViewerChooser extends PopupDialog implements ISelectionChangedLi
 
     private Object input;
     private Map<Entry<Class<?>, String>, ICdmViewer> nameViewerMap;
+    private ExecutionEvent executionEvent;
 
     public CdmViewerChooser(Shell parentShell) {
         this(parentShell, SWT.RESIZE | SWT.ON_TOP, true, false, false, false, false, "Open in ...",
@@ -66,9 +68,11 @@ public class CdmViewerChooser extends PopupDialog implements ISelectionChangedLi
     /**
      * Opens a popup dialog with all possible viewers for the given input.
      * @param input the input for which the viewers are listed
+     * @param event the {@link ExecutionEvent} if invoked via command/handler
      */
-    public void chooseViewer(Object input){
+    public void chooseViewer(Object input, ExecutionEvent event){
         this.input = input;
+        this.executionEvent = event;
         this.nameViewerMap = new HashMap<Entry<Class<?>, String>, ICdmViewer>();
 
         IExtensionRegistry reg = Platform.getExtensionRegistry();
@@ -95,7 +99,7 @@ public class CdmViewerChooser extends PopupDialog implements ISelectionChangedLi
         if(nameViewerMap.size()==1){
             Entry<Class<?>, String> next = nameViewerMap.keySet().iterator().next();
             ICdmViewer cdmViewer = nameViewerMap.get(next);
-            cdmViewer.show(input, next.getKey());
+            cdmViewer.show(input, next.getKey(), event);
         }
         else{
             if(nameViewerMap.isEmpty()){
@@ -129,7 +133,7 @@ public class CdmViewerChooser extends PopupDialog implements ISelectionChangedLi
             if(nameViewerMap.containsKey(firstElement)){
                 Entry<Class<?>, String> entry = (Entry<Class<?>, String>)firstElement;
                 ICdmViewer cdmViewer = nameViewerMap.get(entry);
-                cdmViewer.show(input, entry.getKey());
+                cdmViewer.show(input, entry.getKey(), this.executionEvent);
                 this.close();
             }
         }