Project

General

Profile

Download (1.63 KB) Statistics
| Branch: | Tag: | Revision:
1

    
2
package eu.etaxonomy.taxeditor.editor.workingSet.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.IWorkingSetService;
11
import eu.etaxonomy.cdm.model.description.WorkingSet;
12
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
13
import eu.etaxonomy.taxeditor.editor.workingSet.WorkingSetNavigator;
14
import eu.etaxonomy.taxeditor.model.MessagingUtils;
15
import eu.etaxonomy.taxeditor.store.CdmStore;
16

    
17
public class DeleteWorkingSetHandler {
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 working set?");
23
	    if(confirm && selection instanceof WorkingSet){
24
	        Object object = activePart.getObject();
25
	        if(object instanceof WorkingSetNavigator){
26
	            IWorkingSetService workingSetService = CdmStore.getService(IWorkingSetService.class);
27
	            workingSetService.delete(((WorkingSet) selection).getUuid());
28
	            WorkingSetNavigator navigator = (WorkingSetNavigator) object;
29
	            navigator.removeWorkingSet((WorkingSet) selection);
30
	            navigator.getConversationHolder().commit();
31
	        }
32
	        else{
33
	            MessagingUtils.errorDialog("Deletion failed", DeleteWorkingSetHandler.class, "Deletion failed. Please try again", TaxeditorEditorPlugin.PLUGIN_ID, null, false);
34
	        }
35
	    }
36
	}
37

    
38
}
(2-2/5)