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
.navigator
.handler
;
11 import org
.eclipse
.core
.commands
.ExecutionEvent
;
12 import org
.eclipse
.ui
.IEditorInput
;
13 import org
.eclipse
.ui
.IEditorReference
;
14 import org
.eclipse
.ui
.IWorkbenchPage
;
15 import org
.eclipse
.ui
.PartInitException
;
16 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
18 import eu
.etaxonomy
.cdm
.model
.common
.ITreeNode
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
20 import eu
.etaxonomy
.taxeditor
.editor
.TaxonEditorInput
;
27 public class NavigatorHandlerUtils
{
29 protected static boolean closeObsoleteEditor(ExecutionEvent event
, TaxonNode taxonNode
){
30 IWorkbenchPage activePage
= HandlerUtil
.getActiveWorkbenchWindow(event
).getActivePage();
31 boolean result
= true;
32 for (IEditorReference ref
: activePage
.getEditorReferences()) {
34 String treeIndex
= ((ITreeNode
)taxonNode
).treeIndex();
37 IEditorInput input
= ref
.getEditorInput();
38 if (input
instanceof TaxonEditorInput
) {
39 TaxonNode node
= ((TaxonEditorInput
) input
).getTaxonNode();
40 //if node is a child of taxonNode then close the editor
41 if( ((ITreeNode
) node
).treeIndex().startsWith(treeIndex
)){
42 //if (taxonNode.equals(node)) {
43 result
&= activePage
.closeEditor(ref
.getEditor(false), true);
47 } catch (PartInitException e
) {