From 871e0d3709c9360946a91931956c28d23dcb984c Mon Sep 17 00:00:00 2001 From: Patrick Plitzner Date: Tue, 13 Sep 2016 08:08:16 +0200 Subject: [PATCH] Do not show taxon-specific deletion options when deleting classifications --- .../RemotingDeleteTaxonNodeHandler.java | 42 +++++++------------ .../DeleteConfiguratorDialog.java | 10 ----- 2 files changed, 16 insertions(+), 36 deletions(-) diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RemotingDeleteTaxonNodeHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RemotingDeleteTaxonNodeHandler.java index 374ca7e0e..c6d53ad38 100644 --- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RemotingDeleteTaxonNodeHandler.java +++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RemotingDeleteTaxonNodeHandler.java @@ -23,10 +23,9 @@ 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.NodeDeletionConfigurator.ChildHandling; -import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; import eu.etaxonomy.cdm.model.taxon.Classification; import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; import eu.etaxonomy.cdm.model.taxon.TaxonNode; @@ -47,21 +46,15 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler { private TaxonDeletionConfigurator config; private Set 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(); while (selectionIterator.hasNext()){ @@ -99,15 +92,20 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler { } 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 = "Do you really want to delete the classification? The tree has children, they will be deleted, too."; + } else { + message = "Do you really want to delete the classification?"; + } + if (!DeleteConfiguratorDialog.openConfirm( + HandlerUtil.getActiveShell(event), "Confirm Deletion", + message)) { + return Status.CANCEL_STATUS; + } + } + else { if (taxonNode.hasChildNodes()){ DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog( @@ -142,9 +140,6 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler { 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(), @@ -153,13 +148,8 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler { config); } - /* (non-Javadoc) - * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete() - */ @Override public void onComplete() { - // TODO Auto-generated method stub - } } diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteConfiguratorDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteConfiguratorDialog.java index a3988f6c1..93477123e 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteConfiguratorDialog.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteConfiguratorDialog.java @@ -41,9 +41,6 @@ public class DeleteConfiguratorDialog extends MessageDialog{ this.configurator = configurator; } - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite) - */ @Override protected Control createCustomArea(Composite parent) { DeleteConfiguratorComposite composite = new DeleteConfiguratorComposite(parent, NONE); @@ -67,19 +64,12 @@ public class DeleteConfiguratorDialog extends MessageDialog{ return dialog.open() == 0; } - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#isResizable() - */ @Override protected boolean isResizable() { return true; } - /** - * @param kind - * @return - */ protected static String[] getButtonLabels(int kind) { String[] dialogButtonLabels; switch (kind) { -- 2.34.1