2 * Copyright (C) 2015 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.
9 package eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.handler
;
11 import org
.eclipse
.core
.commands
.AbstractHandler
;
12 import org
.eclipse
.core
.commands
.ExecutionEvent
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
15 import org
.eclipse
.core
.runtime
.IStatus
;
16 import org
.eclipse
.core
.runtime
.Status
;
17 import org
.eclipse
.core
.runtime
.jobs
.Job
;
18 import org
.eclipse
.jface
.viewers
.ISelection
;
19 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
20 import org
.eclipse
.swt
.widgets
.Display
;
22 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
23 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
24 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
25 import eu
.etaxonomy
.taxeditor
.navigation
.NavigationUtil
;
26 import eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.PolytomousKeyViewLabels
;
27 import eu
.etaxonomy
.taxeditor
.navigation
.key
.polytomous
.PolytomousKeyViewPart
;
34 public class RemotingEditPolytomousKeyNodesHandler
extends AbstractHandler
{
37 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
40 public Object
execute(final ExecutionEvent event
) throws ExecutionException
{
41 PolytomousKeyViewPart view
= (PolytomousKeyViewPart
) NavigationUtil
.getView(PolytomousKeyViewPart
.ID
, false);
43 ISelection selection
= view
.getSite().getSelectionProvider().getSelection();
44 if(selection
instanceof StructuredSelection
){
46 final StructuredSelection structuredSelection
= (StructuredSelection
) selection
;
48 Job job
= new Job(EditPolytomousKeyNodesHandler
.OPENING_POLYTOMOUS_KEYS
){
51 protected IStatus
run(IProgressMonitor monitor
) {
52 monitor
.beginTask(EditPolytomousKeyNodesHandler
.OPENING_POLYTOMOUS_KEYS
, structuredSelection
.size());
54 for(final Object selectedObject
: structuredSelection
.toArray()){
55 if(selectedObject
instanceof PolytomousKey
){
57 Display
.getDefault().asyncExec(new Runnable(){
62 PolytomousKey key
= (PolytomousKey
) selectedObject
;
63 EditorUtil
.openPolytomousKey(key
.getUuid());
64 } catch(Exception ex
) {
65 MessagingUtils
.warningDialog(PolytomousKeyViewLabels
.ERROR_OPENING_KEY_EDITOR_MESSAGE
,
67 ex
.getLocalizedMessage());
77 return Status
.OK_STATUS
;
82 job
.setPriority(Job
.SHORT
);