public static String DeleteTaxonBaseHandler_CONFIRM_DELETION;
public static String DeleteTaxonBaseHandler_ELEMENT_MUST_BE_SYNONYM_MISAPP_CONCEPT;
public static String DeleteTaxonBaseHandler_REALLY_DELETE_TAXON;
+ public static String DeleteTaxonBaseHandler_REALLY_DELETE_SYNONYM;
public static String DerivateDropListener_MOVE_TO;
public static String DerivateView_DERIVATIVE_EDITOR;
public static String DerivateView_SAVING_HIERARCHY;
import org.eclipse.core.commands.IHandler;
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.handlers.HandlerUtil;
-import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.DeleteResult;
+import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
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.Messages;
import eu.etaxonomy.taxeditor.editor.Page;
+import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
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.editor.name.operation.DeleteTaxonBaseOperation;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
} catch (NotDefinedException e) {
MessagingUtils.error(getClass(), e);
}
-
+ IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
// synonym
if(selectedElement instanceof Synonym){
- operation = new DeleteSynonymOperation(commandName, editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, editor);
+ if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), Messages.DeleteTaxonBaseHandler_CONFIRM_DELETION, Messages.DeleteTaxonBaseHandler_REALLY_DELETE_SYNONYM)){
+ return ;
+ }
+ operation = new DeleteSynonymOperation(commandName, editor.getUndoContext(), new SynonymDeletionConfigurator(), activePage, editor.getTaxon(), (Synonym) selectedElement,this, editor, (ICdmEntitySessionEnabled)editor.getEditorInput());
+
}
// misapplication
else if(selectedElement instanceof Taxon && ((Taxon) selectedElement).isMisapplication()){
operation = new DeleteMisapplicationOperation(commandName, editor.getUndoContext(), editor
.getTaxon(), (Taxon) selectedElement, editor);
}
- else if (selectedElement instanceof Taxon){
- //TODO: how to get the actual classification
- if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), Messages.DeleteTaxonBaseHandler_CONFIRM_DELETION, Messages.DeleteTaxonBaseHandler_REALLY_DELETE_TAXON)){
- return ;
- }
-
- IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
-
- operation = new DeleteTaxonOperation(commandName,
- editor.getUndoContext(),
- (Taxon) selectedElement,
- new TaxonDeletionConfigurator(),
- null,
- activePage,
- this,
- editor,
- (ICdmEntitySessionEnabled)editor.getEditorInput());
- //editor.dispose();
-
- }
else {
throw new IllegalArgumentException(Messages.DeleteTaxonBaseHandler_ELEMENT_MUST_BE_SYNONYM_MISAPP_CONCEPT);
}
AbstractUtility.executeOperation(operation);
+ DeleteResult result = ((DeleteTaxonBaseOperation)operation).getResult();
+ if (result.isError()){
+ DeleteResultMessagingUtils.messageDialogWithDetails(result, Messages.DeleteDerivateOperation_DELETE_FAILED, TaxeditorEditorPlugin.PLUGIN_ID);
+ } else if (selectedElement instanceof Synonym){
+ this.editor.redraw();
+ if (!result.getUpdatedObjects().isEmpty()){
+ DeleteResultMessagingUtils.messageDialogWithDetails(result, Messages.DeleteTaxonBaseHandler_DELETE_SYNONYM_SUCCESSFULL_BUT_REMAINING_RELATED_OBJECTS, TaxeditorEditorPlugin.PLUGIN_ID);
+ }
+ }else {
+ if (!result.getUpdatedObjects().isEmpty()){
+ DeleteResultMessagingUtils.messageDialogWithDetails(result, Messages.DeleteTaxonBaseHandler_DELETE_MISAPPLIEDNAME_SUCCESSFULL_BUT_REMAINING_RELATED_OBJECTS, TaxeditorEditorPlugin.PLUGIN_ID);
+ }
+ }
+
}
@Override
public boolean postOperation(CdmBase objectAffectedByOperation) {
- Display.getDefault().asyncExec(new Runnable(){
- @Override
- public void run() {
- AbstractUtility.close(editor.getMultiPageTaxonEditor());
- }
- });
return true;
}
@Override
public boolean onComplete() {
- // TODO Auto-generated method stub
+
return false;
}
package eu.etaxonomy.taxeditor.editor.name.operation;
-import java.util.Set;
-
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 org.eclipse.ui.IWorkbenchPage;
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
+import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.api.service.DeleteResult;
import eu.etaxonomy.cdm.api.service.ITaxonService;
+import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.SynonymType;
import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
-import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils;
-import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @author p.ciardelli
* @created 14.01.2009
*/
-public class DeleteSynonymOperation extends AbstractPostTaxonOperation {
+public class DeleteSynonymOperation extends DeleteTaxonBaseOperation {
private final Synonym synonym;
private SynonymType synonymType;
+
/**
* <p>Constructor for DeleteSynonymOperation.</p>
*
* @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
*/
- public DeleteSynonymOperation(String label, IUndoContext undoContext,
- Taxon taxon, Synonym synonym, IPostOperationEnabled postOperationEnabled) {
- super(label, undoContext, taxon, postOperationEnabled);
+ public DeleteSynonymOperation(String label, IUndoContext undoContext, TaxonBaseDeletionConfigurator configurator,IWorkbenchPage activePage,
+ Taxon taxon, Synonym synonym, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled,ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
+ super(label, undoContext, configurator, activePage, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled);
this.synonym = synonym;
}
} else {
//TODO: this should be moved to the handler, the operations should not contain ui code
- DeleteResult result = service.deleteSynonym(synonym.getUuid(), null);
- if (result.isError()){
- DeleteResultMessagingUtils.messageDialogWithDetails(result, "Delete failed", TaxeditorEditorPlugin.PLUGIN_ID);
- } else if (!result.getUpdatedObjects().isEmpty()){
- DeleteResultMessagingUtils.messageDialogWithDetails(result, "The Synonym could be deleted, but related object(s) could not be deleted", TaxeditorEditorPlugin.PLUGIN_ID);
- }
+ setResult(service.deleteSynonym(synonym.getUuid(), null));
+
}
// taxon.removeSynonym(synonym);
// CdmStore.getTaxonService().deleteSynonymRelationships(synonym);
// Redraw editor if exists
return postExecute(synonym);
}
+
+ /**
+ * @return the result
+ */
+ @Override
+ public DeleteResult getResult() {
+ return result;
+ }
+
+ /**
+ * @param result the result to set
+ */
+ public void setResult(DeleteResult result) {
+ this.result = result;
+ }
}
import org.eclipse.ui.IWorkbenchPage;\r
\r
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;\r
-import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;\r
+import eu.etaxonomy.cdm.api.service.DeleteResult;\r
+import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;\r
import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;\r
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;\r
\r
public class DeleteTaxonBaseOperation extends AbstractPersistentPostOperation {\r
\r
- protected TaxonDeletionConfigurator configurator;\r
+ protected TaxonBaseDeletionConfigurator configurator;\r
+ protected DeleteResult result;\r
\r
public DeleteTaxonBaseOperation(String label,\r
IUndoContext undoContext,\r
- TaxonDeletionConfigurator configurator,\r
+ TaxonBaseDeletionConfigurator configurator,\r
IWorkbenchPage activePage,\r
IPostOperationEnabled postOperationEnabled,\r
IConversationEnabled conversationEnabled,\r
// TODO Auto-generated method stub\r
return null;\r
}\r
+\r
+ public DeleteResult getResult(){\r
+ return result;\r
+ }\r
}\r
\r
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;\r
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;\r
-import eu.etaxonomy.cdm.api.service.DeleteResult;\r
import eu.etaxonomy.cdm.api.service.ITaxonService;\r
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;\r
import eu.etaxonomy.cdm.model.taxon.Classification;\r
import eu.etaxonomy.cdm.model.taxon.Taxon;\r
import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
-import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;\r
-import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils;\r
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;\r
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;\r
import eu.etaxonomy.taxeditor.store.CdmStore;\r
\r
ITaxonService service = controller.getTaxonService();\r
\r
- DeleteResult result = service.deleteTaxon(element.getUuid(), configurator, classification.getUuid());\r
+ result = service.deleteTaxon(element.getUuid(), (TaxonDeletionConfigurator)configurator, classification.getUuid());\r
- if (result.isError()){\r
- DeleteResultMessagingUtils.messageDialogWithDetails(result, "Delete failed", TaxeditorEditorPlugin.PLUGIN_ID);\r
- } else if (!result.getUpdatedObjects().isEmpty()){\r
- DeleteResultMessagingUtils.messageDialogWithDetails(result, "The Taxon was deleted, but related object(s) could not be deleted", TaxeditorEditorPlugin.PLUGIN_ID);\r
- }\r
+\r
\r
monitor.worked(40);\r
\r
// $Id$
/**
* 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.
*/
import org.junit.BeforeClass;
import org.junit.Test;
+import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
import eu.etaxonomy.cdm.model.taxon.Synonym;
import eu.etaxonomy.cdm.model.taxon.SynonymType;
import eu.etaxonomy.cdm.model.taxon.Taxon;
private static Synonym synonym;
private static SynonymType synonymType;
-
+
/**
* @throws java.lang.Exception
*/
taxon = Taxon.NewInstance(null, null);
synonym = Synonym.NewInstance(null, null);
synonymType = SynonymType.SYNONYM_OF();
-
+
taxon.addSynonym(synonym, synonymType);
-
- operation = new DeleteSynonymOperation("", undoContext, taxon, synonym, postOperation);
+
+ operation = new DeleteSynonymOperation("", undoContext, new SynonymDeletionConfigurator(), null, taxon,synonym, postOperation, null, null);
+
}
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
operation.execute(monitor, info);
-
+
Assert.assertTrue(taxon.getSynonyms().size() == 0);
}
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
operation.undo(monitor, info);
-
+
Assert.assertTrue(taxon.getSynonyms().size() > 0);
Assert.assertEquals(synonym, taxon.getSynonyms().toArray(new Synonym[0])[0]);
}
/**
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
- * @throws ExecutionException
+ * @throws ExecutionException
*/
@Test
public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
operation.redo(monitor, info);
-
+
Assert.assertTrue(taxon.getSynonyms().size() == 0);
}
}