Revision 7fcb1960
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportComposite.java | ||
---|---|---|
42 | 42 |
private Text txtLabel; |
43 | 43 |
private Text txtUri; |
44 | 44 |
private Text txtDescription; |
45 |
private Button btnLoadDetails; |
|
45 | 46 |
|
46 | 47 |
public GfBioTerminologyImportComposite(Composite parent, int style) { |
47 | 48 |
super(parent, style); |
... | ... | |
75 | 76 |
composite_1 = new Composite(composite_2, SWT.NONE); |
76 | 77 |
composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); |
77 | 78 |
composite_1.setLayout(new GridLayout(2, false)); |
79 |
new Label(composite_1, SWT.NONE); |
|
80 |
|
|
81 |
btnLoadDetails = new Button(composite_1, SWT.NONE); |
|
82 |
btnLoadDetails.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); |
|
83 |
btnLoadDetails.setText("Load Details"); |
|
78 | 84 |
|
79 | 85 |
lblNewLabel = new Label(composite_1, SWT.NONE); |
80 | 86 |
lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); |
... | ... | |
121 | 127 |
public Text getLblLabel() { |
122 | 128 |
return txtLabel; |
123 | 129 |
} |
130 |
public Button getBtnLoadDetails() { |
|
131 |
return btnLoadDetails; |
|
132 |
} |
|
124 | 133 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPresenter.java | ||
---|---|---|
39 | 39 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.TerminologyParser; |
40 | 40 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestSearch; |
41 | 41 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestSuggest; |
42 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestTerm; |
|
42 | 43 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestTerminologies; |
43 | 44 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.OntologyTermWrapper; |
44 | 45 |
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.TerminologyWrapper; |
... | ... | |
120 | 121 |
} |
121 | 122 |
}); |
122 | 123 |
|
124 |
composite.getBtnLoadDetails().addSelectionListener(new SelectionAdapter() { |
|
125 |
@Override |
|
126 |
public void widgetSelected(SelectionEvent e) { |
|
127 |
loadTermDetails(); |
|
128 |
} |
|
129 |
}); |
|
130 |
|
|
123 | 131 |
composite.getTreeTermHierarchy().setContentProvider(new OntologyTermContentProvider()); |
124 | 132 |
composite.getTreeTermHierarchy().setLabelProvider(new OntologyTermLabelProvider()); |
125 | 133 |
|
... | ... | |
144 | 152 |
}); |
145 | 153 |
} |
146 | 154 |
|
155 |
private OntologyTermWrapper getSelectedTerm(IStructuredSelection selection){ |
|
156 |
Iterator iterator = selection.iterator(); |
|
157 |
if(iterator.hasNext()){ |
|
158 |
Object next = iterator.next(); |
|
159 |
if(next instanceof OntologyTermWrapper){ |
|
160 |
return (OntologyTermWrapper) next; |
|
161 |
} |
|
162 |
} |
|
163 |
return null; |
|
164 |
} |
|
165 |
|
|
147 | 166 |
private void clearDetails(){ |
148 | 167 |
composite.getLblLabel().setText(""); |
149 | 168 |
composite.getLblUri().setText(""); |
... | ... | |
155 | 174 |
if(selection.isEmpty()){ |
156 | 175 |
clearDetails(); |
157 | 176 |
} |
158 |
Iterator iterator = selection.iterator(); |
|
159 |
if(iterator.hasNext()){ |
|
160 |
Object next = iterator.next(); |
|
161 |
if(next instanceof OntologyTermWrapper){ |
|
162 |
OntologyTermWrapper wrapper = (OntologyTermWrapper)next; |
|
163 |
String label = wrapper.getLabel(); |
|
164 |
String uri = wrapper.getUri(); |
|
165 |
String description = wrapper.getDescription(); |
|
166 |
composite.getLblLabel().setText(label!=null?label:""); |
|
167 |
composite.getLblUri().setText(uri!=null?uri:""); |
|
168 |
composite.getLblDescription().setText(description!=null?description:""); |
|
169 |
} |
|
170 |
} |
|
177 |
OntologyTermWrapper wrapper = getSelectedTerm(selection); |
|
178 |
String label = wrapper.getLabel(); |
|
179 |
String uri = wrapper.getUri(); |
|
180 |
String description = wrapper.getDescription(); |
|
181 |
composite.getLblLabel().setText(label!=null?label:""); |
|
182 |
composite.getLblUri().setText(uri!=null?uri:""); |
|
183 |
composite.getLblDescription().setText(description!=null?description:""); |
|
184 |
} |
|
185 |
|
|
186 |
private void loadTermDetails(){ |
|
187 |
OntologyTermWrapper selectedWrapper = getSelectedTerm((IStructuredSelection) composite.getTreeTermHierarchy().getSelection()); |
|
188 |
//load term description |
|
189 |
String request = new RequestTerm(selectedWrapper.getUri(), selectedWrapper.getSourceTerminology()).request(); |
|
190 |
OntologyTermWrapper detailTerm = TermParser.parseSingleTerm(request); |
|
191 |
selectedWrapper.setDescription(detailTerm.getDescription()); |
|
192 |
updateDetails(new StructuredSelection(selectedWrapper)); |
|
171 | 193 |
} |
172 | 194 |
|
173 | 195 |
private void search(){ |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/ParserUtil.java | ||
---|---|---|
32 | 32 |
} |
33 | 33 |
|
34 | 34 |
public static String parseDescription(JSONObject jsonObject) throws JSONException{ |
35 |
return jsonObject.getString("description"); |
|
35 |
String descriptionKey = "description"; |
|
36 |
if(jsonObject.has(descriptionKey)){ |
|
37 |
return jsonObject.getString(descriptionKey); |
|
38 |
} |
|
39 |
return null; |
|
36 | 40 |
} |
37 | 41 |
|
38 | 42 |
public static String parseTerminology(JSONObject jsonObject) throws JSONException { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/SuggestParser.java | ||
---|---|---|
36 | 36 |
String uri= ParserUtil.parseUri(jsonObject); |
37 | 37 |
String sourceTerminology = ParserUtil.parseTerminology(jsonObject); |
38 | 38 |
String request = new RequestTerm(uri, sourceTerminology).request(); |
39 |
//load term description |
|
40 |
String description = TermParser.parseSingleTerm(request).getDescription(); |
|
41 | 39 |
OntologyTermWrapper wrapper = new OntologyTermWrapper(uri, label, sourceTerminology); |
42 |
wrapper.setDescription(description); |
|
43 | 40 |
wrapperList.add(wrapper); |
44 | 41 |
} |
45 | 42 |
} catch (JSONException jsonException) { |
Also available in: Unified diff
ref #7362 Add "Load Details" button