Revision 08a36bdf
Added by Katja Luther almost 4 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/handler/DeleteDescriptiveDataSetHandler.java | ||
---|---|---|
17 | 17 |
import org.eclipse.e4.ui.services.IServiceConstants; |
18 | 18 |
import org.eclipse.e4.ui.workbench.modeling.EPartService; |
19 | 19 |
import org.eclipse.jface.viewers.IStructuredSelection; |
20 |
import org.eclipse.swt.widgets.Shell; |
|
20 | 21 |
|
21 | 22 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState; |
22 | 23 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
24 |
import eu.etaxonomy.cdm.api.service.config.DeleteDescriptiveDataSetConfigurator; |
|
23 | 25 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
24 | 26 |
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet; |
25 | 27 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
... | ... | |
28 | 30 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
29 | 31 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
30 | 32 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
33 |
import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog; |
|
31 | 34 |
|
32 | 35 |
public class DeleteDescriptiveDataSetHandler { |
33 | 36 |
protected EPartService partService; |
34 | 37 |
|
35 | 38 |
@Execute |
36 | 39 |
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection, |
37 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, EPartService partService) { |
|
38 |
boolean confirm = MessagingUtils.confirmDialog(Messages.DeleteDescriptiveDataSetHandler_DELETE_TITLE, Messages.DeleteDescriptiveDataSetHandler_DELETE_MESSAGE); |
|
40 |
@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
41 |
@Named(IServiceConstants.ACTIVE_SHELL)Shell shell, |
|
42 |
EPartService partService) { |
|
43 |
// boolean confirm = MessagingUtils.confirmDialog(Messages.DeleteDescriptiveDataSetHandler_DELETE_TITLE, Messages.DeleteDescriptiveDataSetHandler_DELETE_MESSAGE); |
|
39 | 44 |
this.partService = partService; |
40 | 45 |
Object object = activePart.getObject(); |
41 |
if(!selection.isEmpty() && confirm && object instanceof DescriptiveDataSetNavigator){
|
|
46 |
if(!selection.isEmpty() && object instanceof DescriptiveDataSetNavigator){ |
|
42 | 47 |
Iterator iterator = selection.iterator(); |
43 | 48 |
while(iterator.hasNext()){ |
44 | 49 |
Object next = iterator.next(); |
45 | 50 |
if(next instanceof DescriptiveDataSet){ |
51 |
DeleteDescriptiveDataSetConfigurator deleteConfig = new DeleteDescriptiveDataSetConfigurator(); |
|
52 |
|
|
53 |
if (!DeleteConfiguratorDialog.openConfirmWithConfigurator(deleteConfig, shell, Messages.DeleteDescriptiveDataSetHandler_DELETE_TITLE, Messages.DeleteDescriptiveDataSetHandler_DELETE_MESSAGE)){ |
|
54 |
return; |
|
55 |
} |
|
46 | 56 |
// IDescriptiveDataSetService descriptiveDataSetService = CdmStore.getService(IDescriptiveDataSetService.class); |
47 | 57 |
// descriptiveDataSetService.delete(((DescriptiveDataSet) next).getUuid()); |
48 |
deleteDescriptiveDataSet(((DescriptiveDataSet) next).getUuid()); |
|
58 |
deleteDescriptiveDataSet(((DescriptiveDataSet) next).getUuid(), deleteConfig);
|
|
49 | 59 |
DescriptiveDataSetNavigator navigator = (DescriptiveDataSetNavigator) object; |
50 | 60 |
navigator.removeDescriptiveDataSet((DescriptiveDataSet) next); |
51 | 61 |
navigator.getConversationHolder().commit(); |
... | ... | |
60 | 70 |
} |
61 | 71 |
} |
62 | 72 |
|
63 |
private void deleteDescriptiveDataSet(UUID descriptiveDataSetUuid){ |
|
73 |
private void deleteDescriptiveDataSet(UUID descriptiveDataSetUuid, DeleteDescriptiveDataSetConfigurator deleteConfig){
|
|
64 | 74 |
EditorUtil.closeObsoleteDescriptiveDatasetEditor(descriptiveDataSetUuid, partService); |
65 |
UUID monitorUuid = CdmApplicationState.getLongRunningTasksService().deleteDescriptiveDataset(descriptiveDataSetUuid); |
|
75 |
UUID monitorUuid = CdmApplicationState.getLongRunningTasksService().deleteDescriptiveDataset(descriptiveDataSetUuid, deleteConfig);
|
|
66 | 76 |
|
67 | 77 |
String jobLabel = "Delete descriptive dataset"; |
68 | 78 |
Job job = Job.create(jobLabel, (ICoreRunnable) monitor -> { |
... | ... | |
83 | 93 |
} |
84 | 94 |
else if(resultObject instanceof UpdateResult){ |
85 | 95 |
UpdateResult result = (UpdateResult)resultObject; |
96 |
|
|
86 | 97 |
if(!result.getExceptions().isEmpty() && result.isOk()){ |
87 |
MessagingUtils.warningDialog(Messages.DeleteDescriptiveDatasetHandler_Warning_Message, this,
|
|
98 |
MessagingUtils.messageDialog(Messages.DeleteDescriptiveDatasetHandler_Warning_Message, this,
|
|
88 | 99 |
String.format(Messages.DeleteDescriptiveDatasetHandler_Warning_Message, result.getExceptions() |
89 | 100 |
.stream().map(ex->ex.toString()) |
90 | 101 |
.collect(Collectors.joining("\n")))); |
Also available in: Unified diff
ref #8754: adapt deleteHandling to configuration