Type module largely complete.
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / operations / name / ChangeConceptRelationOperation.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.operations.name;
11
12 import org.apache.log4j.Logger;
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.taxon.Taxon;
20 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
21 import eu.etaxonomy.taxeditor.operations.AbstractEditorOperation;
22
23 /**
24 * @author n.hoffmann
25 * @created 03.02.2009
26 * @version 1.0
27 */
28 public class ChangeConceptRelationOperation extends AbstractEditorOperation {
29
30
31 private static final Logger logger = Logger
32 .getLogger(ChangeConceptRelationOperation.class);
33 private Taxon relatedTaxon;
34 private TaxonRelationshipType oldRelationshipType;
35 private TaxonRelationshipType newRelationshipType;
36
37 public ChangeConceptRelationOperation(String label,
38 IUndoContext undoContext, Taxon taxon, Taxon relatedTaxon, TaxonRelationshipType type) {
39 super(label, undoContext, taxon);
40 this.relatedTaxon = relatedTaxon;
41 // this.oldRelationshipType = relatedTaxon.get
42 this.newRelationshipType = type;
43 }
44
45 /* (non-Javadoc)
46 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
47 */
48 @Override
49 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
50 throws ExecutionException {
51 // Remove relatedTaxon and old relationship
52 // FIXME since taxon relationships come in a set, which relationships are we going to delete here?
53 // taxon.removeTaxon(relatedTaxon, oldRelationshipType);
54 // Add new relationship
55 // TODO add microcitation for misapplied name to property sheet
56 relatedTaxon.addTaxonRelation(taxon, newRelationshipType, null, null);
57
58 return redrawOpenEditor();
59 }
60
61 /* (non-Javadoc)
62 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
63 */
64 @Override
65 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
66 throws ExecutionException {
67 return execute(monitor, info);
68 }
69
70 /* (non-Javadoc)
71 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
72 */
73 @Override
74 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
75 throws ExecutionException {
76 // see FIXME in execute()
77 logger.warn("Not implemented yet. See developer documentation for details");
78 return null;
79 }
80 }