3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.handler
;
13 import java
.util
.List
;
15 import org
.eclipse
.core
.commands
.AbstractHandler
;
16 import org
.eclipse
.core
.commands
.ExecutionEvent
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.core
.commands
.IHandler
;
19 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
20 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
21 import org
.eclipse
.core
.runtime
.IStatus
;
22 import org
.eclipse
.core
.runtime
.Status
;
23 import org
.eclipse
.core
.runtime
.jobs
.Job
;
25 import org
.eclipse
.swt
.widgets
.Display
;
28 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
29 import eu
.etaxonomy
.taxeditor
.navigation
.NavigationUtil
;
30 import eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.PolytomousKeyViewPart
;
31 import eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.operation
.RefreshNodesOperation
;
32 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
36 * <p>RefreshPolytomousKeyNodesHandler class, which refreshes each key node in the polytomous key navigation view</p>
39 * @created Jan 17 2013
42 public class RefreshPolytomousKeyNodesHandler
extends AbstractHandler
implements IHandler
{
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
= "Refresh Polytomous Key Nodes";
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
);