Project

General

Profile

Download (2.84 KB) Statistics
| Branch: | Tag: | Revision:
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.store.operations;
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.name.TaxonNameBase;
20
import eu.etaxonomy.cdm.model.taxon.Taxon;
21
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
22
import eu.etaxonomy.taxeditor.store.parser.CdmParserUtil;
23

    
24
/**
25
 * @author p.ciardelli
26
 * @created 21.01.2009
27
 * @version 1.0
28
 * @author n.hoffmann
29
 */
30
public class CreateMisapplicationOperation extends AbstractPostOperation {
31
	private static final Logger logger = Logger
32
			.getLogger(CreateMisapplicationOperation.class);
33
	
34
	private Taxon misapplication;
35

    
36
	public CreateMisapplicationOperation(String label, IUndoContext undoContext,
37
			Taxon taxon, IPostOperationEnabled editor) {
38
		super(label, undoContext, taxon, editor);
39
	}
40

    
41
	/* (non-Javadoc)
42
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
43
	 */
44
	@Override
45
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
46
			throws ExecutionException {
47
		
48
		// Create empty new name
49
		TaxonNameBase misapplicationName = 
50
				CdmParserUtil.parseFullReference("", null, null);
51
		
52
		// make misapplication name with misapplication name
53
		misapplication = Taxon.NewInstance(misapplicationName, null);
54
						
55
		// add misapplied name to taxon
56
		// TODO add microcitation for misapplied name to property sheet
57
		taxon.addMisappliedName(misapplication, null, null);	
58
		
59
		// redraw editor if exists
60
		return postExecute(misapplication);
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
	@Override
67
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
68
			throws ExecutionException {
69
		return execute(monitor, info);
70
	}
71

    
72
	/* (non-Javadoc)
73
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
74
	 */
75
	@Override
76
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
77
			throws ExecutionException {
78
		
79
		// Remove misapplied name from taxon
80
		taxon.removeTaxon(misapplication, TaxonRelationshipType.MISAPPLIED_NAME_FOR());
81
					
82
		// Redraw editor if exists
83
		return postExecute(null);
84
	}
85
}
(16-16/28)