commit 662c457c6fad1e45b15d82e7cb603aa8afe7e9d5
Author: Cherian Mathew <c.mathew@bgbm.org>
Date:   Thu Jan 29 10:17:48 2015 +0000

    merge from trunk

diff --git a/eu.etaxonomy.taxeditor.bulkeditor/plugin.xml b/eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
index b92d3e139..cb64bf7b3 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
+++ b/eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
@@ -39,9 +39,21 @@
          <menu
                id="bulkeditor.menus.openmenu"
                label="%menu.label">
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
          </menu>
          <menu
                label="%menu.label.0">
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
          </menu>
       </menuContribution>
       <menuContribution
@@ -49,6 +61,12 @@
          <dynamic
                class="eu.etaxonomy.taxeditor.bulkeditor.command.OpenBulkEditorContributionItem"
                id="taxeditor-bulkeditor.dynamicopenmenu">
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
          </dynamic>
          <!--command
                commandId="taxeditor-nameeditor.commands.open"
@@ -69,7 +87,19 @@
             <dynamic
                   class="eu.etaxonomy.taxeditor.bulkeditor.command.DynamicNewObjectMenu"
                   id="eu.etaxonomy.taxeditor.bulkeditor.dynamicNewMenu">
+               <visibleWhen
+                     checkEnabled="false">
+                  <reference
+                        definitionId="isCdmStoreConnected">
+                  </reference>
+               </visibleWhen>
             </dynamic>
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
          </menu>
          <separator
                name="taxeditor-bulkeditor.separator1"
@@ -127,6 +157,12 @@
                   class="eu.etaxonomy.taxeditor.bulkeditor.command.DynamicMarkerTypeEditingMenu"
                   id="eu.etaxonomy.taxeditor.bulkeditor.dynamicMarkerTypeEditingMenu">
             </dynamic>
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
          </menu>
          <separator
                name="taxeditor-bulkeditor.separator3"
@@ -136,6 +172,12 @@
                commandId="org.eclipse.ui.edit.delete"
                label="Delete"
                style="push">
+            <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isCdmStoreConnected">
+               </reference>
+            </visibleWhen>
          </command>
       </menuContribution>
    </extension>
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java
index 86240cb15..ed85b64c0 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java
@@ -1,8 +1,8 @@
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -16,19 +16,19 @@ import org.eclipse.core.commands.common.NotDefinedException;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.handlers.HandlerUtil;
 
+import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.taxon.Synonym;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
 import eu.etaxonomy.taxeditor.editor.Page;
 import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
 import eu.etaxonomy.taxeditor.editor.name.operation.DeleteMisapplicationOperation;
 import eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation;
 import eu.etaxonomy.taxeditor.editor.name.operation.DeleteTaxonOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
@@ -47,16 +47,17 @@ public class DeleteTaxonBaseHandler extends AbstractHandler implements IHandler,
 	 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 	 */
 	/** {@inheritDoc} */
-	public Object execute(ExecutionEvent event) throws ExecutionException {
+	@Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
 		editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(Page.NAME);
-				
+
 		Object selectedElement = EditorUtil.getSelection(event).getFirstElement();
-		
+
 		doExecute(event, editor, selectedElement);
-		
+
 		return null;
 	}
-	
+
 	/**
 	 * @param editor
 	 * @param selectedElement
@@ -65,14 +66,14 @@ public class DeleteTaxonBaseHandler extends AbstractHandler implements IHandler,
 	 */
 	protected void doExecute(ExecutionEvent event, TaxonNameEditor editor, Object selectedElement) {
 		AbstractPostOperation operation = null;
-		String commandName = null;		
+		String commandName = null;
 
 		try {
 			commandName = event.getCommand().getName();
 		} catch (NotDefinedException e) {
 			MessagingUtils.error(getClass(), e);
 		}
-		
+
 		// synonym
 		if(selectedElement instanceof Synonym){
 			operation = new DeleteSynonymOperation(commandName, editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, editor);
@@ -87,35 +88,29 @@ public class DeleteTaxonBaseHandler extends AbstractHandler implements IHandler,
 			if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Are you sure you want to delete the selected taxon?")){
 				return ;
 			}
+
 			IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
-			
-			operation = new DeleteTaxonOperation(commandName, editor.getUndoContext(),(Taxon) selectedElement, null, activePage, this, editor);
+
+			operation = new DeleteTaxonOperation(commandName, editor.getUndoContext(),(Taxon) selectedElement, new TaxonDeletionConfigurator(), null, activePage, this, editor);
 			//editor.dispose();
-			
+
 		}
 		else {
 			throw new IllegalArgumentException("Element has to be Synonym, Misapplication or Concept");
 		}
-				
-		EditorUtil.executeOperation(operation);
-		
-		
-		
-		
+
+		AbstractUtility.executeOperation(operation);
 	}
 
 	@Override
 	public boolean postOperation(CdmBase objectAffectedByOperation) {
 		Display.getDefault().asyncExec(new Runnable(){
 
-			public void run() {
-				EditorUtil.close(editor.getMultiPageTaxonEditor());
-					
+			@Override
+            public void run() {
+				AbstractUtility.close(editor.getMultiPageTaxonEditor());
 			}
-			
 		});
-		
-		
 		return true;
 	}
 
@@ -124,6 +119,5 @@ public class DeleteTaxonBaseHandler extends AbstractHandler implements IHandler,
 		// TODO Auto-generated method stub
 		return false;
 	}
-	
-	
+
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonBaseOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonBaseOperation.java
index 4f8472074..c65dda535 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonBaseOperation.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonBaseOperation.java
@@ -5,31 +5,23 @@ import org.eclipse.core.commands.operations.IUndoContext;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IPerspectiveDescriptor;
-import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
 
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
+import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
 import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 
 public class DeleteTaxonBaseOperation extends AbstractPersistentPostOperation {
-	
-	private IWorkbenchPage activePage;
-	
+
+	protected TaxonDeletionConfigurator configurator;
+
 	public DeleteTaxonBaseOperation(String label, IUndoContext undoContext,
-			Taxon taxon, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
+	        TaxonDeletionConfigurator configurator, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
 		super(label, undoContext, postOperationEnabled,
 				 conversationEnabled);
-		this.activePage = activePage;
-		
+		this.configurator = configurator;
+
 	}
 
 	@Override
@@ -52,25 +44,4 @@ public class DeleteTaxonBaseOperation extends AbstractPersistentPostOperation {
 		// TODO Auto-generated method stub
 		return null;
 	}
-	
-	protected void closeObsoleteEditor(Taxon taxon){
-		for (IEditorReference ref : activePage.getEditorReferences()) {
-			
-			IViewPart view =  activePage.findView("eu.etaxonomy.taxeditor.navigation.navigator");
-		
-			try {
-				IEditorInput input = ref.getEditorInput(); 
-				if (input instanceof TaxonEditorInput) {
-					TaxonNode node = ((TaxonEditorInput) input).getTaxonNode();
-					if (taxonNode.equals(node)) {
-						activePage.closeEditor(ref.getEditor(false), false);
-					}
-				}
-			} catch (PartInitException e) {
-				continue;
-			}
-		}
-	}
 }
-
-
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java
index 98626f5d8..e7cd64a7e 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java
@@ -23,15 +23,12 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{
-	//private Taxon taxon;
-	private final Classification classification;
-
-
 
+    private final Classification classification;
 
 	public DeleteTaxonOperation(String label, IUndoContext undoContext,
-			Taxon taxon, Classification classification, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
-		super(label, undoContext, taxon, activePage, postOperationEnabled, conversationEnabled);
+			Taxon taxon, TaxonDeletionConfigurator configurator, Classification classification, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
+		super(label, undoContext, configurator, activePage, postOperationEnabled, conversationEnabled);
 		this.element = taxon;
 
 		Set<TaxonNode> nodes = taxon.getTaxonNodes();
@@ -52,8 +49,6 @@ public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{
 
 	}
 
-
-
 	@Override
 	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
 			throws ExecutionException {
@@ -64,17 +59,16 @@ public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{
 
 				ICdmApplicationConfiguration controller;
 
-				controller = (ICdmApplicationConfiguration) CdmStore.getCurrentApplicationConfiguration();
+				controller = CdmStore.getCurrentApplicationConfiguration();
 
 				ITaxonService service = controller.getTaxonService();
-				
 
-				DeleteResult result =	service.deleteTaxon(element, new TaxonDeletionConfigurator(), classification);
+
+				DeleteResult result =	service.deleteTaxon(element, configurator, classification);
 				if (result.isError()){
 					MessageDialog.openError(null, "Delete failed", result.getExceptions().get(0).getMessage());
 				}
 
-				//closeObsoleteEditor(taxon);
 				monitor.worked(40);
 
 
@@ -95,5 +89,4 @@ public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{
 		return null;
 	}
 
-
-}
+}
\ No newline at end of file
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveFactualDataHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveFactualDataHandler.java
index ce5b2bf1e..d89a11fda 100644
--- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveFactualDataHandler.java
+++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveFactualDataHandler.java
@@ -100,31 +100,31 @@ public class MoveFactualDataHandler extends AbstractHandler {
                         CdmStore.getService(IDescriptionService.class).saveOrUpdate(description);
                         navigator.getConversationHolder().bind();
                         navigator.getConversationHolder().commit();
+                    }
 
-                        Display.getDefault().asyncExec(new Runnable(){
+                    Display.getDefault().asyncExec(new Runnable(){
 
-                            @Override
-                            public void run() {
-                                try {
-                                    //close and re-open to refresh factual data view
-                                    MultiPageTaxonEditor sourceEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(sourceTaxonNode.getUuid());
-                                    MultiPageTaxonEditor targetEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(targetTaxonNode.getUuid());
-                                    if(targetEditor != null){
-                                        AbstractUtility.close(sourceEditor);
-                                        AbstractUtility.close(targetEditor);
-                                    }
-                                    EditorUtil.openTaxonNode(sourceTaxonNode.getUuid());
-                                    EditorUtil.openTaxonNode(targetTaxonNode.getUuid());
-                                } catch (PartInitException e) {
-                                    MessagingUtils.error(this.getClass(), e);
-                                    throw new RuntimeException(e);
-                                } catch (Exception e) {
-                                    MessagingUtils.warningDialog("Could not create Taxon", this, e.getMessage());
+                        @Override
+                        public void run() {
+                            try {
+                                //close and re-open to refresh factual data view
+                                MultiPageTaxonEditor sourceEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(sourceTaxonNode.getUuid());
+                                MultiPageTaxonEditor targetEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(targetTaxonNode.getUuid());
+                                if(targetEditor != null){
+                                    AbstractUtility.close(sourceEditor);
+                                    AbstractUtility.close(targetEditor);
                                 }
+                                EditorUtil.openTaxonNode(sourceTaxonNode.getUuid());
+                                EditorUtil.openTaxonNode(targetTaxonNode.getUuid());
+                            } catch (PartInitException e) {
+                                MessagingUtils.error(this.getClass(), e);
+                                throw new RuntimeException(e);
+                            } catch (Exception e) {
+                                MessagingUtils.warningDialog("Could not create Taxon", this, e.getMessage());
                             }
+                        }
 
-                        });
-                    }
+                    });
                 }
             }
         }
