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.
9 package eu
.etaxonomy
.taxeditor
.editor
.group
.authority
.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
.swt
.widgets
.Display
;
21 import eu
.etaxonomy
.cdm
.model
.common
.Group
;
22 import eu
.etaxonomy
.taxeditor
.bulkeditor
.BulkEditor
;
23 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
24 import eu
.etaxonomy
.taxeditor
.editor
.group
.authority
.CdmAuthorityEditor
;
25 import eu
.etaxonomy
.taxeditor
.model
.LineSelection
;
26 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
30 * Handler which opens an instance of the {@link CdmAuthorityEditor} for a particluar group.
33 * @created Mar 28, 2013
37 public class EditCdmAuthoritiesHandler
extends AbstractHandler
{
40 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
43 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
44 BulkEditor editor
= (BulkEditor
) EditorUtil
.getActiveEditor();
46 ISelection selection
= editor
.getSite().getSelectionProvider().getSelection();
47 if(selection
instanceof LineSelection
){
49 final LineSelection lineSelection
= (LineSelection
) selection
;
51 Job job
= new Job("Opening Cdm Authorities"){
54 protected IStatus
run(IProgressMonitor monitor
) {
55 monitor
.beginTask("Opening Cdm Authorities", lineSelection
.size());
57 for(final Object selectedObject
: lineSelection
.toArray()){
58 if(selectedObject
instanceof Group
){
60 Display
.getDefault().asyncExec(new Runnable(){
65 EditorUtil
.openCdmAuthorities(((Group
)selectedObject
).getUuid());
66 } catch (Exception e
) {
67 MessagingUtils
.warningDialog("Could not open CDM Authority Editor", EditorUtil
.class, e
.getMessage());
76 return Status
.OK_STATUS
;
81 job
.setPriority(Job
.SHORT
);