--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.editor.workingSet;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+import org.bgbm.prometheus.xml.NEWQUALITATIVEPROPERTY;
+import org.bgbm.prometheus.xml.ONTOLOGYDETAILS;
+import org.bgbm.prometheus.xml.STRUCTURETERM;
+import org.bgbm.prometheus.xml.Structure;
+import org.bgbm.prometheus.xml.TYPETERM;
+import org.eclipse.e4.ui.di.Focus;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+/**
+ * @author pplitzner
+ * @date 24.05.2017
+ *
+ */
+public class FeatureTreeBuilderViewPart {
+
+ private Tree treeStructures;
+ private Tree treeProperties;
+ private Tree treeCharacters;
+ private TreeViewer treeViewerCharacters;
+ private TreeViewer treeViewerProperties;
+ private TreeViewer treeViewerStructures;
+
+ public FeatureTreeBuilderViewPart() {
+ ontology = PrometheusOntology.createOntology();
+ createIndex(ontology);
+ }
+
+ /**
+ * Create contents of the view part.
+ */
+ @PostConstruct
+ public void createControls(Composite parent) {
+ {
+ TableWrapLayout twl_parent = new TableWrapLayout();
+ twl_parent.numColumns = 3;
+ parent.setLayout(twl_parent);
+ }
+
+ treeViewerStructures = new TreeViewer(parent, SWT.BORDER);
+ treeViewerStructures.setColumnProperties(new String[] {});
+ treeStructures = treeViewerStructures.getTree();
+ treeStructures.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 1));
+
+ treeViewerProperties = new TreeViewer(parent, SWT.BORDER);
+ treeProperties = treeViewerProperties.getTree();
+ treeProperties.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 1));
+
+ treeViewerCharacters = new TreeViewer(parent, SWT.BORDER);
+ treeCharacters = treeViewerCharacters.getTree();
+ treeCharacters.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 1));
+
+ init();
+ }
+
+ private void init(){
+ treeViewerStructures.setContentProvider(new StructureContenProvider(this));
+ treeViewerStructures.setLabelProvider(new StructureLabelProvider(this));
+ treeViewerStructures.setInput("");
+ }
+
+ @PreDestroy
+ public void dispose() {
+ }
+
+ @Focus
+ public void setFocus() {
+ // TODO Set the focus to control
+ }
+
+ public TreeViewer getTreeViewerCharacters() {
+ return treeViewerCharacters;
+ }
+ public TreeViewer getTreeViewerProperties() {
+ return treeViewerProperties;
+ }
+ public TreeViewer getTreeViewerStructures() {
+ return treeViewerStructures;
+ }
+
+
+ private final Map<String, List<String>> taxonToCharacterListMap = new HashMap<>();
+
+ private final Map<BigInteger, STRUCTURETERM> structureTermMap = new HashMap<>();
+ private final Map<BigInteger, TYPETERM> typeTermMap = new HashMap<>();
+ private final Map<BigInteger, NEWQUALITATIVEPROPERTY> qualPropertyTermMap = new HashMap<>();
+ private final Map<BigInteger, List<BigInteger>> structureTermToQualPropertyMap = new HashMap<>();
+ private ONTOLOGYDETAILS ontology;
+
+
+ private void createIndex(ONTOLOGYDETAILS ontology){
+ //structures
+ List<STRUCTURETERM> terms = ontology.getONTOLOGYDETAILSBody().getTERMS().getSTRUCTURETERMS().getSTRUCTURETERM();
+ terms.forEach((STRUCTURETERM structureTerm) -> structureTermMap.put(structureTerm.getGLOBALID(), structureTerm));
+ //type terms
+ List<TYPETERM> typeTerms = ontology.getONTOLOGYDETAILSBody().getTERMS().getTYPEOFSTRUCTURETERMS().getTYPETERM();
+ typeTerms.forEach((TYPETERM typeterm) -> typeTermMap.put(typeterm.getGLOBALID(), typeterm));
+ //properties
+ List<NEWQUALITATIVEPROPERTY> qualProperties = ontology.getONTOLOGYDETAILSBody().getNewQualitativeProperties().getNEWQUALITATIVEPROPERTY();
+ qualProperties.forEach((NEWQUALITATIVEPROPERTY newqualitativeproperty) ->
+ {
+ BigInteger id = newqualitativeproperty.getIDSEQ();
+ qualPropertyTermMap.put(id, newqualitativeproperty);
+
+ List<Structure> structures = newqualitativeproperty.getStructuresLinkedToProperty().getStructure();
+ structures.forEach((Structure structure) ->
+ {
+ List<BigInteger> properties = structureTermToQualPropertyMap.get(structure.getRefID());
+ if(properties==null){
+ properties = new ArrayList<>();
+ }
+ properties.add(id);
+ structureTermToQualPropertyMap.put(structure.getRefID(), properties);
+ });
+ });
+ }
+
+ /**
+ * @return the ontology
+ */
+ public ONTOLOGYDETAILS getOntology() {
+ return ontology;
+ }
+
+ public Map<BigInteger, STRUCTURETERM> getStructureTermMap() {
+ return structureTermMap;
+ }
+}
--- /dev/null
+package eu.etaxonomy.taxeditor.editor.workingSet;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import org.bgbm.prometheus.xml.ONTOLOGYDETAILS;
+import org.bgbm.prometheus.xml.TreeNode;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+
+public class PrometheusOntology {
+
+ public static ONTOLOGYDETAILS createOntology() {
+ try {
+
+ URL url = null;
+ URL iconUrl = FileLocator.find(Platform.getBundle("eu.etaxonomy.taxeditor.editor"), new Path("icons/Ontology.xml"), null);
+// URL url = PrometheusOntology.class.getResource("Ontology.xml");
+ File file = null;
+ try {
+ file = new File(FileLocator.resolve(iconUrl).toURI());
+ } catch (URISyntaxException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ JAXBContext jaxbContext = JAXBContext.newInstance(ONTOLOGYDETAILS.class, TreeNode.class);
+
+ Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
+ ONTOLOGYDETAILS unmarshal = (ONTOLOGYDETAILS) jaxbUnmarshaller.unmarshal(file);
+ return unmarshal;
+
+ } catch (JAXBException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public static void main(String[] args) {
+ createOntology();
+ }
+}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.editor.workingSet;
+
+import java.util.Collections;
+
+import org.bgbm.prometheus.xml.TreeNode;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+
+/**
+ * @author pplitzner
+ * @date 24.05.2017
+ *
+ */
+public class StructureContenProvider implements ITreeContentProvider {
+
+ private TreeNode rootStructure;
+ private FeatureTreeBuilderViewPart part;
+
+ public StructureContenProvider(FeatureTreeBuilderViewPart part) {
+ this.part = part;
+
+ rootStructure = part.getOntology().getONTOLOGYDETAILSBody().getONTOLOGYTREE().getTreeNode();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return Collections.singleton(rootStructure).toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ TreeNode node = (TreeNode) parentElement;
+ return node.getTreeNode().toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean hasChildren(Object element) {
+ return !((TreeNode) element).getTreeNode().isEmpty();
+ }
+
+}