ref #3866 Fix instanceOf check for classification taxon nodes
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 5 Jul 2017 09:04:03 +0000 (11:04 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 5 Jul 2017 09:06:05 +0000 (11:06 +0200)
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java

index 6680e5f40ab29f1ccb9902ff6801734b0766bdcc..3c27532c734e4e98eb964393196bbae959ecbd90 100644 (file)
@@ -106,14 +106,20 @@ public class NavigationUtil extends AbstractUtility{
                UUID entityUuid = selectedObject.getUuid();
                try {
                        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);
+                           TaxonNode taxonNode = (TaxonNode)selectedObject;
+                           Classification classification = taxonNode.getClassification();
+                           if(classification!=null && classification.getRootNode().equals(taxonNode)){
+                               NewClassificationWizard classificationWizard = new NewClassificationWizard();
+                               classificationWizard.init(null, null);
+                               classificationWizard.setEntity(classification);
+                               WizardDialog dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), classificationWizard);
+                               dialog.open();
+                           }
+                           else{
+                               EditorUtil.openTaxonNode(entityUuid);
+                           }
                        }else if(selectedObject instanceof TaxonBase){
                                TaxonBase taxonBase = (TaxonBase)selectedObject;
                                if(taxonBase.isOrphaned()){
@@ -142,8 +148,8 @@ public class NavigationUtil extends AbstractUtility{
        }
 
        private static void openInBulkEditor(ICdmBase selectedObject) {
-               ICommandService commandService = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
-               IHandlerService handlerService = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
+               ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
+               IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
                String openInBulkEditorCommand = "eu.etaxonomy.taxeditor.bulkeditor.openBulkEditorForIdentifiableEntity"; //$NON-NLS-1$
                Command command = commandService.getCommand(openInBulkEditorCommand);
                if(command.isDefined()){