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.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
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.PlatformUI;
import org.eclipse.ui.navigator.CommonViewer;
import eu.etaxonomy.cdm.model.common.ICdmBase;
import eu.etaxonomy.cdm.model.description.PolytomousKey;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.Synonym;
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;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.navigation.internal.TaxeditorNavigationPlugin;
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
+import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard;
+import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
/**
* <p>NavigationUtil class.</p>
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(ICdmBase selectedObject){
UUID entityUuid = selectedObject.getUuid();
try {
- if(selectedObject instanceof TaxonNode){
+ if(selectedObject instanceof Classification){
+ NewClassificationWizard classificationWizard = new NewClassificationWizard();
+ classificationWizard.init(null, null);
+ classificationWizard.setEntity((Classification) selectedObject);
+ WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), classificationWizard);
+ dialog.open();
+ }
+ else if(selectedObject instanceof TaxonNode){
EditorUtil.openTaxonNode(entityUuid);
}else if(selectedObject instanceof TaxonBase){
EditorUtil.openTaxonBase(entityUuid);
} catch (PartInitException e) {
MessagingUtils.error(NavigationUtil.class, "Error opening the editor", e);
} catch (Exception e) {
- MessagingUtils.warningDialog("Could not create Taxon", NavigationUtil.class, e.getMessage());
- }
- }
+ MessagingUtils.errorDialog("Could not create Taxon",
+ NavigationUtil.class,
+ e.getMessage(), TaxeditorStorePlugin.PLUGIN_ID,
+ e,
+ true);
- 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));
}
}