Revision e8423490
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportComposite.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.taxeditor.view.webimport.termimport; |
10 | 10 |
|
11 | 11 |
import org.eclipse.jface.viewers.ComboViewer; |
12 |
import org.eclipse.jface.viewers.ListViewer; |
|
12 | 13 |
import org.eclipse.jface.viewers.TreeViewer; |
13 | 14 |
import org.eclipse.swt.SWT; |
15 |
import org.eclipse.swt.custom.ScrolledComposite; |
|
14 | 16 |
import org.eclipse.swt.layout.GridData; |
15 | 17 |
import org.eclipse.swt.layout.GridLayout; |
16 | 18 |
import org.eclipse.swt.widgets.Button; |
... | ... | |
20 | 22 |
import org.eclipse.swt.widgets.List; |
21 | 23 |
import org.eclipse.swt.widgets.Text; |
22 | 24 |
import org.eclipse.swt.widgets.Tree; |
25 |
import org.eclipse.wb.swt.SWTResourceManager; |
|
23 | 26 |
|
24 | 27 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
25 | 28 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
... | ... | |
49 | 52 |
private Text txtDescription; |
50 | 53 |
private Button btnLoadDetails; |
51 | 54 |
private Label lblNewLabel_3; |
52 |
private ScrolledComposite scrolledComposite; |
|
53 |
private List listSynonyms; |
|
54 | 55 |
private Composite composite_3; |
55 | 56 |
private Label lblNewLabel_4; |
56 | 57 |
private Button btnRemoveVocabulary; |
57 | 58 |
private TermVocabularyComboViewer termVocabularyComboViewer; |
59 |
private List list; |
|
60 |
private ListViewer listSynonyms; |
|
58 | 61 |
|
59 | 62 |
public GfBioTerminologyImportComposite(Composite parent, int style) { |
60 | 63 |
super(parent, style); |
... | ... | |
115 | 118 |
lblNewLabel.setText("Label"); |
116 | 119 |
|
117 | 120 |
txtLabel = new Text(composite_1, SWT.NONE); |
121 |
txtLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); |
|
122 |
txtLabel.setEditable(false); |
|
118 | 123 |
txtLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); |
119 | 124 |
|
120 | 125 |
lblNewLabel_1 = new Label(composite_1, SWT.NONE); |
... | ... | |
122 | 127 |
lblNewLabel_1.setText("URI"); |
123 | 128 |
|
124 | 129 |
txtUri = new Text(composite_1, SWT.NONE); |
130 |
txtUri.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); |
|
131 |
txtUri.setEditable(false); |
|
125 | 132 |
txtUri.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); |
126 | 133 |
|
127 | 134 |
lblNewLabel_2 = new Label(composite_1, SWT.NONE); |
... | ... | |
129 | 136 |
lblNewLabel_2.setText("Description"); |
130 | 137 |
|
131 | 138 |
txtDescription = new Text(composite_1, SWT.NONE); |
139 |
txtDescription.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); |
|
140 |
txtDescription.setEditable(false); |
|
132 | 141 |
txtDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); |
142 |
|
|
143 |
lblNewLabel_3 = new Label(composite_1, SWT.NONE); |
|
144 |
lblNewLabel_3.setText("Synonyms"); |
|
145 |
|
|
146 |
listSynonyms = new ListViewer(composite_1, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); |
|
147 |
list = listSynonyms.getList(); |
|
148 |
list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
|
149 |
list.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND)); |
|
133 | 150 |
} |
134 | 151 |
public TreeViewer getTreeTermHierarchy() { |
135 | 152 |
return treeTermHierarchy; |
... | ... | |
158 | 175 |
public Button getBtnLoadDetails() { |
159 | 176 |
return btnLoadDetails; |
160 | 177 |
} |
178 |
public ListViewer getListSynonyms() { |
|
179 |
return listSynonyms; |
|
180 |
} |
|
161 | 181 |
public TermVocabularyComboViewer getTermVocabularyComboViewer() { |
162 | 182 |
return termVocabularyComboViewer; |
163 | 183 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPresenter.java | ||
---|---|---|
179 | 179 |
composite.getLblLabel().setText(""); |
180 | 180 |
composite.getLblUri().setText(""); |
181 | 181 |
composite.getLblDescription().setText(""); |
182 |
composite.getListSynonyms().removeAll(); |
|
182 |
composite.getListSynonyms().getList().removeAll();
|
|
183 | 183 |
} |
184 | 184 |
|
185 | 185 |
private void updateDetails(ISelection s) { |
... | ... | |
195 | 195 |
composite.getLblLabel().setText(label!=null?label:""); |
196 | 196 |
composite.getLblUri().setText(uri!=null?uri:""); |
197 | 197 |
composite.getLblDescription().setText(description!=null?description:""); |
198 |
if(wrapper.getSynonyms()!=null){ |
|
199 |
if(wrapper.getSynonyms().isEmpty()){ |
|
200 |
composite.getListSynonyms().getList().removeAll(); |
|
201 |
} |
|
202 |
else{ |
|
203 |
wrapper.getSynonyms().forEach(syn->composite.getListSynonyms().add(syn)); |
|
204 |
} |
|
205 |
} |
|
198 | 206 |
} |
199 | 207 |
} |
200 | 208 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/ParserUtil.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.view.webimport.termimport.parser; |
10 | 10 |
|
11 |
import java.util.ArrayList; |
|
12 |
import java.util.List; |
|
13 |
|
|
11 | 14 |
import org.json.JSONArray; |
12 | 15 |
import org.json.JSONException; |
13 | 16 |
import org.json.JSONObject; |
... | ... | |
42 | 45 |
return null; |
43 | 46 |
} |
44 | 47 |
|
48 |
public static List<String> parseSynonyms(JSONObject jsonObject) throws JSONException{ |
|
49 |
List<String> synonyms = new ArrayList<>(); |
|
50 |
String synomymKey = "synonyms"; |
|
51 |
if(jsonObject.has(synomymKey)){ |
|
52 |
JSONArray jsonArray = jsonObject.getJSONArray(synomymKey); |
|
53 |
for(int i=0;i<jsonArray.length();i++){ |
|
54 |
synonyms.add(jsonArray.getString(i)); |
|
55 |
} |
|
56 |
} |
|
57 |
return synonyms; |
|
58 |
} |
|
59 |
|
|
45 | 60 |
public static String parseTerminology(JSONObject jsonObject) throws JSONException { |
46 | 61 |
return jsonObject.getString("sourceTerminology"); |
47 | 62 |
} |
... | ... | |
54 | 69 |
String request = new RequestTerm(wrapper.getUri(), wrapper.getSourceTerminology()).request(); |
55 | 70 |
OntologyTermWrapper detailTerm = TermParser.parseSingleTerm(request); |
56 | 71 |
wrapper.setDescription(detailTerm.getDescription()); |
72 |
wrapper.setSynonyms(detailTerm.getSynonyms()); |
|
57 | 73 |
} |
58 | 74 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/TermParser.java | ||
---|---|---|
58 | 58 |
String label = ParserUtil.parseLabel(jsonObject); |
59 | 59 |
String uri= ParserUtil.parseUri(jsonObject); |
60 | 60 |
String terminology= ParserUtil.parseTerminology(jsonObject); |
61 |
List<String> synonyms = ParserUtil.parseSynonyms(jsonObject); |
|
61 | 62 |
OntologyTermWrapper wrapper = new OntologyTermWrapper(uri, label, terminology); |
63 |
wrapper.setSynonyms(synonyms); |
|
62 | 64 |
wrapper.setDescription(description); |
63 | 65 |
return wrapper; |
64 | 66 |
} |
Also available in: Unified diff
ref #7362 Show synonyms for term details