Revision 972ecc88
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/handler/RefreshPolytomousKeyNodesHandler.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.navigation.key.polytomous.handler; |
11 | 11 |
|
12 |
import java.util.List; |
|
13 |
|
|
14 | 12 |
import org.eclipse.core.commands.AbstractHandler; |
15 | 13 |
import org.eclipse.core.commands.ExecutionEvent; |
16 | 14 |
import org.eclipse.core.commands.ExecutionException; |
17 | 15 |
import org.eclipse.core.commands.IHandler; |
18 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
19 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
20 |
import org.eclipse.core.runtime.IStatus; |
|
21 |
import org.eclipse.core.runtime.Status; |
|
22 |
import org.eclipse.core.runtime.jobs.Job; |
|
23 |
import org.eclipse.swt.widgets.Display; |
|
24 | 16 |
|
25 |
import eu.etaxonomy.cdm.model.description.PolytomousKey; |
|
26 |
import eu.etaxonomy.taxeditor.navigation.NavigationUtil; |
|
27 |
import eu.etaxonomy.taxeditor.navigation.key.polytomous.PolytomousKeyViewPart; |
|
28 |
import eu.etaxonomy.taxeditor.navigation.key.polytomous.operation.RefreshNodesOperation; |
|
29 | 17 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
30 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
31 | 18 |
|
32 | 19 |
|
33 | 20 |
/** |
... | ... | |
43 | 30 |
|
44 | 31 |
@Override |
45 | 32 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
46 |
final PolytomousKeyViewPart view = (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false); |
|
47 |
final List<PolytomousKey> keys = view.getKeys(); |
|
48 |
|
|
49 |
final String label = Messages.RefreshPolytomousKeyNodesHandler_REFRESH; |
|
50 |
|
|
51 |
final IUndoContext undoContext = NavigationUtil.getUndoContext(); |
|
52 |
if (keys.size() > 0) { |
|
53 |
Job job = new Job(REFRESHING_POLYTOMOUS_KEY_NODES){ |
|
54 |
|
|
55 |
@Override |
|
56 |
protected IStatus run(IProgressMonitor monitor) { |
|
57 |
monitor.beginTask(REFRESHING_POLYTOMOUS_KEY_NODES, keys.size()); |
|
58 |
|
|
59 |
|
|
60 |
for (final PolytomousKey key : keys) { |
|
61 |
if(key.getRoot() != null) { |
|
62 |
|
|
63 |
Display.getDefault().asyncExec(new Runnable(){ |
|
64 |
|
|
65 |
@Override |
|
66 |
public void run() { |
|
67 |
AbstractPostOperation operation = new RefreshNodesOperation(label, undoContext, key, view); |
|
68 |
NavigationUtil.executeOperation(operation); |
|
69 |
} |
|
70 |
|
|
71 |
}); |
|
72 |
monitor.worked(1); |
|
73 |
} |
|
74 |
} |
|
75 |
monitor.done(); |
|
76 |
return Status.OK_STATUS; |
|
77 |
} |
|
78 |
|
|
79 |
}; |
|
80 |
|
|
81 |
job.setPriority(Job.SHORT); |
|
82 |
job.schedule(); |
|
83 |
|
|
84 |
} |
|
33 |
// final PolytomousKeyViewPart view = (PolytomousKeyViewPart) NavigationUtil.getView(PolytomousKeyViewPart.ID, false);
|
|
34 |
// final List<PolytomousKey> keys = view.getKeys();
|
|
35 |
// |
|
36 |
// final String label = Messages.RefreshPolytomousKeyNodesHandler_REFRESH;
|
|
37 |
// |
|
38 |
// final IUndoContext undoContext = NavigationUtil.getUndoContext();
|
|
39 |
// if (keys.size() > 0) {
|
|
40 |
// Job job = new Job(REFRESHING_POLYTOMOUS_KEY_NODES){
|
|
41 |
// |
|
42 |
// @Override
|
|
43 |
// protected IStatus run(IProgressMonitor monitor) {
|
|
44 |
// monitor.beginTask(REFRESHING_POLYTOMOUS_KEY_NODES, keys.size());
|
|
45 |
// |
|
46 |
// |
|
47 |
// for (final PolytomousKey key : keys) {
|
|
48 |
// if(key.getRoot() != null) {
|
|
49 |
// |
|
50 |
// Display.getDefault().asyncExec(new Runnable(){
|
|
51 |
// |
|
52 |
// @Override
|
|
53 |
// public void run() {
|
|
54 |
// AbstractPostOperation operation = new RefreshNodesOperation(label, undoContext, key, view);
|
|
55 |
// NavigationUtil.executeOperation(operation);
|
|
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 |
// }
|
|
85 | 72 |
return null; |
86 | 73 |
} |
87 | 74 |
} |
Also available in: Unified diff
ref #6913 Remove org.eclipse.ui dependency from AbstractUtility