ref #7362 Add term details to GfBio import composite
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 17 May 2018 09:45:58 +0000 (11:45 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 17 May 2018 09:49:07 +0000 (11:49 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportComposite.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPart.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPresenter.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/wrapper/OntologyTermWrapper.java

index 24828ff989e430507a8afd7fe868c9674267bcf0..0f8ab3a94a4f4a050424116e78ae2d76a31e4a5e 100644 (file)
@@ -16,6 +16,7 @@ import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.swt.widgets.Tree;
 
@@ -33,6 +34,14 @@ public class GfBioTerminologyImportComposite extends Composite{
     private Composite composite;
     private Button btnRemoveTerminology;
     private ComboViewer comboTerminologies;
+    private Composite composite_1;
+    private Composite composite_2;
+    private Label lblNewLabel;
+    private Label lblNewLabel_1;
+    private Label lblNewLabel_2;
+    private Text txtLabel;
+    private Text txtUri;
+    private Text txtDescription;
 
     public GfBioTerminologyImportComposite(Composite parent, int style) {
         super(parent, style);
@@ -55,11 +64,38 @@ public class GfBioTerminologyImportComposite extends Composite{
         btnSearch = new Button(composite, SWT.NONE);
         btnSearch.setText("Search");
 
-        treeTermHierarchy = new TreeViewer(this, SWT.BORDER);
+        composite_2 = new Composite(this, SWT.NONE);
+        composite_2.setLayout(new GridLayout(2, false));
+        composite_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+
+        treeTermHierarchy = new TreeViewer(composite_2, SWT.BORDER);
         Tree tree = treeTermHierarchy.getTree();
-        GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
-        gd_tree.widthHint = 423;
-        tree.setLayoutData(gd_tree);
+        tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+
+        composite_1 = new Composite(composite_2, SWT.NONE);
+        composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+        composite_1.setLayout(new GridLayout(2, false));
+
+        lblNewLabel = new Label(composite_1, SWT.NONE);
+        lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+        lblNewLabel.setText("Label");
+
+        txtLabel = new Text(composite_1, SWT.NONE);
+        txtLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+
+        lblNewLabel_1 = new Label(composite_1, SWT.NONE);
+        lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+        lblNewLabel_1.setText("URI");
+
+        txtUri = new Text(composite_1, SWT.NONE);
+        txtUri.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+
+        lblNewLabel_2 = new Label(composite_1, SWT.NONE);
+        lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+        lblNewLabel_2.setText("Description");
+
+        txtDescription = new Text(composite_1, SWT.NONE);
+        txtDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
     }
     public TreeViewer getTreeTermHierarchy() {
         return treeTermHierarchy;
@@ -76,4 +112,13 @@ public class GfBioTerminologyImportComposite extends Composite{
     public ComboViewer getComboTerminologies() {
         return comboTerminologies;
     }
+    public Text getLblDescription() {
+        return txtDescription;
+    }
+    public Text getLblUri() {
+        return txtUri;
+    }
+    public Text getLblLabel() {
+        return txtLabel;
+    }
 }
index b2dca7a691e066b0b73a9c0bee4329bbc2083bc3..327d213448eda7bae64e03b51fd2a7b0c0972db1 100644 (file)
@@ -20,6 +20,7 @@ import org.eclipse.swt.widgets.Composite;
  */
 public class GfBioTerminologyImportPart {
 
+    @SuppressWarnings("unused")
     @PostConstruct
     public void create(Composite parent){
         GfBioTerminologyImportComposite composite = new GfBioTerminologyImportComposite(parent, SWT.NONE);
index dff94db322f741922674b1304c9874361b643f9b..4959faaa5ba73c9fa620e6b63d2e58872d8c5555 100644 (file)
@@ -16,6 +16,7 @@ import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.ComboViewer;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.dnd.DND;
 import org.eclipse.swt.dnd.DragSourceAdapter;
@@ -122,6 +123,7 @@ public class GfBioTerminologyImportPresenter {
         composite.getTreeTermHierarchy().setLabelProvider(new OntologyTermLabelProvider());
 
         //tree results
+        composite.getTreeTermHierarchy().addSelectionChangedListener(e->updateDetails(e.getSelection()));
         composite.getTreeTermHierarchy().setContentProvider(new OntologyTermContentProvider());
         composite.getTreeTermHierarchy().setLabelProvider(new OntologyTermLabelProvider());
         Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer(),};
@@ -140,6 +142,29 @@ public class GfBioTerminologyImportPresenter {
             }
         });
     }
+    
+    private void clearDetails(){
+        composite.getLblLabel().setText("");
+        composite.getLblUri().setText("");
+        composite.getLblDescription().setText("");
+    }
+
+    private void updateDetails(ISelection s) {
+        StructuredSelection selection = (StructuredSelection)s;
+        if(selection.isEmpty()){
+            clearDetails();
+        }
+        Object next = selection.iterator().next();
+        if(next instanceof OntologyTermWrapper){
+            OntologyTermWrapper wrapper = (OntologyTermWrapper)next;
+            String label = wrapper.getLabel();
+            String uri = wrapper.getUri();
+            String description = wrapper.getDescription();
+            composite.getLblLabel().setText(label!=null?label:"");
+            composite.getLblUri().setText(uri!=null?uri:"");
+            composite.getLblDescription().setText(description!=null?description:"");
+        }
+    }
 
     private void search(){
         String searchString = composite.getTxtSearch().getText();
index 05a52711450848edee02c47312820d7520bba7e7..eb8453da811c54c558b9e4e7b9d0ab0d9dba074e 100644 (file)
@@ -8,7 +8,11 @@
 */
 package eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper;
 
+import java.util.List;
+
 /**
+ * Wrapper for terms received from the GfBio terminology service.
+ *
  * @author pplitzner
  * @since Apr 23, 2018
  *
@@ -16,6 +20,9 @@ package eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper;
 public class OntologyTermWrapper extends TermWrapper{
 
     private String sourceTerminology;
+    private String description;
+    private List<String> synonyms;
+    private String comment;
     public OntologyTermWrapper(String uri, String label, String sourceTerminology) {
         super(uri, label);
         this.sourceTerminology = sourceTerminology;
@@ -23,4 +30,25 @@ public class OntologyTermWrapper extends TermWrapper{
     public String getSourceTerminology() {
         return sourceTerminology;
     }
+    public String getDescription() {
+        return description;
+    }
+    public void setDescription(String description) {
+        this.description = description;
+    }
+    public List<String> getSynonyms() {
+        return synonyms;
+    }
+    public void setSynonyms(List<String> synonyms) {
+        this.synonyms = synonyms;
+    }
+    public String getComment() {
+        return comment;
+    }
+    public void setComment(String comment) {
+        this.comment = comment;
+    }
+    public void setSourceTerminology(String sourceTerminology) {
+        this.sourceTerminology = sourceTerminology;
+    }
 }