4 package eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
.operation
;
6 import org
.eclipse
.core
.commands
.ExecutionException
;
7 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
8 import org
.eclipse
.core
.runtime
.IAdaptable
;
9 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
10 import org
.eclipse
.core
.runtime
.IStatus
;
12 import eu
.etaxonomy
.cdm
.api
.application
.ICdmRepository
;
13 import eu
.etaxonomy
.cdm
.api
.service
.DeleteResult
;
14 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyNodeService
;
15 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
16 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
17 import eu
.etaxonomy
.taxeditor
.bulkeditor
.internal
.TaxeditorBulkeditorPlugin
;
18 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
19 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
20 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
21 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
22 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
28 public class DeleteNodeOperation
extends AbstractPostOperation
<PolytomousKeyNode
> {
30 private final PolytomousKeyNode parent
;
31 private final PolytomousKeyNode node
;
32 private final boolean deleteChildren
;
34 public DeleteNodeOperation(String label
, IUndoContext undoContext
,
35 PolytomousKeyNode node
, IPostOperationEnabled postOperationEnabled
, boolean deleteChildren
) {
36 super(label
, undoContext
, node
, postOperationEnabled
);
37 HibernateProxyHelper
.deproxy(node
, PolytomousKeyNode
.class);
39 this.parent
= node
.getParent();
40 this.deleteChildren
= deleteChildren
;
47 * org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse
48 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
51 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
52 throws ExecutionException
{
54 //parent.removeChild(node);
55 ICdmRepository controller
;
57 controller
= CdmStore
.getCurrentApplicationConfiguration();
59 IPolytomousKeyNodeService service
= controller
.getPolytomousKeyNodeService();
62 if (node
.getChildren().size()>0){
64 result
= service
.delete(node
.getUuid(), false);
66 result
= service
.delete(node
.getUuid(), true);
69 result
= service
.delete(node
.getUuid(), true);
72 if (!result
.isOk() || result
.getExceptions().size() > 0){
73 Exception t
= new Exception();
74 if (result
.getExceptions().size() >1){
75 for (Exception e
:result
.getExceptions()){
79 t
= result
.getExceptions().iterator().next();
81 MessagingUtils
.errorDialog(Messages
.DeleteNodeOperation_DELETE_FAILED
, getClass(),null, TaxeditorBulkeditorPlugin
.PLUGIN_ID
, t
, true);
83 return postExecute(null);
90 * org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse
91 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
94 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
95 throws ExecutionException
{
96 return execute(monitor
, info
);
103 * org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse
104 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
107 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
108 throws ExecutionException
{
109 // TODO Auto-generated method stub