-// $Id$
/**
* Copyright (C) 2015 EDIT
* European Distributed Institute of Taxonomy
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.handlers.HandlerUtil;
+import eu.etaxonomy.cdm.api.application.CdmApplicationState;
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
-import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator.ChildHandling;
import eu.etaxonomy.cdm.model.taxon.Classification;
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingDeleteTaxonNodeOperation;
import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
-import eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator.DeleteConfiguratorDialog;
+import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog;
/**
* @author cmathew
private TaxonDeletionConfigurator config;
private Set<ITaxonTreeNode> treeNodes;
- /**
- * @param label
- */
public RemotingDeleteTaxonNodeHandler() {
super(TaxonNavigatorLabels.DELETE_TAXON_NODE_LABEL);
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
- */
@Override
public IStatus allowOperations(ExecutionEvent event) {
TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
- Iterator selectionIterator = selection.iterator();
+ Iterator<?> selectionIterator = selection.iterator();
treeNodes = new HashSet<ITaxonTreeNode>();
while (selectionIterator.hasNext()){
}
if(!allEditorsClosed) {
return new Status(IStatus.WARNING,
- "unknown",
+ "unknown", //$NON-NLS-1$
TaxonNavigatorLabels.RELATED_EDITOR_NOT_CLOSED_MESSAGE);
}
config = new TaxonDeletionConfigurator();
if (treeNodes.size() == 1 ){
-
- ITaxonTreeNode treeNode = treeNodes.iterator().next();
+ ITaxonTreeNode treeNode = treeNodes.iterator().next();
ITaxonTreeNode taxonNode = treeNode;
+ if (taxonNode instanceof TaxonNode && !((TaxonNode)taxonNode).hasTaxon()){
+ taxonNode = CdmApplicationState.getCurrentAppConfig().getClassificationService().load(((TaxonNode)taxonNode).getClassification().getUuid());
+ }else{
+ taxonNode = CdmApplicationState.getCurrentAppConfig().getTaxonNodeService().load(taxonNode.getUuid());
+ }
+ treeNodes = new HashSet<ITaxonTreeNode>();
+ treeNodes.add(taxonNode);
+ if (taxonNode == null){
+ MessagingUtils.informationDialog(Messages.RemotingDeleteTaxonNodeHandler_NODE_DELETED, Messages.RemotingDeleteTaxonNodeHandler_NODE_DELETED_MESSAGE);
+ return Status.CANCEL_STATUS;
+
+ }
TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
- if (taxonNode instanceof Classification && taxonNode.hasChildNodes()){
- 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.")){
- return Status.CANCEL_STATUS;
- }
- } else if (taxonNode instanceof Classification && !taxonNode.hasChildNodes()){
- if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification?")){
- return Status.CANCEL_STATUS;
- }
- } else {
+ if (taxonNode instanceof Classification) {
+ String message;
+ if (taxonNode.hasChildNodes()) {
+ message = DeleteHandler.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION+DeleteHandler.THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO;
+ } else {
+ message = DeleteHandler.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION;
+ }
+ if (!DeleteConfiguratorDialog.openConfirm(
+ HandlerUtil.getActiveShell(event), DeleteHandler.CONFIRM_DELETION,
+ message)) {
+ return Status.CANCEL_STATUS;
+ }
+ }
+ else {
if (taxonNode.hasChildNodes()){
DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
config,
HandlerUtil.getActiveShell(event),
- "Confirm Deletion",
+ DeleteHandler.CONFIRM_DELETION,
null,
- "Do you really want to delete the selected node? It has childnodes, they will be deleted, too.",
- MessageDialog.WARNING, new String[] { "Delete all children",
- "Move children to parent node", "Skip" }, 0);
+ DeleteHandler.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S+DeleteHandler.THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO,
+ MessageDialog.WARNING, new String[] { DeleteHandler.DELETE_ALL_CHILDREN,
+ DeleteHandler.MOVE_CHILDREN_TO_PARENT_NODE, DeleteHandler.SKIP }, 0);
int result = dialog.open();
if (result == 0){
return Status.CANCEL_STATUS;
}
} else{
- if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
+ if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(configNodes, HandlerUtil.getActiveShell(event), DeleteHandler.CONFIRM_DELETION, DeleteHandler.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
return Status.CANCEL_STATUS;
}
+ config.setTaxonNodeConfig(configNodes);
}
}
}
return Status.OK_STATUS;
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#prepareOperation(org.eclipse.core.commands.ExecutionEvent)
- */
@Override
public AbstractOperation prepareOperation(ExecutionEvent event) {
return new RemotingDeleteTaxonNodeOperation(event.getTrigger(),
config);
}
- /* (non-Javadoc)
- * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete()
- */
@Override
public void onComplete() {
- // TODO Auto-generated method stub
-
}
}