1
|
|
2
|
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.handler;
|
3
|
|
4
|
import javax.inject.Named;
|
5
|
|
6
|
import org.eclipse.e4.core.di.annotations.Execute;
|
7
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
8
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
9
|
|
10
|
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
|
11
|
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
|
12
|
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.DescriptiveDataSetNavigator;
|
13
|
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
|
14
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
15
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
16
|
|
17
|
public class DeleteDescriptiveDataSetHandler {
|
18
|
|
19
|
@Execute
|
20
|
public void execute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
|
21
|
@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
|
22
|
boolean confirm = MessagingUtils.confirmDialog("Confirm delete", "Do you really want to delete the descriptive data set?");
|
23
|
if(confirm && selection instanceof DescriptiveDataSet){
|
24
|
Object object = activePart.getObject();
|
25
|
if(object instanceof DescriptiveDataSetNavigator){
|
26
|
IDescriptiveDataSetService descriptiveDataSetService = CdmStore.getService(IDescriptiveDataSetService.class);
|
27
|
descriptiveDataSetService.delete(((DescriptiveDataSet) selection).getUuid());
|
28
|
DescriptiveDataSetNavigator navigator = (DescriptiveDataSetNavigator) object;
|
29
|
navigator.removeDescriptiveDataSet((DescriptiveDataSet) selection);
|
30
|
navigator.getConversationHolder().commit();
|
31
|
}
|
32
|
else{
|
33
|
MessagingUtils.errorDialog("Deletion failed", DeleteDescriptiveDataSetHandler.class, "Deletion failed. Please try again", TaxeditorEditorPlugin.PLUGIN_ID, null, false);
|
34
|
}
|
35
|
}
|
36
|
}
|
37
|
|
38
|
}
|