p2izing the editor
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor.prototype2 / src / eu / etaxonomy / taxeditor / prototype2 / controller / ActionMoveTaxon.java
1 package eu.etaxonomy.taxeditor.prototype2.controller;
2
3 import org.eclipse.jface.action.Action;
4
5 import eu.etaxonomy.cdm.model.taxon.Taxon;
6 import eu.etaxonomy.taxeditor.prototype2.Activator;
7
8 /**
9 * Moves taxon in the taxonomic tree by assigning it a new parent
10 * and triggering observable tree list update
11 *
12 * @author p.ciardelli
13 *
14 */
15 public class ActionMoveTaxon extends Action {
16 Taxon taxon;
17 Taxon newParentTaxon;
18
19 public ActionMoveTaxon(Taxon taxon, Taxon newParentTaxon) {
20 this.taxon = taxon;
21 this.newParentTaxon = newParentTaxon;
22 }
23
24 public void run() {
25
26 // TODO Taxon.setParentTaxon(newParentTaxon)
27 taxon.setTaxonomicParent(newParentTaxon, null, null);
28
29 // Trigger re-draw in list by removing then adding taxon
30 Activator.getDefault().getObservableTaxonTreeList().remove(taxon);
31 Activator.getDefault().getObservableTaxonTreeList().add(taxon);
32
33 // Save the taxon to the CDM
34 Activator.getDefault().getCdmApp().getTaxonService().saveTaxon(taxon);
35 }
36 }