}
config = new TaxonDeletionConfigurator();
-
- if (treeNodes.size() == 1 ){
- ITaxonTreeNode treeNode = treeNodes.iterator().next();
- ITaxonTreeNode taxonNode = treeNode;
- if (taxonNode instanceof TaxonNode && !((TaxonNode)taxonNode).hasTaxon()){
- taxonNode = CdmApplicationState.getCurrentAppConfig().getClassificationService().load(((TaxonNode)taxonNode).getClassification().getUuid());
+ Iterator it = treeNodes.iterator();
+ boolean containsNodeWithChildren = false;
+ boolean containsClassification = false;
+ boolean containsTaxonNodes = false;
+ treeNodes = new HashSet<ITaxonTreeNode>();
+ while (it.hasNext()){
+ ITaxonTreeNode treeNode = (ITaxonTreeNode) it.next();
+
+ if (treeNode instanceof TaxonNode && !((TaxonNode)treeNode).hasTaxon()){
+ treeNode = CdmApplicationState.getCurrentAppConfig().getClassificationService().load(((TaxonNode)treeNode).getClassification().getUuid());
}else{
- taxonNode = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(taxonNode.getUuid());
+ treeNode = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(treeNode.getUuid());
}
- treeNodes = new HashSet<ITaxonTreeNode>();
- treeNodes.add(taxonNode);
- if (taxonNode == null){
+
+ treeNodes.add(treeNode);
+ if (treeNode == null){
MessagingUtils.informationDialog(Messages.RemotingDeleteTaxonNodeHandler_NODE_DELETED, Messages.RemotingDeleteTaxonNodeHandler_NODE_DELETED_MESSAGE);
return Status.CANCEL_STATUS;
}
+ if (treeNode instanceof Classification){
+ containsClassification = true;
+ if (((Classification)treeNode).getRootNode() != null &&treeNode.hasChildNodes()) {
+ containsNodeWithChildren = true;
+ }
+ }else if (treeNode instanceof TaxonNode){
+ containsTaxonNodes = true;
+ if (treeNode.hasChildNodes()){
+ containsNodeWithChildren = true;
+ }
+ }
+
+
+ }
TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
- if (taxonNode instanceof Classification) {
+ if (containsClassification && !containsTaxonNodes) {
String message;
- if (((Classification)taxonNode).getRootNode() != null &&taxonNode.hasChildNodes()) {
+ if (containsClassification && containsNodeWithChildren) {
message = DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION+DeleteHandlerE4.THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO;
} else {
message = DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION;
}
}
else {
-
- if (taxonNode.hasChildNodes()){
- DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
+ String confirmMessage= treeNodes.size() == 1?DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE:DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S;
+ if (containsNodeWithChildren){
+
+ DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
config,
shell,
DeleteHandlerE4.CONFIRM_DELETION,
null,
- DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S+DeleteHandlerE4.THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO,
+ confirmMessage+DeleteHandlerE4.THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO,
MessageDialog.WARNING, new String[] { DeleteHandlerE4.DELETE_ALL_CHILDREN,
DeleteHandlerE4.MOVE_CHILDREN_TO_PARENT_NODE, DeleteHandlerE4.SKIP }, 0);
int result = dialog.open();
shell,
DeleteHandlerE4.CONFIRM_DELETION,
null,
- DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S,
+ confirmMessage,
MessageDialog.WARNING, new String[] { DeleteHandlerE4.DELETE, DeleteHandlerE4.SKIP }, 0);
int result = dialog.open();
if (result == 0){
// config.setTaxonNodeConfig(configNodes);
}
}
- }
+// }
return Status.OK_STATUS;
}