609be0b86f2ae31ca0c628aeadd116ccd230e7eb
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / actions / cdm / MoveTaxonAction.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.actions.cdm;
11
12 import org.apache.log4j.Logger;
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.jface.viewers.ISelection;
15
16 import eu.etaxonomy.cdm.model.taxon.Taxon;
17 import eu.etaxonomy.taxeditor.TaxEditorPlugin;
18 import eu.etaxonomy.taxeditor.UiUtil;
19 import eu.etaxonomy.taxeditor.model.CdmSessionDataRepository;
20 import eu.etaxonomy.taxeditor.navigation.TaxonomicTreeViewer;
21
22 /**
23 * Moves taxon in the taxonomic tree by assigning it a new parent
24 * and triggering observable tree list update
25 *
26 * @author p.ciardelli
27 * @created 06.05.2008
28 * @version 1.0
29 */
30 public class MoveTaxonAction extends Action {
31 private static final Logger logger = Logger
32 .getLogger(MoveTaxonAction.class);
33
34 Taxon taxon;
35 Taxon newParentTaxon;
36 Taxon oldParentTaxon;
37
38 public MoveTaxonAction(Taxon taxon, Taxon newParentTaxon) {
39
40 this.taxon = taxon;
41 this.newParentTaxon = newParentTaxon;
42
43 // Save old parent taxon for undo
44 this.oldParentTaxon = taxon.getTaxonomicParent();
45 }
46
47 public void run() {
48 CdmSessionDataRepository.getDefault().
49 setTaxonomicParent(taxon, newParentTaxon);
50 new SaveTaxonAction(taxon).run();
51 }
52 }