Project

General

Profile

« Previous | Next » 

Revision 707b6237

Added by Niels Hoffmann over 12 years ago

Merged with trunk

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/EditHandler.java
13 13
import org.eclipse.core.commands.AbstractHandler;
14 14
import org.eclipse.core.commands.ExecutionEvent;
15 15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.runtime.IProgressMonitor;
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.core.runtime.jobs.Job;
16 20
import org.eclipse.jface.viewers.ISelection;
17 21
import org.eclipse.jface.viewers.StructuredSelection;
18
import org.eclipse.ui.handlers.HandlerUtil;
22
import org.eclipse.swt.widgets.Display;
19 23

  
20 24
import eu.etaxonomy.cdm.model.description.PolytomousKey;
21 25
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
26
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewPart;
22 27

  
23 28
/**
24 29
 * @author n.hoffmann
......
32 37
	 */
33 38
	@Override
34 39
	public Object execute(ExecutionEvent event) throws ExecutionException {
35
		ISelection selection = HandlerUtil.getCurrentSelection(event);
40
		PolytomousKeyViewPart view = (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false);
36 41
		
42
		ISelection selection = view.getSite().getSelectionProvider().getSelection(); 
37 43
		if(selection instanceof StructuredSelection){
38 44
			final StructuredSelection structuredSelection = (StructuredSelection) selection;
39 45
		
40
			if(structuredSelection.size() == 1 && structuredSelection.getFirstElement() instanceof PolytomousKey){
41
				NavigationUtil.openEditor((PolytomousKey) structuredSelection.getFirstElement());
42
			}
46
			Job job = new Job("Opening Polytomous Keys"){
47

  
48
				@Override
49
				protected IStatus run(IProgressMonitor monitor) {
50
					monitor.beginTask("Opening Polytomous Keys", structuredSelection.size());
51
					
52
					for(final Object selectedObject : structuredSelection.toArray()){
53
						if(selectedObject instanceof PolytomousKey){
54
							
55
							Display.getDefault().asyncExec(new Runnable(){
56

  
57
								@Override
58
								public void run() {
59
									NavigationUtil.openEditor((PolytomousKey) selectedObject);
60
								}
61
								
62
							});
63
							monitor.worked(1);
64
						}
65
					}
66
					monitor.done();
67
					return Status.OK_STATUS;
68
				}
69
				
70
			};
71
			
72
			job.setPriority(Job.SHORT);
73
			job.schedule();			
43 74
			
44 75
		}
45 76
		return null;

Also available in: Unified diff