9 |
9 |
|
10 |
10 |
package eu.etaxonomy.taxeditor.navigation;
|
11 |
11 |
|
|
12 |
import java.util.HashMap;
|
|
13 |
import java.util.Map;
|
12 |
14 |
import java.util.Set;
|
13 |
15 |
import java.util.UUID;
|
14 |
16 |
|
|
17 |
import org.eclipse.core.commands.Command;
|
|
18 |
import org.eclipse.core.commands.ParameterizedCommand;
|
|
19 |
import org.eclipse.core.commands.common.NotDefinedException;
|
15 |
20 |
import org.eclipse.core.commands.operations.IUndoContext;
|
16 |
21 |
import org.eclipse.core.commands.operations.UndoContext;
|
17 |
22 |
import org.eclipse.jface.viewers.StructuredSelection;
|
... | ... | |
23 |
28 |
import org.eclipse.ui.IWorkbenchWindow;
|
24 |
29 |
import org.eclipse.ui.PartInitException;
|
25 |
30 |
import org.eclipse.ui.PlatformUI;
|
|
31 |
import org.eclipse.ui.commands.ICommandService;
|
|
32 |
import org.eclipse.ui.handlers.IHandlerService;
|
26 |
33 |
import org.eclipse.ui.navigator.CommonViewer;
|
27 |
34 |
|
28 |
35 |
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
... | ... | |
103 |
110 |
else if(selectedObject instanceof TaxonNode){
|
104 |
111 |
EditorUtil.openTaxonNode(entityUuid);
|
105 |
112 |
}else if(selectedObject instanceof TaxonBase){
|
106 |
|
EditorUtil.openTaxonBase(entityUuid);
|
|
113 |
TaxonBase taxonBase = (TaxonBase)selectedObject;
|
|
114 |
if(taxonBase.isOrphaned()){
|
|
115 |
openInBulkEditor(taxonBase);
|
|
116 |
}
|
|
117 |
else{
|
|
118 |
EditorUtil.openTaxonBase(entityUuid);
|
|
119 |
}
|
107 |
120 |
}else if(selectedObject instanceof TaxonNameBase){
|
108 |
|
// TODO open bulk editor
|
109 |
|
MessagingUtils.warningDialog("Not implemented yet", NavigationUtil.class, "You tried to open a name. This is not handled by the software yet. For open a pure name you can use the bulk editor");
|
|
121 |
openInBulkEditor(selectedObject);
|
110 |
122 |
}else if(selectedObject instanceof PolytomousKey){
|
111 |
123 |
EditorUtil.openPolytomousKey(entityUuid);
|
112 |
124 |
}else{
|
... | ... | |
124 |
136 |
}
|
125 |
137 |
}
|
126 |
138 |
|
|
139 |
private static void openInBulkEditor(ICdmBase selectedObject) {
|
|
140 |
ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
|
|
141 |
IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
|
|
142 |
String openInBulkEditorCommand = "eu.etaxonomy.taxeditor.bulkeditor.openBulkEditorForIdentifiableEntity";
|
|
143 |
Command command = commandService.getCommand(openInBulkEditorCommand);
|
|
144 |
if(command.isDefined()){
|
|
145 |
Map<String, UUID> params = new HashMap<String, UUID>();
|
|
146 |
params.put(openInBulkEditorCommand+".uuid", ((ICdmBase) selectedObject).getUuid()); //$NON-NLS-1$
|
|
147 |
ParameterizedCommand parameterizedCommand = ParameterizedCommand.generateCommand(command, params);
|
|
148 |
try {
|
|
149 |
if(parameterizedCommand!=null){
|
|
150 |
handlerService.executeCommand(parameterizedCommand, null);
|
|
151 |
return;
|
|
152 |
}
|
|
153 |
else{
|
|
154 |
handlerService.executeCommand(command.getId(), null);
|
|
155 |
return;
|
|
156 |
}
|
|
157 |
} catch (NotDefinedException nde) {
|
|
158 |
throw new RuntimeException("Could not find open command: " + command.getId()); //$NON-NLS-1$
|
|
159 |
} catch (Exception exception) {
|
|
160 |
MessagingUtils.error(NavigationUtil.class, "An exception occured while trying to execute "+command.getId(), exception); //$NON-NLS-1$
|
|
161 |
}
|
|
162 |
}
|
|
163 |
}
|
|
164 |
|
127 |
165 |
/**
|
128 |
166 |
* <p>openEmpty</p>
|
129 |
167 |
*
|
ref #5616 Add alternative to double click execution in search view