23 |
23 |
import org.eclipse.ui.handlers.HandlerUtil;
|
24 |
24 |
|
25 |
25 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
|
|
26 |
import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
|
26 |
27 |
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
|
27 |
28 |
import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
|
28 |
|
import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
|
29 |
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
30 |
29 |
import eu.etaxonomy.cdm.model.taxon.Classification;
|
31 |
30 |
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
|
32 |
31 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
... | ... | |
47 |
46 |
private TaxonDeletionConfigurator config;
|
48 |
47 |
private Set<ITaxonTreeNode> treeNodes;
|
49 |
48 |
|
50 |
|
/**
|
51 |
|
* @param label
|
52 |
|
*/
|
53 |
49 |
public RemotingDeleteTaxonNodeHandler() {
|
54 |
50 |
super(TaxonNavigatorLabels.DELETE_TAXON_NODE_LABEL);
|
55 |
51 |
}
|
56 |
52 |
|
57 |
|
/* (non-Javadoc)
|
58 |
|
* @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
|
59 |
|
*/
|
60 |
53 |
@Override
|
61 |
54 |
public IStatus allowOperations(ExecutionEvent event) {
|
62 |
55 |
TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
|
63 |
56 |
|
64 |
|
Iterator selectionIterator = selection.iterator();
|
|
57 |
Iterator<?> selectionIterator = selection.iterator();
|
65 |
58 |
treeNodes = new HashSet<ITaxonTreeNode>();
|
66 |
59 |
|
67 |
60 |
while (selectionIterator.hasNext()){
|
... | ... | |
99 |
92 |
|
100 |
93 |
}
|
101 |
94 |
TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
|
102 |
|
if (taxonNode instanceof Classification && taxonNode.hasChildNodes()){
|
103 |
|
if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification? The tree has children, they will be deleted, too.")){
|
104 |
|
return Status.CANCEL_STATUS;
|
105 |
|
}
|
106 |
|
} else if (taxonNode instanceof Classification && !taxonNode.hasChildNodes()){
|
107 |
|
if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification?")){
|
108 |
|
return Status.CANCEL_STATUS;
|
109 |
|
}
|
110 |
|
} else {
|
|
95 |
if (taxonNode instanceof Classification) {
|
|
96 |
String message;
|
|
97 |
if (taxonNode.hasChildNodes()) {
|
|
98 |
message = "Do you really want to delete the classification? The tree has children, they will be deleted, too.";
|
|
99 |
} else {
|
|
100 |
message = "Do you really want to delete the classification?";
|
|
101 |
}
|
|
102 |
if (!DeleteConfiguratorDialog.openConfirm(
|
|
103 |
HandlerUtil.getActiveShell(event), "Confirm Deletion",
|
|
104 |
message)) {
|
|
105 |
return Status.CANCEL_STATUS;
|
|
106 |
}
|
|
107 |
}
|
|
108 |
else {
|
111 |
109 |
|
112 |
110 |
if (taxonNode.hasChildNodes()){
|
113 |
111 |
DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
|
... | ... | |
142 |
140 |
return Status.OK_STATUS;
|
143 |
141 |
}
|
144 |
142 |
|
145 |
|
/* (non-Javadoc)
|
146 |
|
* @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#prepareOperation(org.eclipse.core.commands.ExecutionEvent)
|
147 |
|
*/
|
148 |
143 |
@Override
|
149 |
144 |
public AbstractOperation prepareOperation(ExecutionEvent event) {
|
150 |
145 |
return new RemotingDeleteTaxonNodeOperation(event.getTrigger(),
|
... | ... | |
153 |
148 |
config);
|
154 |
149 |
}
|
155 |
150 |
|
156 |
|
/* (non-Javadoc)
|
157 |
|
* @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete()
|
158 |
|
*/
|
159 |
151 |
@Override
|
160 |
152 |
public void onComplete() {
|
161 |
|
// TODO Auto-generated method stub
|
162 |
|
|
163 |
153 |
}
|
164 |
154 |
|
165 |
155 |
}
|
Do not show taxon-specific deletion options when deleting
classifications