Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / operation / DeleteNameRelationOperation.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor.editor.name.operation;
11
12 import org.eclipse.core.commands.ExecutionException;
13 import org.eclipse.core.commands.operations.IUndoContext;
14 import org.eclipse.core.runtime.IAdaptable;
15 import org.eclipse.core.runtime.IProgressMonitor;
16 import org.eclipse.core.runtime.IStatus;
17
18 import eu.etaxonomy.cdm.model.name.NameRelationship;
19 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
20 import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
21 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
22
23 /**
24 * <p>DeleteNameRelationOperation class.</p>
25 *
26 * @author n.hoffmann
27 * @created Mar 30, 2010
28 * @version 1.0
29 */
30 public class DeleteNameRelationOperation extends AbstractPostTaxonOperation {
31
32 private NameRelationship nameRelationship;
33
34 /**
35 * <p>Constructor for DeleteNameRelationOperation.</p>
36 *
37 * @param label a {@link java.lang.String} object.
38 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
39 * @param nameRelationship a {@link eu.etaxonomy.cdm.model.name.NameRelationship} object.
40 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
41 */
42 public DeleteNameRelationOperation(String label, IUndoContext undoContext, NameRelationship nameRelationship,
43 IPostOperationEnabled postOperationEnabled) {
44 super(label, undoContext, postOperationEnabled);
45 this.nameRelationship = nameRelationship;
46 }
47
48 /* (non-Javadoc)
49 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
50 */
51 /** {@inheritDoc} */
52 @Override
53 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
54 throws ExecutionException {
55
56 TaxonNameBase fromName = nameRelationship.getFromName();
57
58 fromName.removeRelationToTaxonName(nameRelationship.getToName());
59
60 return postExecute(null);
61 }
62
63 /* (non-Javadoc)
64 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
65 */
66 /** {@inheritDoc} */
67 @Override
68 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
69 throws ExecutionException {
70 return execute(monitor, info);
71 }
72
73 /* (non-Javadoc)
74 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
75 */
76 /** {@inheritDoc} */
77 @Override
78 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
79 throws ExecutionException {
80 // TODO Auto-generated method stub
81 return null;
82 }
83 }