c3d73a28ed98ffd3b215e22210b0c78116b2216a
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / view / uses / operation / CreateTaxonUseOperation.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 package eu.etaxonomy.taxeditor.editor.view.uses.operation;
10
11 import java.util.UUID;
12
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.api.service.ITermService;
20 import eu.etaxonomy.cdm.model.common.Marker;
21 import eu.etaxonomy.cdm.model.common.MarkerType;
22 import eu.etaxonomy.cdm.model.description.TaxonDescription;
23 import eu.etaxonomy.cdm.model.taxon.Taxon;
24 import eu.etaxonomy.taxeditor.editor.UsageTermCollection;
25 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
26 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
27 import eu.etaxonomy.taxeditor.store.CdmStore;
28
29 /**
30 * CreateTaxonUseOperation Class
31 * @author a.theys
32 * @created mar 13, 2012
33 * @version 1.0
34 */
35 public class CreateTaxonUseOperation extends CreateTaxonDescriptionOperation {
36 private TaxonDescription description;
37 private Marker marker;
38
39 /**
40 * <p>Constructor for CreateTaxonUseOperation.</p>
41 *
42 * @param label a {@link java.lang.String} object.
43 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
44 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
45 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
46 */
47 public CreateTaxonUseOperation(String label, IUndoContext undoContext,
48 Taxon taxon, IPostOperationEnabled postOperationEnabled) {
49 this(label, undoContext, taxon, postOperationEnabled, false);
50 }
51
52 /**
53 * <p>Constructor for CreateTaxonUseOperation.</p>
54 *
55 * @param label a {@link java.lang.String} object.
56 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
57 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
58 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
59 * @param isImageGallery a boolean.
60 */
61 public CreateTaxonUseOperation(String label, IUndoContext undoContext,
62 Taxon taxon, IPostOperationEnabled postOperationEnabled, boolean isImageGallery) {
63 super(label, undoContext, taxon, postOperationEnabled);
64 }
65
66 /* (non-Javadoc)
67 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
68 */
69 /** {@inheritDoc} */
70 @Override
71 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
72 throws ExecutionException {
73
74 description = TaxonDescription.NewInstance(taxon);
75 monitor.worked(20);
76 MarkerType useMarkerType = (MarkerType) CdmStore.getService(ITermService.class).find(UsageTermCollection.uuidUseMarkerType);
77 marker = Marker.NewInstance(useMarkerType, true);
78 description.addMarker(marker);
79 monitor.worked(40);
80
81 return postExecute(description);
82 }
83 }
84