merge from trunk
authorCherian Mathew <c.mathew@bgbm.org>
Thu, 29 Jan 2015 10:17:48 +0000 (10:17 +0000)
committerCherian Mathew <c.mathew@bgbm.org>
Thu, 29 Jan 2015 10:17:48 +0000 (10:17 +0000)
eu.etaxonomy.taxeditor.bulkeditor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonBaseOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteTaxonOperation.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveFactualDataHandler.java

index b92d3e139e14589c0fd46011ad5389caabf87d97..cb64bf7b38e7e45ce98ba1f9fa6f76e1f53cac0d 100644 (file)
          <menu\r
                id="bulkeditor.menus.openmenu"\r
                label="%menu.label">\r
+            <visibleWhen\r
+                  checkEnabled="true">\r
+               <reference\r
+                     definitionId="isCdmStoreConnected">\r
+               </reference>\r
+            </visibleWhen>\r
          </menu>\r
          <menu\r
                label="%menu.label.0">\r
+            <visibleWhen\r
+                  checkEnabled="true">\r
+               <reference\r
+                     definitionId="isCdmStoreConnected">\r
+               </reference>\r
+            </visibleWhen>\r
          </menu>\r
       </menuContribution>\r
       <menuContribution\r
          <dynamic\r
                class="eu.etaxonomy.taxeditor.bulkeditor.command.OpenBulkEditorContributionItem"\r
                id="taxeditor-bulkeditor.dynamicopenmenu">\r
+            <visibleWhen\r
+                  checkEnabled="true">\r
+               <reference\r
+                     definitionId="isCdmStoreConnected">\r
+               </reference>\r
+            </visibleWhen>\r
          </dynamic>\r
          <!--command\r
                commandId="taxeditor-nameeditor.commands.open"\r
             <dynamic\r
                   class="eu.etaxonomy.taxeditor.bulkeditor.command.DynamicNewObjectMenu"\r
                   id="eu.etaxonomy.taxeditor.bulkeditor.dynamicNewMenu">\r
+               <visibleWhen\r
+                     checkEnabled="false">\r
+                  <reference\r
+                        definitionId="isCdmStoreConnected">\r
+                  </reference>\r
+               </visibleWhen>\r
             </dynamic>\r
+            <visibleWhen\r
+                  checkEnabled="true">\r
+               <reference\r
+                     definitionId="isCdmStoreConnected">\r
+               </reference>\r
+            </visibleWhen>\r
          </menu>\r
          <separator\r
                name="taxeditor-bulkeditor.separator1"\r
                   class="eu.etaxonomy.taxeditor.bulkeditor.command.DynamicMarkerTypeEditingMenu"\r
                   id="eu.etaxonomy.taxeditor.bulkeditor.dynamicMarkerTypeEditingMenu">\r
             </dynamic>\r
+            <visibleWhen\r
+                  checkEnabled="true">\r
+               <reference\r
+                     definitionId="isCdmStoreConnected">\r
+               </reference>\r
+            </visibleWhen>\r
          </menu>\r
          <separator\r
                name="taxeditor-bulkeditor.separator3"\r
                commandId="org.eclipse.ui.edit.delete"\r
                label="Delete"\r
                style="push">\r
+            <visibleWhen\r
+                  checkEnabled="true">\r
+               <reference\r
+                     definitionId="isCdmStoreConnected">\r
+               </reference>\r
+            </visibleWhen>\r
          </command>\r
       </menuContribution>\r
    </extension>\r
index 86240cb151f15d8270c6b60ca0ebc6caa45bfa5f..ed85b64c00acdb64cf79575bc147cb35fb9d14b0 100644 (file)
@@ -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;
        }
-       
-       
+
 }
index 4f8472074f3b34aad9c99e5e0a10dc096a93fc0c..c65dda535e5f559e04d9da813723b6cab3b6d58f 100644 (file)
@@ -5,31 +5,23 @@ import org.eclipse.core.commands.operations.IUndoContext;
 import org.eclipse.core.runtime.IAdaptable;\r
 import org.eclipse.core.runtime.IProgressMonitor;\r
 import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.ui.IEditorInput;\r
-import org.eclipse.ui.IEditorReference;\r
-import org.eclipse.ui.IPerspectiveDescriptor;\r
-import org.eclipse.ui.IViewPart;\r
 import org.eclipse.ui.IWorkbenchPage;\r
-import org.eclipse.ui.PartInitException;\r
 \r
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
-import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;\r
+import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;\r
 import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;\r
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
 \r
 public class DeleteTaxonBaseOperation extends AbstractPersistentPostOperation {\r
-       \r
-       private IWorkbenchPage activePage;\r
-       \r
+\r
+       protected TaxonDeletionConfigurator configurator;\r
+\r
        public DeleteTaxonBaseOperation(String label, IUndoContext undoContext,\r
-                       Taxon taxon, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {\r
+               TaxonDeletionConfigurator configurator, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {\r
                super(label, undoContext, postOperationEnabled,\r
                                 conversationEnabled);\r
-               this.activePage = activePage;\r
-               \r
+               this.configurator = configurator;\r
+\r
        }\r
 \r
        @Override\r
@@ -52,25 +44,4 @@ public class DeleteTaxonBaseOperation extends AbstractPersistentPostOperation {
                // TODO Auto-generated method stub\r
                return null;\r
        }\r
-       \r
-       protected void closeObsoleteEditor(Taxon taxon){\r
-               for (IEditorReference ref : activePage.getEditorReferences()) {\r
-                       \r
-                       IViewPart view =  activePage.findView("eu.etaxonomy.taxeditor.navigation.navigator");\r
-               \r
-                       try {\r
-                               IEditorInput input = ref.getEditorInput(); \r
-                               if (input instanceof TaxonEditorInput) {\r
-                                       TaxonNode node = ((TaxonEditorInput) input).getTaxonNode();\r
-                                       if (taxonNode.equals(node)) {\r
-                                               activePage.closeEditor(ref.getEditor(false), false);\r
-                                       }\r
-                               }\r
-                       } catch (PartInitException e) {\r
-                               continue;\r
-                       }\r
-               }\r
-       }\r
 }\r
-\r
-\r
index 98626f5d855ebf7f4318faf18a6eb41a9941d3ae..e7cd64a7ec18092c53e40af40a99353d30a04200 100644 (file)
@@ -23,15 +23,12 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;\r
 \r
 public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{\r
-       //private Taxon taxon;\r
-       private final Classification classification;\r
-\r
-\r
 \r
+    private final Classification classification;\r
 \r
        public DeleteTaxonOperation(String label, IUndoContext undoContext,\r
-                       Taxon taxon, Classification classification, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {\r
-               super(label, undoContext, taxon, activePage, postOperationEnabled, conversationEnabled);\r
+                       Taxon taxon, TaxonDeletionConfigurator configurator, Classification classification, IWorkbenchPage activePage, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {\r
+               super(label, undoContext, configurator, activePage, postOperationEnabled, conversationEnabled);\r
                this.element = taxon;\r
 \r
                Set<TaxonNode> nodes = taxon.getTaxonNodes();\r
@@ -52,8 +49,6 @@ public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{
 \r
        }\r
 \r
-\r
-\r
        @Override\r
        public IStatus execute(IProgressMonitor monitor, IAdaptable info)\r
                        throws ExecutionException {\r
@@ -64,17 +59,16 @@ public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{
 \r
                                ICdmApplicationConfiguration controller;\r
 \r
-                               controller = (ICdmApplicationConfiguration) CdmStore.getCurrentApplicationConfiguration();\r
+                               controller = CdmStore.getCurrentApplicationConfiguration();\r
 \r
                                ITaxonService service = controller.getTaxonService();\r
-                               \r
 \r
-                               DeleteResult result =   service.deleteTaxon(element, new TaxonDeletionConfigurator(), classification);\r
+\r
+                               DeleteResult result =   service.deleteTaxon(element, configurator, classification);\r
                                if (result.isError()){\r
                                        MessageDialog.openError(null, "Delete failed", result.getExceptions().get(0).getMessage());\r
                                }\r
 \r
-                               //closeObsoleteEditor(taxon);\r
                                monitor.worked(40);\r
 \r
 \r
@@ -95,5 +89,4 @@ public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{
                return null;\r
        }\r
 \r
-\r
-}\r
+}
\ No newline at end of file
index ce5b2bf1e7ca4d290d74434446ca931b4431f607..d89a11fda672cc994a353abcbc617d7d0460bee3 100644 (file)
@@ -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());
                             }
+                        }
 
-                        });
-                    }
+                    });
                 }
             }
         }