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
;
24 import org
.eclipse
.swt
.widgets
.Display
;
27 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
28 import eu
.etaxonomy
.taxeditor
.navigation
.NavigationUtil
;
29 import eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.PolytomousKeyViewPart
;
30 import eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.operation
.RefreshNodesOperation
;
31 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
35 * <p>RefreshPolytomousKeyNodesHandler class, which refreshes each key node in the polytomous key navigation view</p>
38 * @created Jan 17 2013
41 public class RefreshPolytomousKeyNodesHandler
extends AbstractHandler
implements IHandler
{
44 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
45 final PolytomousKeyViewPart view
= (PolytomousKeyViewPart
) NavigationUtil
.getView(PolytomousKeyViewPart
.ID
, false);
46 final List
<PolytomousKey
> keys
= view
.getKeys();
48 final String label
= "Refresh Polytomous Key Nodes";
50 final IUndoContext undoContext
= NavigationUtil
.getUndoContext();
51 if (keys
.size() > 0) {
52 Job job
= new Job("Refreshing Polytomous Key Nodes"){
55 protected IStatus
run(IProgressMonitor monitor
) {
56 monitor
.beginTask("Refreshing Polytomous Key Nodes", keys
.size());
59 for (final PolytomousKey key
: keys
) {
60 if(key
.getRoot() != null) {
62 Display
.getDefault().asyncExec(new Runnable(){
66 AbstractPostOperation operation
= new RefreshNodesOperation(label
, undoContext
, key
, view
);
67 NavigationUtil
.executeOperation(operation
);
75 return Status
.OK_STATUS
;
80 job
.setPriority(Job
.SHORT
);