+
+ /**
+ * Opens a taxon editor for the given object if the given object is a valid input.
+ * @param object the object for which the editor will be opened
+ * @throws PartInitException
+ */
+ public static void openTaxonEditor(Object object) throws PartInitException {
+ if(object instanceof TaxonBase<?>){
+ openTaxonBase(((TaxonBase<?>) object).getUuid());
+ }
+ }
+
+ public static boolean closeObsoleteEditor(TaxonNode taxonNode, IWorkbenchPage activePage){
+ boolean result = true;
+ for (IEditorReference ref : activePage.getEditorReferences()) {
+ try {
+ String treeIndex = ((ITreeNode)taxonNode).treeIndex();
+
+
+ IEditorInput input = ref.getEditorInput();
+ if (input instanceof TaxonEditorInput) {
+ TaxonNode node = ((TaxonEditorInput) input).getTaxonNode();
+ //if node is a child of taxonNode then close the editor
+ if( ((ITreeNode) node).treeIndex().startsWith(treeIndex)){
+ //if (taxonNode.equals(node)) {
+ result &= activePage.closeEditor(ref.getEditor(false), true);
+
+ }
+ }
+ } catch (PartInitException e) {
+ continue;
+ }
+ }
+ return result;
+ }