2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.handler
;
12 import java
.util
.List
;
14 import org
.eclipse
.core
.commands
.AbstractHandler
;
15 import org
.eclipse
.core
.commands
.ExecutionEvent
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 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
;
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 import eu
.etaxonomy
.taxeditor
.navigation
.l10n
.Messages
;
30 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
34 * <p>RefreshPolytomousKeyNodesHandler class, which refreshes each key node in the polytomous key navigation view</p>
37 * @created Jan 17 2013
40 public class RefreshPolytomousKeyNodesHandler
extends AbstractHandler
implements IHandler
{
42 private static final String REFRESHING_POLYTOMOUS_KEY_NODES
= Messages
.RefreshPolytomousKeyNodesHandler_REFRESHING
;
45 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
46 final PolytomousKeyViewPart view
= (PolytomousKeyViewPart
) NavigationUtil
.getView(PolytomousKeyViewPart
.ID
, false);
47 final List
<PolytomousKey
> keys
= view
.getKeys();
49 final String label
= Messages
.RefreshPolytomousKeyNodesHandler_REFRESH
;
51 final IUndoContext undoContext
= NavigationUtil
.getUndoContext();
52 if (keys
.size() > 0) {
53 Job job
= new Job(REFRESHING_POLYTOMOUS_KEY_NODES
){
56 protected IStatus
run(IProgressMonitor monitor
) {
57 monitor
.beginTask(REFRESHING_POLYTOMOUS_KEY_NODES
, keys
.size());
60 for (final PolytomousKey key
: keys
) {
61 if(key
.getRoot() != null) {
63 Display
.getDefault().asyncExec(new Runnable(){
67 AbstractPostOperation operation
= new RefreshNodesOperation(label
, undoContext
, key
, view
);
68 NavigationUtil
.executeOperation(operation
);
76 return Status
.OK_STATUS
;
81 job
.setPriority(Job
.SHORT
);