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