Revision b0277a63
Added by Katja Luther almost 7 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/operation/DeleteMediaOperation.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.editor.view.media.operation; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.List; |
|
14 |
|
|
12 | 15 |
import org.eclipse.core.commands.ExecutionException; |
13 | 16 |
import org.eclipse.core.commands.operations.IUndoContext; |
14 | 17 |
import org.eclipse.core.runtime.IAdaptable; |
15 | 18 |
import org.eclipse.core.runtime.IProgressMonitor; |
16 | 19 |
import org.eclipse.core.runtime.IStatus; |
17 | 20 |
|
21 |
import eu.etaxonomy.cdm.api.service.DeleteResult; |
|
18 | 22 |
import eu.etaxonomy.cdm.api.service.IMediaService; |
19 | 23 |
import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator; |
20 | 24 |
import eu.etaxonomy.cdm.api.utility.ImagesUtility; |
21 | 25 |
import eu.etaxonomy.cdm.model.description.DescriptionBase; |
22 | 26 |
import eu.etaxonomy.cdm.model.media.Media; |
27 |
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; |
|
28 |
import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils; |
|
29 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
23 | 30 |
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation; |
24 | 31 |
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; |
25 | 32 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
... | ... | |
67 | 74 |
// ImagesUtility.removeMediaFromGallery(description, media); |
68 | 75 |
|
69 | 76 |
monitor.worked(20); |
70 |
CdmStore.getService(IMediaService.class).delete(media.getUuid(), config); |
|
77 |
DeleteResult result = CdmStore.getService(IMediaService.class).delete(media.getUuid(), config); |
|
78 |
String errorMessage = "The media "; |
|
79 |
if (result.isOk()){ |
|
80 |
ImagesUtility.removeMediaFromGallery(description, media); |
|
81 |
} else{ |
|
82 |
List<String> messages = new ArrayList<String>(); |
|
83 |
int i = result.getExceptions().size(); |
|
84 |
for (Exception e:result.getExceptions()){ |
|
85 |
messages.add(e.getMessage()); |
|
86 |
} |
|
87 |
errorMessage += "could not be deleted."; |
|
88 |
//MessagingUtils.errorDialog("test", getClass(), "message", TaxeditorBulkeditorPlugin.PLUGIN_ID, result.getExceptions().iterator().next(),true); |
|
89 |
DeleteResultMessagingUtils.messageDialogWithDetails(result,errorMessage, TaxeditorBulkeditorPlugin.PLUGIN_ID); |
|
90 |
} |
|
71 | 91 |
monitor.worked(40); |
72 | 92 |
|
73 | 93 |
return postExecute(null); |
Also available in: Unified diff
ref #6527: adapt delete operation to show up error dialog