import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.TreeSelection;
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
import eu.etaxonomy.taxeditor.navigation.navigator.operation.DeleteOperation;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.ui.dialog.DeleteConfiguratorDialog;
+import eu.etaxonomy.taxeditor.ui.dialog.DeleteTaxonConfiguratorDialog;
/**
* <p>DeleteTreeNodeHandler class.</p>
* @created 06.04.2009
* @version 1.0
*/
-public class DeleteHandler extends AbstractHandler implements IHandler{
+public class DeleteHandler extends AbstractHandler{
protected IWorkbenchPage activePage;
protected TaxonNavigator taxonNavigator;
TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
+
String plural = selection.size() > 1 ? "s" : "";
// Prompt user for confirmation
}
}
AbstractPostOperation operation = null;
+ TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
if (treeNodes.size() == 1 ){
try {
ITaxonTreeNode treeNode = treeNodes.iterator().next();
ITaxonTreeNode taxonNode =treeNode;
TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
- TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
if (taxonNode instanceof Classification && taxonNode.hasChildNodes()){
- if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification? The tree has children, they will be deleted, too.")){
+ if(!DeleteTaxonConfiguratorDialog.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 null;
}
} else if (taxonNode instanceof Classification && !taxonNode.hasChildNodes()){
- if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification?")){
+ if(!DeleteTaxonConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification?")){
return null;
}
} else {
+
if (taxonNode.hasChildNodes()){
- MessageDialog dialog = new MessageDialog(HandlerUtil.getActiveShell(event), "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);
+ DeleteConfiguratorDialog dialog = new DeleteTaxonConfiguratorDialog(
+ config,
+ HandlerUtil.getActiveShell(event),
+ "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);
int result = dialog.open();
if (result == 0){
}
}else{
- if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
+ if(!DeleteTaxonConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
return null;
}
}
/*if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){
return null;
}*/
+
operation = new DeleteOperation(event.getCommand().getName(),
NavigationUtil.getUndoContext(),
taxonNode,
taxonNavigator);
NavigationUtil.executeOperation(operation);
+
//}
}
}
} else{
try{
- if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){
+ if(!DeleteTaxonConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){
return null;
}
if (allEditorsClosed){
+
operation = new DeleteOperation(event.getCommand().getName(),
NavigationUtil.getUndoContext(),
treeNodes,
taxonNavigator);
NavigationUtil.executeOperation(operation);
+
}
}catch (NotDefinedException e) {
MessagingUtils.warn(getClass(), "Command name not set");