private Text txtLabel;
private Text txtUri;
private Text txtDescription;
+ private Button btnLoadDetails;
public GfBioTerminologyImportComposite(Composite parent, int style) {
super(parent, style);
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));
+ new Label(composite_1, SWT.NONE);
+
+ btnLoadDetails = new Button(composite_1, SWT.NONE);
+ btnLoadDetails.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ btnLoadDetails.setText("Load Details");
lblNewLabel = new Label(composite_1, SWT.NONE);
lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
public Text getLblLabel() {
return txtLabel;
}
+ public Button getBtnLoadDetails() {
+ return btnLoadDetails;
+ }
}
import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.TerminologyParser;
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestSearch;
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestSuggest;
+import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestTerm;
import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestTerminologies;
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.OntologyTermWrapper;
import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.TerminologyWrapper;
}
});
+ composite.getBtnLoadDetails().addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ loadTermDetails();
+ }
+ });
+
composite.getTreeTermHierarchy().setContentProvider(new OntologyTermContentProvider());
composite.getTreeTermHierarchy().setLabelProvider(new OntologyTermLabelProvider());
});
}
+ private OntologyTermWrapper getSelectedTerm(IStructuredSelection selection){
+ Iterator iterator = selection.iterator();
+ if(iterator.hasNext()){
+ Object next = iterator.next();
+ if(next instanceof OntologyTermWrapper){
+ return (OntologyTermWrapper) next;
+ }
+ }
+ return null;
+ }
+
private void clearDetails(){
composite.getLblLabel().setText("");
composite.getLblUri().setText("");
if(selection.isEmpty()){
clearDetails();
}
- Iterator iterator = selection.iterator();
- if(iterator.hasNext()){
- Object next = 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:"");
- }
- }
+ OntologyTermWrapper wrapper = getSelectedTerm(selection);
+ 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 loadTermDetails(){
+ OntologyTermWrapper selectedWrapper = getSelectedTerm((IStructuredSelection) composite.getTreeTermHierarchy().getSelection());
+ //load term description
+ String request = new RequestTerm(selectedWrapper.getUri(), selectedWrapper.getSourceTerminology()).request();
+ OntologyTermWrapper detailTerm = TermParser.parseSingleTerm(request);
+ selectedWrapper.setDescription(detailTerm.getDescription());
+ updateDetails(new StructuredSelection(selectedWrapper));
}
private void search(){