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