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
.editor
.l10n
.Messages
;
26 import eu
.etaxonomy
.taxeditor
.model
.LineSelection
;
27 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
31 * Handler which opens an instance of the {@link CdmAuthorityEditor} for a particluar group.
34 * @created Mar 28, 2013
38 public class EditCdmAuthoritiesHandler
extends AbstractHandler
{
40 private static final String OPENING_CDM_AUTHORITIES
= Messages
.EditCdmAuthoritiesHandler_OPEN_AUTHORITIES
;
43 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
46 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
47 BulkEditor editor
= (BulkEditor
) EditorUtil
.getActiveEditor();
49 ISelection selection
= editor
.getSite().getSelectionProvider().getSelection();
50 if(selection
instanceof LineSelection
){
52 final LineSelection lineSelection
= (LineSelection
) selection
;
54 Job job
= new Job(OPENING_CDM_AUTHORITIES
){
57 protected IStatus
run(IProgressMonitor monitor
) {
58 monitor
.beginTask(OPENING_CDM_AUTHORITIES
, lineSelection
.size());
60 for(final Object selectedObject
: lineSelection
.toArray()){
61 if(selectedObject
instanceof Group
){
63 Display
.getDefault().asyncExec(new Runnable(){
68 EditorUtil
.openCdmAuthorities(((Group
)selectedObject
).getUuid());
69 } catch (Exception e
) {
70 MessagingUtils
.warningDialog(Messages
.EditCdmAuthoritiesHandler_COULD_NOT_OPEN_AUTHORITIES
, EditorUtil
.class, e
.getMessage());
79 return Status
.OK_STATUS
;
84 job
.setPriority(Job
.SHORT
);