1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.navigation.key.polytomous.handler;
|
11
|
|
12
|
import org.eclipse.core.commands.AbstractHandler;
|
13
|
import org.eclipse.core.commands.ExecutionEvent;
|
14
|
import org.eclipse.core.commands.ExecutionException;
|
15
|
import org.eclipse.core.runtime.IProgressMonitor;
|
16
|
import org.eclipse.core.runtime.IStatus;
|
17
|
import org.eclipse.core.runtime.Status;
|
18
|
import org.eclipse.core.runtime.jobs.Job;
|
19
|
import org.eclipse.jface.viewers.ISelection;
|
20
|
import org.eclipse.jface.viewers.StructuredSelection;
|
21
|
import org.eclipse.swt.widgets.Display;
|
22
|
|
23
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
24
|
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
|
25
|
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewPart;
|
26
|
import eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingEditPolytomousKeyNodesHandlerE4;
|
27
|
|
28
|
/**
|
29
|
* @author n.hoffmann
|
30
|
* @created Dec 3, 2010
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class EditPolytomousKeyNodesHandler extends AbstractHandler {
|
34
|
|
35
|
/* (non-Javadoc)
|
36
|
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
|
37
|
*/
|
38
|
@Override
|
39
|
public Object execute(ExecutionEvent event) throws ExecutionException {
|
40
|
PolytomousKeyViewPart view = (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false);
|
41
|
|
42
|
ISelection selection = view.getSite().getSelectionProvider().getSelection();
|
43
|
if(selection instanceof StructuredSelection){
|
44
|
|
45
|
final StructuredSelection structuredSelection = (StructuredSelection) selection;
|
46
|
|
47
|
Job job = new Job(RemotingEditPolytomousKeyNodesHandlerE4.OPENING_POLYTOMOUS_KEYS){
|
48
|
|
49
|
@Override
|
50
|
protected IStatus run(IProgressMonitor monitor) {
|
51
|
monitor.beginTask(RemotingEditPolytomousKeyNodesHandlerE4.OPENING_POLYTOMOUS_KEYS, structuredSelection.size());
|
52
|
|
53
|
for(final Object selectedObject : structuredSelection.toArray()){
|
54
|
if(selectedObject instanceof PolytomousKey){
|
55
|
|
56
|
Display.getDefault().asyncExec(new Runnable(){
|
57
|
|
58
|
@Override
|
59
|
public void run() {
|
60
|
// NavigationUtil.openEditor((PolytomousKey) selectedObject, PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
|
61
|
}
|
62
|
|
63
|
});
|
64
|
monitor.worked(1);
|
65
|
}
|
66
|
}
|
67
|
monitor.done();
|
68
|
return Status.OK_STATUS;
|
69
|
}
|
70
|
|
71
|
};
|
72
|
|
73
|
job.setPriority(Job.SHORT);
|
74
|
job.schedule();
|
75
|
|
76
|
}
|
77
|
return null;
|
78
|
}
|
79
|
|
80
|
}
|