From: p.plitzner
Date: Wed, 17 Feb 2016 17:06:53 +0000 (+0100)
Subject: Fix type check in CdmViewerChooser
X-Git-Tag: 4.0.0^2~139
X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/ad56b4cd5922a09f24b4c4aca11c496ea155e64e
Fix type check in CdmViewerChooser
---
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerChooser.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerChooser.java
index 09f378404..330301f8f 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerChooser.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/CdmViewerChooser.java
@@ -74,7 +74,7 @@ public class CdmViewerChooser extends PopupDialog implements ISelectionChangedLi
//if only one editor is available then open it
if(nameViewerMap.size()==1){
Command command = nameViewerMap.keySet().iterator().next();
- executeCommand(command.getId(), input);
+ executeCommand(command, input);
}
else{
if(nameViewerMap.isEmpty()){
@@ -84,15 +84,12 @@ public class CdmViewerChooser extends PopupDialog implements ISelectionChangedLi
}
}
- private void executeCommand(String commandId, Object input) {
- ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
- //get the command from plugin.xml
- Command command = commandService.getCommand(commandId);
-
+ private void executeCommand(Command command, Object input) {
//set uuid parameter
if(input instanceof ICdmBase){
Map params = new HashMap();
- params.put(commandId+".uuid", ((ICdmBase) input).getUuid());
+ String commandId = command.getId();
+ params.put(commandId+".uuid", ((ICdmBase) input).getUuid());
//build the parameterized command
ParameterizedCommand pc = ParameterizedCommand.generateCommand(command, params);
@@ -125,8 +122,8 @@ public class CdmViewerChooser extends PopupDialog implements ISelectionChangedLi
ISelection selection = event.getSelection();
if(selection instanceof IStructuredSelection){
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
- if(firstElement instanceof String && nameViewerMap.containsKey(firstElement)){
- executeCommand((String) firstElement, this.input);
+ if(firstElement instanceof Command && nameViewerMap.containsKey(firstElement)){
+ executeCommand((Command) firstElement, this.input);
this.close();
}
}