1
|
/**
|
2
|
* Copyright (C) 2019 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.ui.section.name.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.INameService;
|
18
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
19
|
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
|
20
|
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
|
21
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
22
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
|
23
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
24
|
|
25
|
/**
|
26
|
*
|
27
|
* @author pplitzner
|
28
|
* @since Apr 10, 2019
|
29
|
*
|
30
|
*/
|
31
|
public class DeleteTypeDesignationOperation extends AbstractPostOperation<TaxonName> {
|
32
|
|
33
|
private final TypeDesignationBase<?> typeDesignation;
|
34
|
|
35
|
public DeleteTypeDesignationOperation(String label, IUndoContext undoContext, TaxonName taxonName,
|
36
|
TypeDesignationBase<?> typeDesignation, IPostOperationEnabled postOperationEnabled,
|
37
|
ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
|
38
|
super(label, undoContext, taxonName, postOperationEnabled, cdmEntitySessionEnabled);
|
39
|
this.typeDesignation = typeDesignation;
|
40
|
|
41
|
}
|
42
|
|
43
|
@Override
|
44
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
|
45
|
monitor.worked(20);
|
46
|
if (typeDesignation != null && typeDesignation.isPersited()){
|
47
|
if(element==null){
|
48
|
CdmStore.getService(INameService.class).deleteTypeDesignation(null, typeDesignation);
|
49
|
}
|
50
|
else{
|
51
|
CdmStore.getService(INameService.class).deleteTypeDesignation(element.getUuid(), typeDesignation.getUuid());
|
52
|
}
|
53
|
return postExecute(element);
|
54
|
}
|
55
|
return null;
|
56
|
}
|
57
|
|
58
|
@Override
|
59
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
|
60
|
return execute(monitor, info);
|
61
|
}
|
62
|
|
63
|
@Override
|
64
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
|
65
|
element.removeTypeDesignation(typeDesignation);
|
66
|
return postExecute(element);
|
67
|
}
|
68
|
|
69
|
}
|