Project

General

Profile

« Previous | Next » 

Revision cc5f03e7

Added by Patrick Plitzner over 5 years ago

Initial commit of prototype view

View differences:

eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF
35 35
 org.eclipse.e4.ui.di
36 36
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
37 37
Bundle-ActivationPolicy: lazy
38
Import-Package: javax.inject;version="1.0.0",
38
Import-Package: javax.annotation;version="1.0.0";resolution:=optional,
39
 javax.inject;version="1.0.0",
39 40
 org.eclipse.core.databinding.beans,
40 41
 org.eclipse.core.databinding.observable.list,
41 42
 org.eclipse.core.databinding.observable.map,
eu.etaxonomy.taxeditor.editor/fragment.e4xmi
52 52
        <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"/>
53 53
      </menus>
54 54
    </elements>
55
    <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"/>
55 56
  </fragments>
56 57
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="__mwtMDVpEee_b7RlBzTDRw" featurename="commands" parentElementId="xpath:/">
57 58
    <elements xsi:type="commands:Command" xmi:id="_BjF3ADVqEee_b7RlBzTDRw" elementId="eu.etaxonomy.taxeditor.editor.command.specimeneditor.create_field_unit" commandName="%command.commandname.1"/>
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/FeatureTreeBuilderViewPart.java
1
// $Id$
2
/**
3
* Copyright (C) 2017 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
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.
9
*/
10
package eu.etaxonomy.taxeditor.editor.workingSet;
11

  
12
import java.math.BigInteger;
13
import java.util.ArrayList;
14
import java.util.HashMap;
15
import java.util.List;
16
import java.util.Map;
17

  
18
import javax.annotation.PostConstruct;
19
import javax.annotation.PreDestroy;
20

  
21
import org.bgbm.prometheus.xml.NEWQUALITATIVEPROPERTY;
22
import org.bgbm.prometheus.xml.ONTOLOGYDETAILS;
23
import org.bgbm.prometheus.xml.STRUCTURETERM;
24
import org.bgbm.prometheus.xml.Structure;
25
import org.bgbm.prometheus.xml.TYPETERM;
26
import org.eclipse.e4.ui.di.Focus;
27
import org.eclipse.jface.viewers.TreeViewer;
28
import org.eclipse.swt.SWT;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Tree;
31
import org.eclipse.ui.forms.widgets.TableWrapData;
32
import org.eclipse.ui.forms.widgets.TableWrapLayout;
33

  
34
/**
35
 * @author pplitzner
36
 * @date 24.05.2017
37
 *
38
 */
39
public class FeatureTreeBuilderViewPart {
40

  
41
    private Tree treeStructures;
42
    private Tree treeProperties;
43
    private Tree treeCharacters;
44
    private TreeViewer treeViewerCharacters;
45
    private TreeViewer treeViewerProperties;
46
    private TreeViewer treeViewerStructures;
47

  
48
    public FeatureTreeBuilderViewPart() {
49
        ontology = PrometheusOntology.createOntology();
50
        createIndex(ontology);
51
    }
52

  
53
    /**
54
     * Create contents of the view part.
55
     */
56
    @PostConstruct
57
    public void createControls(Composite parent) {
58
        {
59
            TableWrapLayout twl_parent = new TableWrapLayout();
60
            twl_parent.numColumns = 3;
61
            parent.setLayout(twl_parent);
62
        }
63

  
64
        treeViewerStructures = new TreeViewer(parent, SWT.BORDER);
65
        treeViewerStructures.setColumnProperties(new String[] {});
66
        treeStructures = treeViewerStructures.getTree();
67
        treeStructures.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 1));
68

  
69
        treeViewerProperties = new TreeViewer(parent, SWT.BORDER);
70
        treeProperties = treeViewerProperties.getTree();
71
        treeProperties.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 1));
72

  
73
        treeViewerCharacters = new TreeViewer(parent, SWT.BORDER);
74
        treeCharacters = treeViewerCharacters.getTree();
75
        treeCharacters.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 1));
76

  
77
        init();
78
    }
79

  
80
    private void init(){
81
        treeViewerStructures.setContentProvider(new StructureContenProvider(this));
82
        treeViewerStructures.setLabelProvider(new StructureLabelProvider(this));
83
        treeViewerStructures.setInput("");
84
    }
85

  
86
    @PreDestroy
87
    public void dispose() {
88
    }
89

  
90
    @Focus
91
    public void setFocus() {
92
        // TODO	Set the focus to control
93
    }
94

  
95
    public TreeViewer getTreeViewerCharacters() {
96
        return treeViewerCharacters;
97
    }
98
    public TreeViewer getTreeViewerProperties() {
99
        return treeViewerProperties;
100
    }
101
    public TreeViewer getTreeViewerStructures() {
102
        return treeViewerStructures;
103
    }
104

  
105

  
106
    private final Map<String, List<String>> taxonToCharacterListMap = new HashMap<>();
107

  
108
    private final Map<BigInteger, STRUCTURETERM> structureTermMap = new HashMap<>();
109
    private final Map<BigInteger, TYPETERM> typeTermMap = new HashMap<>();
110
    private final Map<BigInteger, NEWQUALITATIVEPROPERTY> qualPropertyTermMap = new HashMap<>();
111
    private final Map<BigInteger, List<BigInteger>> structureTermToQualPropertyMap = new HashMap<>();
112
    private ONTOLOGYDETAILS ontology;
113

  
114

  
115
    private void createIndex(ONTOLOGYDETAILS ontology){
116
        //structures
117
        List<STRUCTURETERM> terms = ontology.getONTOLOGYDETAILSBody().getTERMS().getSTRUCTURETERMS().getSTRUCTURETERM();
118
        terms.forEach((STRUCTURETERM structureTerm) -> structureTermMap.put(structureTerm.getGLOBALID(), structureTerm));
119
        //type terms
120
        List<TYPETERM> typeTerms = ontology.getONTOLOGYDETAILSBody().getTERMS().getTYPEOFSTRUCTURETERMS().getTYPETERM();
121
        typeTerms.forEach((TYPETERM typeterm) -> typeTermMap.put(typeterm.getGLOBALID(), typeterm));
122
        //properties
123
        List<NEWQUALITATIVEPROPERTY> qualProperties = ontology.getONTOLOGYDETAILSBody().getNewQualitativeProperties().getNEWQUALITATIVEPROPERTY();
124
        qualProperties.forEach((NEWQUALITATIVEPROPERTY newqualitativeproperty) ->
125
        {
126
            BigInteger id = newqualitativeproperty.getIDSEQ();
127
            qualPropertyTermMap.put(id, newqualitativeproperty);
128

  
129
            List<Structure> structures = newqualitativeproperty.getStructuresLinkedToProperty().getStructure();
130
            structures.forEach((Structure structure) ->
131
            {
132
                List<BigInteger> properties = structureTermToQualPropertyMap.get(structure.getRefID());
133
                if(properties==null){
134
                    properties = new ArrayList<>();
135
                }
136
                properties.add(id);
137
                structureTermToQualPropertyMap.put(structure.getRefID(), properties);
138
            });
139
        });
140
    }
141

  
142
    /**
143
     * @return the ontology
144
     */
145
    public ONTOLOGYDETAILS getOntology() {
146
        return ontology;
147
    }
148

  
149
    public Map<BigInteger, STRUCTURETERM> getStructureTermMap() {
150
        return structureTermMap;
151
    }
152
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/PrometheusOntology.java
1
package eu.etaxonomy.taxeditor.editor.workingSet;
2

  
3
import java.io.File;
4
import java.io.IOException;
5
import java.net.URISyntaxException;
6
import java.net.URL;
7

  
8
import javax.xml.bind.JAXBContext;
9
import javax.xml.bind.JAXBException;
10
import javax.xml.bind.Unmarshaller;
11

  
12
import org.bgbm.prometheus.xml.ONTOLOGYDETAILS;
13
import org.bgbm.prometheus.xml.TreeNode;
14
import org.eclipse.core.runtime.FileLocator;
15
import org.eclipse.core.runtime.Path;
16
import org.eclipse.core.runtime.Platform;
17

  
18
public class PrometheusOntology {
19

  
20
	public static ONTOLOGYDETAILS createOntology() {
21
		try {
22

  
23
		    URL url = null;
24
		    URL iconUrl = FileLocator.find(Platform.getBundle("eu.etaxonomy.taxeditor.editor"), new Path("icons/Ontology.xml"), null);
25
//		    URL url = PrometheusOntology.class.getResource("Ontology.xml");
26
			File file = null;
27
            try {
28
                file = new File(FileLocator.resolve(iconUrl).toURI());
29
            } catch (URISyntaxException | IOException e) {
30
                // TODO Auto-generated catch block
31
                e.printStackTrace();
32
            }
33
			JAXBContext jaxbContext = JAXBContext.newInstance(ONTOLOGYDETAILS.class, TreeNode.class);
34

  
35
			Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
36
			ONTOLOGYDETAILS unmarshal = (ONTOLOGYDETAILS) jaxbUnmarshaller.unmarshal(file);
37
			return unmarshal;
38

  
39
		  } catch (JAXBException e) {
40
			e.printStackTrace();
41
		  }
42
		return null;
43
	}
44

  
45
	public static void main(String[] args) {
46
	    createOntology();
47
    }
48
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/StructureContenProvider.java
1
// $Id$
2
/**
3
* Copyright (C) 2017 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
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.
9
*/
10
package eu.etaxonomy.taxeditor.editor.workingSet;
11

  
12
import java.util.Collections;
13

  
14
import org.bgbm.prometheus.xml.TreeNode;
15
import org.eclipse.jface.viewers.ITreeContentProvider;
16

  
17
/**
18
 * @author pplitzner
19
 * @date 24.05.2017
20
 *
21
 */
22
public class StructureContenProvider implements ITreeContentProvider {
23

  
24
    private TreeNode rootStructure;
25
    private FeatureTreeBuilderViewPart part;
26

  
27
    public StructureContenProvider(FeatureTreeBuilderViewPart part) {
28
        this.part = part;
29

  
30
        rootStructure = part.getOntology().getONTOLOGYDETAILSBody().getONTOLOGYTREE().getTreeNode();
31
    }
32

  
33
    /**
34
     * {@inheritDoc}
35
     */
36
    @Override
37
    public Object[] getElements(Object inputElement) {
38
        return Collections.singleton(rootStructure).toArray();
39
    }
40

  
41
    /**
42
     * {@inheritDoc}
43
     */
44
    @Override
45
    public Object[] getChildren(Object parentElement) {
46
        TreeNode node = (TreeNode) parentElement;
47
        return node.getTreeNode().toArray();
48
    }
49

  
50
    /**
51
     * {@inheritDoc}
52
     */
53
    @Override
54
    public Object getParent(Object element) {
55
        return null;
56
    }
57

  
58
    /**
59
     * {@inheritDoc}
60
     */
61
    @Override
62
    public boolean hasChildren(Object element) {
63
        return !((TreeNode) element).getTreeNode().isEmpty();
64
    }
65

  
66
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/StructureLabelProvider.java
1
// $Id$
2
/**
3
* Copyright (C) 2017 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
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.
9
*/
10
package eu.etaxonomy.taxeditor.editor.workingSet;
11

  
12
import org.bgbm.prometheus.xml.TreeNode;
13
import org.eclipse.jface.viewers.ColumnLabelProvider;
14

  
15
/**
16
 * @author pplitzner
17
 * @date 24.05.2017
18
 *
19
 */
20
public class StructureLabelProvider extends ColumnLabelProvider {
21

  
22
    private FeatureTreeBuilderViewPart part;
23

  
24
    public StructureLabelProvider( FeatureTreeBuilderViewPart part) {
25
        this.part = part;
26
    }
27
    /**
28
     * {@inheritDoc}
29
     */
30
    @Override
31
    public String getText(Object element) {
32

  
33
        return part.getStructureTermMap().get(((TreeNode)element).getTermID()).getTerm();
34
    }
35
}
eu.etaxonomy.taxeditor.editor/src/main/java/org/bgbm/prometheus/.gitignore
1
/xml/

Also available in: Unified diff