Revision 972ecc88
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/RemotingEditPolytomousKeyNodesHandler.java | ||
---|---|---|
11 | 11 |
import org.eclipse.core.commands.AbstractHandler; |
12 | 12 |
import org.eclipse.core.commands.ExecutionEvent; |
13 | 13 |
import org.eclipse.core.commands.ExecutionException; |
14 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
15 |
import org.eclipse.core.runtime.IStatus; |
|
16 |
import org.eclipse.core.runtime.Status; |
|
17 |
import org.eclipse.core.runtime.jobs.Job; |
|
18 |
import org.eclipse.jface.viewers.ISelection; |
|
19 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
20 |
import org.eclipse.swt.widgets.Display; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.model.description.PolytomousKey; |
|
23 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
24 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
25 |
import eu.etaxonomy.taxeditor.navigation.NavigationUtil; |
|
26 |
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewLabels; |
|
27 |
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewPart; |
|
28 |
import eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingEditPolytomousKeyNodesHandlerE4; |
|
29 | 14 |
|
30 | 15 |
/** |
31 | 16 |
* @author cmathew |
... | ... | |
39 | 24 |
*/ |
40 | 25 |
@Override |
41 | 26 |
public Object execute(final ExecutionEvent event) throws ExecutionException { |
42 |
PolytomousKeyViewPart view = (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false); |
|
43 |
|
|
44 |
ISelection selection = view.getSite().getSelectionProvider().getSelection(); |
|
45 |
if(selection instanceof StructuredSelection){ |
|
46 |
|
|
47 |
final StructuredSelection structuredSelection = (StructuredSelection) selection; |
|
48 |
|
|
49 |
Job job = new Job(RemotingEditPolytomousKeyNodesHandlerE4.OPENING_POLYTOMOUS_KEYS){ |
|
50 |
|
|
51 |
@Override |
|
52 |
protected IStatus run(IProgressMonitor monitor) { |
|
53 |
monitor.beginTask(RemotingEditPolytomousKeyNodesHandlerE4.OPENING_POLYTOMOUS_KEYS, structuredSelection.size()); |
|
54 |
|
|
55 |
for(final Object selectedObject : structuredSelection.toArray()){ |
|
56 |
if(selectedObject instanceof PolytomousKey){ |
|
57 |
|
|
58 |
Display.getDefault().asyncExec(new Runnable(){ |
|
59 |
|
|
60 |
@Override |
|
61 |
public void run() { |
|
62 |
try { |
|
63 |
PolytomousKey key = (PolytomousKey) selectedObject; |
|
64 |
EditorUtil.openPolytomousKey(key.getUuid()); |
|
65 |
} catch(Exception ex) { |
|
66 |
MessagingUtils.warningDialog(PolytomousKeyViewLabels.ERROR_OPENING_KEY_EDITOR_MESSAGE, |
|
67 |
event.getTrigger(), |
|
68 |
ex.getLocalizedMessage()); |
|
69 |
ex.printStackTrace(); |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
}); |
|
74 |
monitor.worked(1); |
|
75 |
} |
|
76 |
} |
|
77 |
monitor.done(); |
|
78 |
return Status.OK_STATUS; |
|
79 |
} |
|
80 |
|
|
81 |
}; |
|
82 |
|
|
83 |
job.setPriority(Job.SHORT); |
|
84 |
job.schedule(); |
|
85 |
|
|
86 |
} |
|
27 |
// PolytomousKeyViewPart view = (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false);
|
|
28 |
// |
|
29 |
// ISelection selection = view.getSite().getSelectionProvider().getSelection();
|
|
30 |
// if(selection instanceof StructuredSelection){
|
|
31 |
// |
|
32 |
// final StructuredSelection structuredSelection = (StructuredSelection) selection;
|
|
33 |
// |
|
34 |
// Job job = new Job(RemotingEditPolytomousKeyNodesHandlerE4.OPENING_POLYTOMOUS_KEYS){
|
|
35 |
// |
|
36 |
// @Override
|
|
37 |
// protected IStatus run(IProgressMonitor monitor) {
|
|
38 |
// monitor.beginTask(RemotingEditPolytomousKeyNodesHandlerE4.OPENING_POLYTOMOUS_KEYS, structuredSelection.size());
|
|
39 |
// |
|
40 |
// for(final Object selectedObject : structuredSelection.toArray()){
|
|
41 |
// if(selectedObject instanceof PolytomousKey){
|
|
42 |
// |
|
43 |
// Display.getDefault().asyncExec(new Runnable(){
|
|
44 |
// |
|
45 |
// @Override
|
|
46 |
// public void run() {
|
|
47 |
// try {
|
|
48 |
// PolytomousKey key = (PolytomousKey) selectedObject;
|
|
49 |
// EditorUtil.openPolytomousKey(key.getUuid());
|
|
50 |
// } catch(Exception ex) {
|
|
51 |
// MessagingUtils.warningDialog(PolytomousKeyViewLabels.ERROR_OPENING_KEY_EDITOR_MESSAGE,
|
|
52 |
// event.getTrigger(),
|
|
53 |
// ex.getLocalizedMessage());
|
|
54 |
// ex.printStackTrace();
|
|
55 |
// }
|
|
56 |
// }
|
|
57 |
// |
|
58 |
// });
|
|
59 |
// monitor.worked(1);
|
|
60 |
// }
|
|
61 |
// }
|
|
62 |
// monitor.done();
|
|
63 |
// return Status.OK_STATUS;
|
|
64 |
// }
|
|
65 |
// |
|
66 |
// };
|
|
67 |
// |
|
68 |
// job.setPriority(Job.SHORT);
|
|
69 |
// job.schedule();
|
|
70 |
// |
|
71 |
// }
|
|
87 | 72 |
return null; |
88 | 73 |
} |
89 | 74 |
|
Also available in: Unified diff
ref #6913 Remove org.eclipse.ui dependency from AbstractUtility