Project

General

Profile

« Previous | Next » 

Revision 708e6614

Added by Niels Hoffmann almost 13 years ago

Fixes #2436; PolytomousKeyListView now allows deletion of multiple elements

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/DeleteHandler.java
10 10

  
11 11
package eu.etaxonomy.taxeditor.navigation.key.polytomous.handler;
12 12

  
13
import java.util.List;
14

  
13 15
import org.eclipse.core.commands.AbstractHandler;
14 16
import org.eclipse.core.commands.ExecutionEvent;
15 17
import org.eclipse.core.commands.ExecutionException;
......
37 39
	public Object execute(ExecutionEvent event) throws ExecutionException {
38 40
		IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
39 41
		
40
		PolytomousKey key = (PolytomousKey) selection.getFirstElement();
42
		List<PolytomousKey> keys = selection.toList();
43
		
44
		if(keys.isEmpty()){
45
			return null;
46
		}
47
		
48
		boolean confirmation = NavigationUtil.confirmDialog("Confirm deletaion", "Do you want to delete the selected key" + (keys.size() == 1 ? "" : "s") + "?");
41 49
		
42
		if(NavigationUtil.confirmDialog("Confirm deletaion", "Do you really want to delete the key: " + key.getTitleCache())){
50
		if(confirmation){
43 51
		
44
			try {
45
				AbstractPostOperation operation = new DeleteOperation(
46
						event.getCommand().getName(),
47
						NavigationUtil.getUndoContext(), key, 
48
						(PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false),
49
						(PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false));
50
				NavigationUtil.executeOperation(operation);
51
			} catch (NotDefinedException e) {
52
				NavigationUtil.error(getClass(), e);
52
			for(PolytomousKey key : keys){
53
				try {
54
					AbstractPostOperation operation = new DeleteOperation(
55
							event.getCommand().getName(),
56
							NavigationUtil.getUndoContext(), key, 
57
							(PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false),
58
							(PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false));
59
					NavigationUtil.executeOperation(operation);
60
				} catch (NotDefinedException e) {
61
					NavigationUtil.error(getClass(), e);
62
				}
53 63
			}
54 64
		}
55 65
		

Also available in: Unified diff