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
;
11 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
13 import eu
.etaxonomy
.cdm
.api
.application
.ICdmApplicationConfiguration
;
14 import eu
.etaxonomy
.cdm
.api
.service
.DeleteResult
;
15 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyNodeService
;
16 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
17 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
18 import eu
.etaxonomy
.taxeditor
.bulkeditor
.internal
.TaxeditorBulkeditorPlugin
;
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
;
34 public DeleteNodeOperation(String label
, IUndoContext undoContext
,
35 PolytomousKeyNode node
, IPostOperationEnabled postOperationEnabled
) {
36 super(label
, undoContext
, node
, postOperationEnabled
);
37 HibernateProxyHelper
.deproxy(node
, PolytomousKeyNode
.class);
39 this.parent
= node
.getParent();
46 * org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse
47 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
50 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
51 throws ExecutionException
{
53 //parent.removeChild(node);
54 ICdmApplicationConfiguration controller
;
56 controller
= CdmStore
.getCurrentApplicationConfiguration();
58 IPolytomousKeyNodeService service
= controller
.getPolytomousKeyNodeService();
61 if (node
.getChildren().size()>0){
62 if(! MessageDialog
.openQuestion(null, "Confirm deletion of children", "The selected node has children, do you want to delete them, too?")) {
63 result
= service
.delete(node
.getUuid(), false);
65 result
= service
.delete(node
.getUuid(), true);
68 result
= service
.delete(node
.getUuid(), true);
71 if (!result
.isOk() || result
.getExceptions().size() > 0){
72 Exception t
= new Exception();
73 if (result
.getExceptions().size() >1){
74 for (Exception e
:result
.getExceptions()){
78 t
= result
.getExceptions().iterator().next();
80 MessagingUtils
.errorDialog("Exception occured. Delete not possible", getClass(),null, TaxeditorBulkeditorPlugin
.PLUGIN_ID
, t
, true);
82 return postExecute(null);
89 * org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse
90 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
93 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
94 throws ExecutionException
{
95 return execute(monitor
, info
);
102 * org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse
103 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
106 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
107 throws ExecutionException
{
108 // TODO Auto-generated method stub