Refactor generic "open in..." framework
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / CdmViewerContextMenu.java
index 2811fe14a38fc719795857cae83e4b0b24fe4f7f..bfe10e7cd4b71689bd8a9f8c55d66e599dbf7c25 100644 (file)
@@ -20,7 +20,6 @@ import org.eclipse.swt.widgets.MenuItem;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.actions.CompoundContributionItem;
-import org.eclipse.ui.commands.ICommandService;
 import org.eclipse.ui.handlers.IHandlerService;
 
 import eu.etaxonomy.cdm.model.common.ICdmBase;
@@ -43,8 +42,7 @@ public class CdmViewerContextMenu extends CompoundContributionItem {
                         final ISelection selection = window.getActivePage().getSelection();
                         if(selection instanceof IStructuredSelection){
                             Object firstElement = ((IStructuredSelection) selection).getFirstElement();
-                            Map<String, String> availableViewers = CdmViewerUtil.getAvailableViewers(firstElement);
-                            Map<Command, String> enabledCommands = getEnabledCommands(availableViewers);
+                            Map<Command, String> enabledCommands = CdmViewerUtil.getAvailableViewers(firstElement);
 
                             //check if only one or multiple viewers/commands are available
                             if(enabledCommands.size()==1){
@@ -78,19 +76,6 @@ public class CdmViewerContextMenu extends CompoundContributionItem {
         return contributionItems;
     }
 
-    private Map<Command, String> getEnabledCommands(Map<String, String> availableViewers) {
-        Map<Command, String> enabledCommands = new HashMap<Command, String>();
-        for(Entry<String, String> entry:availableViewers.entrySet()){
-            final String commandId = entry.getKey();
-            ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
-            Command command = commandService.getCommand(commandId);
-            if(command.isEnabled()){
-                enabledCommands.put(command, entry.getValue());
-            }
-        }
-        return enabledCommands;
-    }
-
     private final class CommandInvoker extends SelectionAdapter {
         private final Command command;
         private final Object selectedObject;