package eu.etaxonomy.taxeditor.navigation;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.commands.operations.UndoContext;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.navigator.CommonViewer;
import eu.etaxonomy.cdm.api.service.IClassificationService;
else if(selectedObject instanceof TaxonNode){
EditorUtil.openTaxonNode(entityUuid);
}else if(selectedObject instanceof TaxonBase){
- EditorUtil.openTaxonBase(entityUuid);
+ TaxonBase taxonBase = (TaxonBase)selectedObject;
+ if(taxonBase.isOrphaned()){
+ openInBulkEditor(taxonBase);
+ }
+ else{
+ EditorUtil.openTaxonBase(entityUuid);
+ }
}else if(selectedObject instanceof TaxonNameBase){
- // TODO open bulk editor
- 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");
+ openInBulkEditor(selectedObject);
}else if(selectedObject instanceof PolytomousKey){
EditorUtil.openPolytomousKey(entityUuid);
}else{
}
}
+ private static void openInBulkEditor(ICdmBase selectedObject) {
+ ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
+ IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
+ String openInBulkEditorCommand = "eu.etaxonomy.taxeditor.bulkeditor.openBulkEditorForIdentifiableEntity";
+ Command command = commandService.getCommand(openInBulkEditorCommand);
+ if(command.isDefined()){
+ Map<String, UUID> params = new HashMap<String, UUID>();
+ params.put(openInBulkEditorCommand+".uuid", ((ICdmBase) selectedObject).getUuid()); //$NON-NLS-1$
+ ParameterizedCommand parameterizedCommand = ParameterizedCommand.generateCommand(command, params);
+ try {
+ if(parameterizedCommand!=null){
+ handlerService.executeCommand(parameterizedCommand, null);
+ return;
+ }
+ else{
+ handlerService.executeCommand(command.getId(), null);
+ return;
+ }
+ } catch (NotDefinedException nde) {
+ throw new RuntimeException("Could not find open command: " + command.getId()); //$NON-NLS-1$
+ } catch (Exception exception) {
+ MessagingUtils.error(NavigationUtil.class, "An exception occured while trying to execute "+command.getId(), exception); //$NON-NLS-1$
+ }
+ }
+ }
+
/**
* <p>openEmpty</p>
*