Merge branch 'develop' into featureTreeEditor
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 1 Jun 2017 07:52:58 +0000 (09:52 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 1 Jun 2017 07:52:58 +0000 (09:52 +0200)
eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.editor/fragment.e4xmi
eu.etaxonomy.taxeditor.editor/icons/Ontology.xml [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/FeatureTreeBuilderViewPart.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/PrometheusOntology.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/StructureContenProvider.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/StructureLabelProvider.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/org/bgbm/prometheus/.gitignore [new file with mode: 0644]

index f10e87bf421fb1fbfcae1ff14edf63450862a144..ff33a16d6412ed3fe5146a0ab4cb338658c0492f 100644 (file)
@@ -35,7 +35,8 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.e4.ui.di
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
-Import-Package: javax.inject;version="1.0.0",
+Import-Package: javax.annotation;version="1.0.0";resolution:=optional,
+ javax.inject;version="1.0.0",
  org.eclipse.core.databinding.beans,
  org.eclipse.core.databinding.observable.list,
  org.eclipse.core.databinding.observable.map,
index 85719aa92f22e108a8e302e204f3efcda724eb58..2744ab9f1b52a298c2912139df220da650834e1d 100644 (file)
@@ -54,6 +54,7 @@
         <children xsi:type="menu:HandledMenuItem" xmi:id="_wg0-oDulEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabel54" label="%command.label.54" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/deep-delete-16x16-32.png" command="_fKT-wDulEeeOtqC_3qh40A"/>
       </menus>
     </elements>
+    <elements xsi:type="basic:PartDescriptor" xmi:id="_R7vxEECaEeeL5JDzMOYK6g" elementId="eu.etaxonomy.taxeditor.editor.workingSet.FeatureTreeBuilderViewPart" label="FeatureTreeBuilder" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.workingSet.FeatureTreeBuilderViewPart"/>
   </fragments>
   <fragments xsi:type="fragment:StringModelFragment" xmi:id="__mwtMDVpEee_b7RlBzTDRw" featurename="commands" parentElementId="xpath:/">
     <elements xsi:type="commands:Command" xmi:id="_BjF3ADVqEee_b7RlBzTDRw" elementId="eu.etaxonomy.taxeditor.editor.command.specimeneditor.create_field_unit" commandName="%command.commandname.1"/>
diff --git a/eu.etaxonomy.taxeditor.editor/icons/Ontology.xml b/eu.etaxonomy.taxeditor.editor/icons/Ontology.xml
new file mode 100644 (file)
index 0000000..5266690
Binary files /dev/null and b/eu.etaxonomy.taxeditor.editor/icons/Ontology.xml differ
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/FeatureTreeBuilderViewPart.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/FeatureTreeBuilderViewPart.java
new file mode 100644 (file)
index 0000000..961660e
--- /dev/null
@@ -0,0 +1,152 @@
+// $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;
+    }
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/PrometheusOntology.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/PrometheusOntology.java
new file mode 100644 (file)
index 0000000..a7a1c64
--- /dev/null
@@ -0,0 +1,48 @@
+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();
+    }
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/StructureContenProvider.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/StructureContenProvider.java
new file mode 100644 (file)
index 0000000..ea775db
--- /dev/null
@@ -0,0 +1,66 @@
+// $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();
+    }
+
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/StructureLabelProvider.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/StructureLabelProvider.java
new file mode 100644 (file)
index 0000000..53b9c06
--- /dev/null
@@ -0,0 +1,35 @@
+// $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 org.bgbm.prometheus.xml.TreeNode;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+
+/**
+ * @author pplitzner
+ * @date 24.05.2017
+ *
+ */
+public class StructureLabelProvider extends ColumnLabelProvider {
+
+    private FeatureTreeBuilderViewPart part;
+
+    public StructureLabelProvider( FeatureTreeBuilderViewPart part) {
+        this.part = part;
+    }
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getText(Object element) {
+
+        return part.getStructureTermMap().get(((TreeNode)element).getTermID()).getTerm();
+    }
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/org/bgbm/prometheus/.gitignore b/eu.etaxonomy.taxeditor.editor/src/main/java/org/bgbm/prometheus/.gitignore
new file mode 100644 (file)
index 0000000..b25d107
--- /dev/null
@@ -0,0 +1 @@
+/xml/