3 * Copyright (C) 2015 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.
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
.editor
.EditorUtil
;
25 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
26 import eu
.etaxonomy
.taxeditor
.navigation
.NavigationUtil
;
27 import eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.PolytomousKeyViewLabels
;
28 import eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.PolytomousKeyViewPart
;
35 public class RemotingEditPolytomousKeyNodesHandler
extends AbstractHandler
{
38 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
41 public Object
execute(final ExecutionEvent event
) throws ExecutionException
{
42 PolytomousKeyViewPart view
= (PolytomousKeyViewPart
) NavigationUtil
.getView(PolytomousKeyViewPart
.ID
, false);
44 ISelection selection
= view
.getSite().getSelectionProvider().getSelection();
45 if(selection
instanceof StructuredSelection
){
47 final StructuredSelection structuredSelection
= (StructuredSelection
) selection
;
49 Job job
= new Job("Opening Polytomous Keys"){
52 protected IStatus
run(IProgressMonitor monitor
) {
53 monitor
.beginTask("Opening Polytomous Keys", structuredSelection
.size());
55 for(final Object selectedObject
: structuredSelection
.toArray()){
56 if(selectedObject
instanceof PolytomousKey
){
58 Display
.getDefault().asyncExec(new Runnable(){
63 PolytomousKey key
= (PolytomousKey
) selectedObject
;
64 EditorUtil
.openPolytomousKey(key
.getUuid());
65 } catch(Exception ex
) {
66 MessagingUtils
.warningDialog(PolytomousKeyViewLabels
.ERROR_OPENING_KEY_EDITOR_MESSAGE
,
68 ex
.getLocalizedMessage());
78 return Status
.OK_STATUS
;
83 job
.setPriority(Job
.SHORT
);