Project

General

Profile

Revision 0f31eab7

ID0f31eab757a22071fb2ae689b98576ef57be4bb8
Parent 572814ac
Child 0fa485b5

Added by Patrick Plitzner over 3 years ago

ref #7362 Add term details to GfBio import composite

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportComposite.java
16 16
import org.eclipse.swt.widgets.Button;
17 17
import org.eclipse.swt.widgets.Combo;
18 18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Label;
19 20
import org.eclipse.swt.widgets.Text;
20 21
import org.eclipse.swt.widgets.Tree;
21 22

  
......
33 34
    private Composite composite;
34 35
    private Button btnRemoveTerminology;
35 36
    private ComboViewer comboTerminologies;
37
    private Composite composite_1;
38
    private Composite composite_2;
39
    private Label lblNewLabel;
40
    private Label lblNewLabel_1;
41
    private Label lblNewLabel_2;
42
    private Text txtLabel;
43
    private Text txtUri;
44
    private Text txtDescription;
36 45

  
37 46
    public GfBioTerminologyImportComposite(Composite parent, int style) {
38 47
        super(parent, style);
......
55 64
        btnSearch = new Button(composite, SWT.NONE);
56 65
        btnSearch.setText("Search");
57 66

  
58
        treeTermHierarchy = new TreeViewer(this, SWT.BORDER);
67
        composite_2 = new Composite(this, SWT.NONE);
68
        composite_2.setLayout(new GridLayout(2, false));
69
        composite_2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
70

  
71
        treeTermHierarchy = new TreeViewer(composite_2, SWT.BORDER);
59 72
        Tree tree = treeTermHierarchy.getTree();
60
        GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
61
        gd_tree.widthHint = 423;
62
        tree.setLayoutData(gd_tree);
73
        tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
74

  
75
        composite_1 = new Composite(composite_2, SWT.NONE);
76
        composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
77
        composite_1.setLayout(new GridLayout(2, false));
78

  
79
        lblNewLabel = new Label(composite_1, SWT.NONE);
80
        lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
81
        lblNewLabel.setText("Label");
82

  
83
        txtLabel = new Text(composite_1, SWT.NONE);
84
        txtLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
85

  
86
        lblNewLabel_1 = new Label(composite_1, SWT.NONE);
87
        lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
88
        lblNewLabel_1.setText("URI");
89

  
90
        txtUri = new Text(composite_1, SWT.NONE);
91
        txtUri.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
92

  
93
        lblNewLabel_2 = new Label(composite_1, SWT.NONE);
94
        lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
95
        lblNewLabel_2.setText("Description");
96

  
97
        txtDescription = new Text(composite_1, SWT.NONE);
98
        txtDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
63 99
    }
64 100
    public TreeViewer getTreeTermHierarchy() {
65 101
        return treeTermHierarchy;
......
76 112
    public ComboViewer getComboTerminologies() {
77 113
        return comboTerminologies;
78 114
    }
115
    public Text getLblDescription() {
116
        return txtDescription;
117
    }
118
    public Text getLblUri() {
119
        return txtUri;
120
    }
121
    public Text getLblLabel() {
122
        return txtLabel;
123
    }
79 124
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPart.java
20 20
 */
21 21
public class GfBioTerminologyImportPart {
22 22

  
23
    @SuppressWarnings("unused")
23 24
    @PostConstruct
24 25
    public void create(Composite parent){
25 26
        GfBioTerminologyImportComposite composite = new GfBioTerminologyImportComposite(parent, SWT.NONE);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPresenter.java
16 16
import org.eclipse.jface.viewers.ComboViewer;
17 17
import org.eclipse.jface.viewers.ISelection;
18 18
import org.eclipse.jface.viewers.IStructuredSelection;
19
import org.eclipse.jface.viewers.StructuredSelection;
19 20
import org.eclipse.swt.SWT;
20 21
import org.eclipse.swt.dnd.DND;
21 22
import org.eclipse.swt.dnd.DragSourceAdapter;
......
122 123
        composite.getTreeTermHierarchy().setLabelProvider(new OntologyTermLabelProvider());
123 124

  
124 125
        //tree results
126
        composite.getTreeTermHierarchy().addSelectionChangedListener(e->updateDetails(e.getSelection()));
125 127
        composite.getTreeTermHierarchy().setContentProvider(new OntologyTermContentProvider());
126 128
        composite.getTreeTermHierarchy().setLabelProvider(new OntologyTermLabelProvider());
127 129
        Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer(),};
......
140 142
            }
141 143
        });
142 144
    }
145
    
146
    private void clearDetails(){
147
        composite.getLblLabel().setText("");
148
        composite.getLblUri().setText("");
149
        composite.getLblDescription().setText("");
150
    }
151

  
152
    private void updateDetails(ISelection s) {
153
        StructuredSelection selection = (StructuredSelection)s;
154
        if(selection.isEmpty()){
155
            clearDetails();
156
        }
157
        Object next = selection.iterator().next();
158
        if(next instanceof OntologyTermWrapper){
159
            OntologyTermWrapper wrapper = (OntologyTermWrapper)next;
160
            String label = wrapper.getLabel();
161
            String uri = wrapper.getUri();
162
            String description = wrapper.getDescription();
163
            composite.getLblLabel().setText(label!=null?label:"");
164
            composite.getLblUri().setText(uri!=null?uri:"");
165
            composite.getLblDescription().setText(description!=null?description:"");
166
        }
167
    }
143 168

  
144 169
    private void search(){
145 170
        String searchString = composite.getTxtSearch().getText();
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/wrapper/OntologyTermWrapper.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper;
10 10

  
11
import java.util.List;
12

  
11 13
/**
14
 * Wrapper for terms received from the GfBio terminology service.
15
 *
12 16
 * @author pplitzner
13 17
 * @since Apr 23, 2018
14 18
 *
......
16 20
public class OntologyTermWrapper extends TermWrapper{
17 21

  
18 22
    private String sourceTerminology;
23
    private String description;
24
    private List<String> synonyms;
25
    private String comment;
19 26
    public OntologyTermWrapper(String uri, String label, String sourceTerminology) {
20 27
        super(uri, label);
21 28
        this.sourceTerminology = sourceTerminology;
......
23 30
    public String getSourceTerminology() {
24 31
        return sourceTerminology;
25 32
    }
33
    public String getDescription() {
34
        return description;
35
    }
36
    public void setDescription(String description) {
37
        this.description = description;
38
    }
39
    public List<String> getSynonyms() {
40
        return synonyms;
41
    }
42
    public void setSynonyms(List<String> synonyms) {
43
        this.synonyms = synonyms;
44
    }
45
    public String getComment() {
46
        return comment;
47
    }
48
    public void setComment(String comment) {
49
        this.comment = comment;
50
    }
51
    public void setSourceTerminology(String sourceTerminology) {
52
        this.sourceTerminology = sourceTerminology;
53
    }
26 54
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)