Project

General

Profile

Download (2.73 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.editor.view.descriptive.operation;
11

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

    
18
import eu.etaxonomy.cdm.api.service.IDescriptionService;
19
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
20
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
21
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
22
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
23
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
24
import eu.etaxonomy.taxeditor.store.CdmStore;
25

    
26
/**
27
 *
28
 * @author pplitzner
29
 * @date Jan 15, 2015
30
 *
31
 */
32
public class DeleteSpecimenDescriptionOperation extends AbstractPostOperation<SpecimenOrObservationBase<?>> {
33

    
34
	private final SpecimenDescription description;
35

    
36
	public DeleteSpecimenDescriptionOperation(String label,
37
	        IUndoContext undoContext,
38
	        SpecimenDescription description,
39
	        IPostOperationEnabled postOperationEnabled,
40
	        ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
41
		super(label, undoContext, description.getDescribedSpecimenOrObservation(), postOperationEnabled, cdmEntitySessionEnabled);
42
		this.description = description;
43
	}
44

    
45
	/* (non-Javadoc)
46
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
47
	 */
48
	/** {@inheritDoc} */
49
	@Override
50
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
51
			throws ExecutionException {
52

    
53
		monitor.worked(40);
54
		CdmStore.getService(IDescriptionService.class).deleteDescription(description);
55

    
56
		return postExecute(description);
57
	}
58

    
59
	/* (non-Javadoc)
60
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
61
	 */
62
	/** {@inheritDoc} */
63
	@Override
64
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
65
			throws ExecutionException {
66
		return execute(monitor, info);
67
	}
68

    
69
	/* (non-Javadoc)
70
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
71
	 */
72
	/** {@inheritDoc} */
73
	@Override
74
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
75
			throws ExecutionException {
76

    
77
	    element.addDescription(description);
78

    
79
		return postExecute(null);
80
	}
81
}
(6-6/9)