Revision 2bffeed2
Added by Katja Luther about 7 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/DeleteTaxonBaseHandler.java | ||
---|---|---|
13 | 13 |
import org.eclipse.core.commands.ExecutionException; |
14 | 14 |
import org.eclipse.core.commands.IHandler; |
15 | 15 |
import org.eclipse.core.commands.common.NotDefinedException; |
16 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
17 | 16 |
import org.eclipse.ui.IWorkbenchPage; |
18 | 17 |
import org.eclipse.ui.handlers.HandlerUtil; |
19 | 18 |
|
20 | 19 |
import eu.etaxonomy.cdm.api.service.DeleteResult; |
21 | 20 |
import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator; |
21 |
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator; |
|
22 | 22 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
23 | 23 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
24 | 24 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
... | ... | |
36 | 36 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
37 | 37 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
38 | 38 |
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; |
39 |
import eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator.DeleteConfiguratorDialog; |
|
39 | 40 |
|
40 | 41 |
/** |
41 | 42 |
* @author n.hoffmann |
... | ... | |
69 | 70 |
IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); |
70 | 71 |
// synonym |
71 | 72 |
if(selectedElement instanceof Synonym){ |
72 |
if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), Messages.DeleteTaxonBaseHandler_CONFIRM_DELETION, Messages.DeleteTaxonBaseHandler_REALLY_DELETE_SYNONYM)){ |
|
73 |
return ; |
|
73 |
SynonymDeletionConfigurator deleteConfig = new SynonymDeletionConfigurator(); |
|
74 |
if(! DeleteConfiguratorDialog.openConfirmWithConfigurator(deleteConfig, HandlerUtil.getActiveShell(event), Messages.DeleteTaxonBaseHandler_CONFIRM_DELETION, Messages.DeleteTaxonBaseHandler_REALLY_DELETE_SYNONYM)){ |
|
75 |
return ; |
|
74 | 76 |
} |
75 |
operation = new DeleteSynonymOperation(commandName, editor.getUndoContext(), new SynonymDeletionConfigurator(), activePage, editor.getTaxon(), (Synonym) selectedElement,this, editor, (ICdmEntitySessionEnabled)editor.getEditorInput());
|
|
77 |
operation = new DeleteSynonymOperation(commandName, editor.getUndoContext(), deleteConfig, activePage, editor.getTaxon(), (Synonym) selectedElement,this, editor, (ICdmEntitySessionEnabled)editor.getEditorInput());
|
|
76 | 78 |
|
77 | 79 |
} |
78 | 80 |
// misapplication |
79 | 81 |
else if(selectedElement instanceof Taxon && ((Taxon) selectedElement).isMisapplication()){ |
80 |
operation = new DeleteMisapplicationOperation(commandName, editor.getUndoContext(), editor |
|
81 |
.getTaxon(), (Taxon) selectedElement, editor); |
|
82 |
} |
|
83 |
else { |
|
82 |
TaxonDeletionConfigurator deleteConfig = new TaxonDeletionConfigurator(); |
|
83 |
if(! DeleteConfiguratorDialog.openConfirmWithConfigurator(deleteConfig, HandlerUtil.getActiveShell(event), Messages.DeleteTaxonBaseHandler_CONFIRM_DELETION, Messages.DeleteTaxonBaseHandler_REALLY_DELETE_MISAPPLICATION)){ |
|
84 |
return ; |
|
85 |
} |
|
86 |
operation = new DeleteMisapplicationOperation(commandName, editor.getUndoContext(), deleteConfig, activePage, editor.getTaxon(), (Taxon) selectedElement,this, editor, (ICdmEntitySessionEnabled)editor.getEditorInput()); |
|
87 |
} else { |
|
84 | 88 |
throw new IllegalArgumentException(Messages.DeleteTaxonBaseHandler_ELEMENT_MUST_BE_SYNONYM_MISAPP_CONCEPT); |
85 | 89 |
} |
86 | 90 |
|
... | ... | |
88 | 92 |
DeleteResult result = ((DeleteTaxonBaseOperation)operation).getResult(); |
89 | 93 |
if (result.isError()){ |
90 | 94 |
DeleteResultMessagingUtils.messageDialogWithDetails(result, Messages.DeleteDerivateOperation_DELETE_FAILED, TaxeditorEditorPlugin.PLUGIN_ID); |
91 |
} else if (selectedElement instanceof Synonym){
|
|
95 |
} else { |
|
92 | 96 |
this.editor.redraw(); |
93 | 97 |
if (!result.getUpdatedObjects().isEmpty()){ |
94 | 98 |
DeleteResultMessagingUtils.messageDialogWithDetails(result, Messages.DeleteTaxonBaseHandler_DELETE_SYNONYM_SUCCESSFULL_BUT_REMAINING_RELATED_OBJECTS, TaxeditorEditorPlugin.PLUGIN_ID); |
95 | 99 |
} |
96 |
}else {
|
|
100 |
} |
|
97 | 101 |
if (!result.getUpdatedObjects().isEmpty()){ |
98 | 102 |
DeleteResultMessagingUtils.messageDialogWithDetails(result, Messages.DeleteTaxonBaseHandler_DELETE_MISAPPLIEDNAME_SUCCESSFULL_BUT_REMAINING_RELATED_OBJECTS, TaxeditorEditorPlugin.PLUGIN_ID); |
99 | 103 |
} |
100 |
} |
|
104 |
|
|
101 | 105 |
|
102 | 106 |
} |
103 | 107 |
|
Also available in: Unified diff
fix #6308: add delete configuration dialog for synonyms and misapplied names