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 org
.eclipse
.core
.commands
.AbstractHandler
;
13 import org
.eclipse
.core
.commands
.ExecutionEvent
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
17 import org
.eclipse
.core
.runtime
.Status
;
18 import org
.eclipse
.core
.runtime
.jobs
.Job
;
19 import org
.eclipse
.jface
.viewers
.ISelection
;
20 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
21 import org
.eclipse
.swt
.widgets
.Display
;
23 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
24 import eu
.etaxonomy
.taxeditor
.navigation
.NavigationUtil
;
25 import eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.PolytomousKeyViewPart
;
29 * @created Dec 3, 2010
32 public class EditPolytomousKeyNodesHandler
extends AbstractHandler
{
35 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
38 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
39 PolytomousKeyViewPart view
= (PolytomousKeyViewPart
) NavigationUtil
.getView(PolytomousKeyViewPart
.ID
, false);
41 ISelection selection
= view
.getSite().getSelectionProvider().getSelection();
42 if(selection
instanceof StructuredSelection
){
44 final StructuredSelection structuredSelection
= (StructuredSelection
) selection
;
46 Job job
= new Job("Opening Polytomous Keys"){
49 protected IStatus
run(IProgressMonitor monitor
) {
50 monitor
.beginTask("Opening Polytomous Keys", structuredSelection
.size());
52 for(final Object selectedObject
: structuredSelection
.toArray()){
53 if(selectedObject
instanceof PolytomousKey
){
55 Display
.getDefault().asyncExec(new Runnable(){
59 NavigationUtil
.openEditor((PolytomousKey
) selectedObject
);
67 return Status
.OK_STATUS
;
72 job
.setPriority(Job
.SHORT
);