Project

General

Profile

Download (3.22 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2011 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
package eu.etaxonomy.taxeditor.editor.view.uses.operation;
10

    
11
import org.eclipse.core.commands.ExecutionException;
12
import org.eclipse.core.commands.operations.IUndoContext;
13
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.core.runtime.IProgressMonitor;
15
import org.eclipse.core.runtime.IStatus;
16

    
17
import eu.etaxonomy.cdm.api.service.ITermService;
18
import eu.etaxonomy.cdm.model.common.Marker;
19
import eu.etaxonomy.cdm.model.common.MarkerType;
20
import eu.etaxonomy.cdm.model.description.TaxonDescription;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.taxeditor.editor.UsageTermCollection;
23
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
24
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
25
import eu.etaxonomy.taxeditor.store.CdmStore;
26

    
27
/**
28
 * CreateTaxonUseOperation Class
29
 * @author a.theys
30
 * @created mar 13, 2012
31
 * @version 1.0
32
 */
33
public class CreateTaxonUseOperation extends CreateTaxonDescriptionOperation {
34
	private TaxonDescription description;
35
	private Marker marker;
36

    
37
	/**
38
	 * <p>Constructor for CreateTaxonUseOperation.</p>
39
	 *
40
	 * @param label a {@link java.lang.String} object.
41
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
42
	 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
43
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
44
	 */
45
	public CreateTaxonUseOperation(String label, IUndoContext undoContext,
46
			Taxon taxon, IPostOperationEnabled postOperationEnabled) {
47
		this(label, undoContext, taxon, postOperationEnabled, false);
48
	}
49

    
50
	/**
51
	 * <p>Constructor for CreateTaxonUseOperation.</p>
52
	 *
53
	 * @param label a {@link java.lang.String} object.
54
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
55
	 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
56
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
57
	 * @param isImageGallery a boolean.
58
	 */
59
	public CreateTaxonUseOperation(String label, IUndoContext undoContext,
60
			Taxon taxon, IPostOperationEnabled postOperationEnabled, boolean isImageGallery) {
61
		super(label, undoContext, taxon, postOperationEnabled);
62
	}
63

    
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
66
	 */
67
	/** {@inheritDoc} */
68
	@Override
69
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
70
			throws ExecutionException {
71

    
72
		description = TaxonDescription.NewInstance(element);
73
		monitor.worked(20);
74
		MarkerType useMarkerType = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType);
75
		marker = Marker.NewInstance(useMarkerType, true);
76
		description.addMarker(marker);
77
		monitor.worked(40);
78

    
79
		return postExecute(description);
80
	}
81
}
82

    
(1-1/3)