import java.util.Set;
import java.util.UUID;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-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.IEditorReference;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.navigator.CommonViewer;
import eu.etaxonomy.cdm.model.common.ICdmBase;
import eu.etaxonomy.cdm.model.taxon.Taxon;
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
public class NavigationUtil extends AbstractUtility{
private static IUndoContext defaultUndoContext;
- /**
- * <p>executeEditHandler</p>
- */
- public static void executeEditHandler(){
-
- String commandId = "eu.etaxonomy.taxeditor.navigation.command.update.editSelection";
-
- IHandlerService handlerService = (IHandlerService) AbstractUtility.getService(IHandlerService.class);
- try {
- handlerService.executeCommand(commandId, null);
- } catch (ExecutionException e) {
- MessagingUtils.error(NavigationUtil.class, e);
- } catch (NotDefinedException e) {
- MessagingUtils.error(NavigationUtil.class, e);
- } catch (NotEnabledException e) {
- MessagingUtils.error(NavigationUtil.class, e);
- } catch (NotHandledException e) {
- MessagingUtils.error(NavigationUtil.class, e);
- }
- }
-
/**
* <p>openEditor</p>
*
}
}
- public static void openEditor(Object selectedObject){
- if (selectedObject instanceof UuidAndTitleCache){
- Class type = ((UuidAndTitleCache) selectedObject).getType();
- if(type == Taxon.class || type == Synonym.class){
- try {
- EditorUtil.openTaxonBase(((UuidAndTitleCache) selectedObject).getUuid());
- } catch (PartInitException e) {
- MessagingUtils.error(NavigationUtil.class, "Error opening the editor", e);
- }
- }
- }else if(selectedObject instanceof ICdmBase){
- openEditor((ICdmBase) selectedObject);
- }else{
- MessagingUtils.error(NavigationUtil.class, new IllegalArgumentException("Selected object is not supported: " + selectedObject));
- }
- }
-
/**
* <p>openEmpty</p>
*