3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.taxeditor
.navigation
.navigator
;
13 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
14 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
15 import org
.eclipse
.ui
.IEditorInput
;
16 import org
.eclipse
.ui
.IWorkbenchPage
;
17 import org
.eclipse
.ui
.navigator
.ILinkHelper
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
20 import eu
.etaxonomy
.taxeditor
.editor
.TaxonEditorInput
;
21 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
24 * When a taxon is open in an editor and this editor has focus, its entry in the
25 * navigator's taxonomic tree is selected.
31 public class TaxonLinkHelper
implements ILinkHelper
{
33 /** Constant <code>ID="eu.etaxonomy.taxeditor.navigation.taxon"{trunked}</code> */
34 public static final String ID
= "eu.etaxonomy.taxeditor.navigation.taxonlinkhelper"; //$NON-NLS-1$
37 * @see org.eclipse.ui.navigator.ILinkHelper#activateEditor(org.eclipse.ui.IWorkbenchPage, org.eclipse.jface.viewers.IStructuredSelection)
41 public void activateEditor(IWorkbenchPage page
,
42 IStructuredSelection selection
) {
44 if (selection
== null || selection
.isEmpty()) {
47 // if (selection.getFirstElement() instanceof TaxonNode) {
48 // TaxonNode taxonNode = (TaxonNode) selection.getFirstElement();
49 // TaxonEditorInput taxonEditorInput;
51 // taxonEditorInput = TaxonEditorInput.NewInstance(taxonNode.getUuid());
53 // IEditorPart editor = null;
54 // if ((editor = page.findEditor(taxonEditorInput)) != null) {
55 // page.bringToTop(editor);
58 } catch (Exception e
) {
59 MessagingUtils
.warningDialog("Could not create Taxon", this, e
.getMessage());
64 * @see org.eclipse.ui.navigator.ILinkHelper#findSelection(org.eclipse.ui.IEditorInput)
68 public IStructuredSelection
findSelection(IEditorInput editorInput
) {
69 if (editorInput
instanceof TaxonEditorInput
) {
70 TaxonNode taxonNode
= ((TaxonEditorInput
) editorInput
).getTaxonNode();
71 if (taxonNode
!= null) {
72 return new StructuredSelection(taxonNode
);
75 return StructuredSelection
.EMPTY
;