From c918301bac8cb360e2b3949065476be1ad52771b Mon Sep 17 00:00:00 2001
From: Katja Luther
Date: Thu, 6 Feb 2014 11:58:53 +0000
Subject: [PATCH] move the change accepted to Synonym Operation to taxon
navigator.
---
.gitattributes | 2 -
eu.etaxonomy.taxeditor.editor/plugin.xml | 20 +--
.../ChangeAcceptedTaxonToSynonymHandler.java | 134 ------------------
...ChangeAcceptedTaxonToSynonymOperation.java | 104 --------------
...hangeSynonymToMisapplicationOperation.java | 7 +-
.../MoveDescriptionToOtherTaxonHandler.java | 2 +-
eu.etaxonomy.taxeditor.navigation/plugin.xml | 17 +++
.../navigator/handler/DeleteHandler.java | 6 +-
.../navigator/operation/DeleteOperation.java | 2 +-
9 files changed, 36 insertions(+), 258 deletions(-)
delete mode 100644 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeAcceptedTaxonToSynonymHandler.java
delete mode 100644 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeAcceptedTaxonToSynonymOperation.java
diff --git a/.gitattributes b/.gitattributes
index 1d9402e02..a8ee33899 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -420,7 +420,6 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/d
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/dnd/NameEditorDragSourceEffect.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/dnd/NameEditorDropTargetEffect.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/dnd/NameEditorDropTargetListener.java -text
-eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeAcceptedTaxonToSynonymHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeSynonymToAcceptedTaxonHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeToConceptRelationHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeToMisapplicationHandler.java -text
@@ -436,7 +435,6 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/h
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/RemoveBasionymHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/SetBasionymHandler.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/SwapSynonymAndAcceptedHandler.java -text
-eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeAcceptedTaxonToSynonymOperation.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptRelationshipTypeOperation.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptToSynonymOperation.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeHomotypicGroupOperation.java -text
diff --git a/eu.etaxonomy.taxeditor.editor/plugin.xml b/eu.etaxonomy.taxeditor.editor/plugin.xml
index ad0017f0e..70cb65697 100644
--- a/eu.etaxonomy.taxeditor.editor/plugin.xml
+++ b/eu.etaxonomy.taxeditor.editor/plugin.xml
@@ -247,7 +247,7 @@
name="separator1"
visible="true">
-
@@ -261,18 +261,18 @@
-
+ -->
-
-
+
-
+ -->
- *
- * @author n.hoffmann
- * @created Jan 4, 2010
- * @version 1.0
- */
-public class ChangeAcceptedTaxonToSynonymHandler extends AbstractHandler
- implements IHandler, IPostOperationEnabled {
- private static final Logger logger = Logger
- .getLogger(ChangeAcceptedTaxonToSynonymHandler.class);
- private ChangeAcceptedTaxonToSynonymOperation operation;
-
- private UUID newAcceptedTaxonNodeUuid;
- private TaxonNameEditor editor;
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- /** {@inheritDoc} */
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(
- Page.NAME);
- TaxonNode oldAcceptedTaxonNode = ((TaxonEditorInput) editor.getEditorInput()).getTaxonNode();
-
- // check if taxon has no children
- if(oldAcceptedTaxonNode.getCountChildren() > 0) {
- EditorUtil.warningDialog("Prerequisite not met", this,
- "The accepted taxon must not have any childen. You need to move all childen to " +
- "another taxon node in the TaxonNavigator before attempting to turn the accepted " +
- "taxon into a synonym.");
- return null;
- }
-
- // Choose new accepted taxon
- List excludeTaxa = new ArrayList();
- excludeTaxa.add(oldAcceptedTaxonNode.getUuid());
- TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event),
- editor.getConversationHolder(),
- "Choose the accepted taxon",
- excludeTaxa,
- null,
- oldAcceptedTaxonNode.getClassification());
-
- if (newAcceptedTaxonNode == null) {
- return null;
- }
-
- newAcceptedTaxonNodeUuid = newAcceptedTaxonNode.getUuid();
-
- try {
- operation = new ChangeAcceptedTaxonToSynonymOperation(event.getCommand().getName(),
- editor.getUndoContext(), oldAcceptedTaxonNode, newAcceptedTaxonNode, this, editor);
- EditorUtil.executeOperation(operation);
-
- } catch (NotDefinedException e) {
- logger.warn("Command name not set");
- }
-
- return null;
-
- }
-
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
- */
- /** {@inheritDoc} */
- public boolean postOperation(CdmBase objectAffectedByOperation) {
- Display.getDefault().asyncExec(new Runnable(){
-
- public void run() {
- EditorUtil.close(editor.getMultiPageTaxonEditor());
-
- try {
- MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
- if(possibleOpenEditor != null){
- EditorUtil.close(possibleOpenEditor);
- }
- EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid);
- } catch (PartInitException e) {
- EditorUtil.error(this.getClass(), e);
- throw new RuntimeException(e);
- } catch (Exception e) {
- EditorUtil.warningDialog("Could not create Taxon", this, e.getMessage());
- }
- }
-
- });
-
-
- return true;
- }
-
- /**
- * onComplete
- *
- * @return a boolean.
- */
- public boolean onComplete() {
- // TODO Auto-generated method stub
- return false;
- }
-}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeAcceptedTaxonToSynonymOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeAcceptedTaxonToSynonymOperation.java
deleted file mode 100644
index 42dbfec25..000000000
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeAcceptedTaxonToSynonymOperation.java
+++ /dev/null
@@ -1,104 +0,0 @@
-// $Id$
-/**
-* Copyright (C) 2007 EDIT
-* 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.
-*/
-
-package eu.etaxonomy.taxeditor.editor.name.operation;
-
-import org.eclipse.core.commands.ExecutionException;
-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 eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
-import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
-import eu.etaxonomy.cdm.model.taxon.Synonym;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
-import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.store.CdmStore;
-
-/**
- * ChangeAcceptedTaxonToSynonymOperation class.
- *
- * @author n.hoffmann
- * @created Jan 4, 2010
- * @version 1.0
- */
-public class ChangeAcceptedTaxonToSynonymOperation extends
- AbstractPersistentPostOperation {
-
- private TaxonNode newAcceptedTaxonNode;
-
- private TaxonNode oldTaxonNode;
-
- /**
- * Constructor for ChangeAcceptedTaxonToSynonymOperation.
- *
- * @param label a {@link java.lang.String} object.
- * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
- * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
- * @param oldTaxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
- * @param newAcceptedTaxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
- * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
- */
- public ChangeAcceptedTaxonToSynonymOperation(String label,
- IUndoContext undoContext, TaxonNode oldTaxonNode, TaxonNode newAcceptedTaxonNode,
- IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
- super(label, undoContext, oldTaxonNode, postOperationEnabled, conversationEnabled);
- this.oldTaxonNode = oldTaxonNode;
- this.newAcceptedTaxonNode = newAcceptedTaxonNode;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
- */
- /** {@inheritDoc} */
- @Override
- public IStatus execute(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
-
- monitor.worked(20);
- bind();
- Synonym synonym = null;
- try {
- synonym = CdmStore.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode(oldTaxonNode, newAcceptedTaxonNode, null, null, null);
- } catch (DataChangeNoRollbackException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- monitor.worked(40);
-
- return postExecute(synonym);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
- */
- /** {@inheritDoc} */
- @Override
- public IStatus redo(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
- */
- /** {@inheritDoc} */
- @Override
- public IStatus undo(IProgressMonitor monitor, IAdaptable info)
- throws ExecutionException {
- // TODO Auto-generated method stub
- return null;
- }
-}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperation.java
index 3bd310bd3..65b9e1797 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperation.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperation.java
@@ -17,6 +17,7 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
import eu.etaxonomy.cdm.api.service.ITaxonService;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.taxon.Synonym;
@@ -62,7 +63,7 @@ public class ChangeSynonymToMisapplicationOperation extends AbstractPostTaxonOpe
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
- // get name from synonym
+ /*// get name from synonym
TaxonNameBase, ?> synonymName = synonym.getName();
// make misapplied name with synonym name
@@ -79,8 +80,8 @@ public class ChangeSynonymToMisapplicationOperation extends AbstractPostTaxonOpe
// add misapplied name to taxon
// TODO add microcitation for misapplied name to property sheet (if microcitation is indeed needed?!)
- element.addMisappliedName(misapplication, null, null);
-
+ element.addMisappliedName(misapplication, null, null);*/
+ misapplication = CdmStore.getService(ITaxonService.class).changeSynonymToRelatedTaxon(synonym, element, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), null, null);
// redraw editor if exists
return postExecute(misapplication);
}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java
index abddcb7a1..945af220e 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java
@@ -31,8 +31,8 @@ import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
import eu.etaxonomy.taxeditor.editor.Page;
import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
-import eu.etaxonomy.taxeditor.editor.name.operation.ChangeAcceptedTaxonToSynonymOperation;
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionToOtherTaxonOperation;
+//import eu.etaxonomy.taxeditor.navigator.operation.ChangeAcceptedTaxonToSynonymOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
diff --git a/eu.etaxonomy.taxeditor.navigation/plugin.xml b/eu.etaxonomy.taxeditor.navigation/plugin.xml
index ea92e5a52..d47aa7435 100644
--- a/eu.etaxonomy.taxeditor.navigation/plugin.xml
+++ b/eu.etaxonomy.taxeditor.navigation/plugin.xml
@@ -119,6 +119,17 @@
+
+
+
+
+
+
+
+
+
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java
index 2df882e50..ab4fc28ce 100644
--- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java
+++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java
@@ -47,8 +47,8 @@ import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
*/
public class DeleteHandler extends AbstractHandler implements IHandler{
- private IWorkbenchPage activePage;
- private TaxonNavigator taxonNavigator;
+ protected IWorkbenchPage activePage;
+ protected TaxonNavigator taxonNavigator;
/** {@inheritDoc} */
@Override
@@ -137,7 +137,7 @@ public class DeleteHandler extends AbstractHandler implements IHandler{
return null;
}
- private boolean closeObsoleteEditor(TaxonNode taxonNode){
+ protected boolean closeObsoleteEditor(TaxonNode taxonNode){
boolean result = true;
for (IEditorReference ref : activePage.getEditorReferences()) {
try {
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java
index 1f9cea4df..afad39fc6 100644
--- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java
+++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java
@@ -43,7 +43,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
public class DeleteOperation extends AbstractPersistentPostOperation{
private Set treeNodes;
- private final TaxonDeletionConfigurator config;
+ protected final TaxonDeletionConfigurator config;
/**
--
2.34.1