2 * Copyright (C) 2019 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.ui
.section
.name
.operation
;
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
;
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
;
29 public class DeleteTypeDesignationOperation
extends AbstractPostOperation
<TaxonName
> {
31 private final TypeDesignationBase
<?
> typeDesignation
;
33 public DeleteTypeDesignationOperation(String label
, IUndoContext undoContext
, TaxonName taxonName
,
34 TypeDesignationBase
<?
> typeDesignation
, IPostOperationEnabled postOperationEnabled
,
35 ICdmEntitySessionEnabled
<TaxonName
> cdmEntitySessionEnabled
) {
36 super(label
, undoContext
, taxonName
, postOperationEnabled
, cdmEntitySessionEnabled
);
37 this.typeDesignation
= typeDesignation
;
41 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
43 if (typeDesignation
!= null && typeDesignation
.isPersited()){
45 CdmStore
.getService(INameService
.class).deleteTypeDesignation(null, typeDesignation
);
48 CdmStore
.getService(INameService
.class).deleteTypeDesignation(element
.getUuid(), typeDesignation
.getUuid());
50 return postExecute(element
);
56 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
57 return execute(monitor
, info
);
61 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
62 element
.removeTypeDesignation(typeDesignation
);
63 return postExecute(element
);