From e024a31faaaa7f161e1ec8989da72d5d2fe53b3b Mon Sep 17 00:00:00 2001 From: preecej Date: Tue, 31 Jan 2012 00:09:44 +0000 Subject: [PATCH] Moved PO web service calls to application.properties file; added lookup label focus listener for PO term details call svn path=/; revision=287 --- .../resources/config/application.properties | 4 ++ Annotation/src/ie/dcu/apps/ist/AppWindow.java | 2 +- .../src/ie/dcu/apps/ist/labelling/Labels.java | 8 +++- .../dcu/apps/ist/views/SegmentationView.java | 48 +++++++++++++++++-- 4 files changed, 55 insertions(+), 7 deletions(-) diff --git a/Annotation/resources/config/application.properties b/Annotation/resources/config/application.properties index d21c608..31a723f 100644 --- a/Annotation/resources/config/application.properties +++ b/Annotation/resources/config/application.properties @@ -25,3 +25,7 @@ ExperimentPanel.timeout-message=The time allocated for this task is up! ExperimentPanel.experiment-complete-message=The experiment has been completed ExperimentPanel.button.text.start=Start ExperimentPanel.button.text.finish=Finish + +# Web Service Configuration +POWebService.TermSearch.URL=http://palea.cgrb.oregonstate.edu/services/PO_web_service.php?request_type=term_search&search_value=&inc_synonyms&branch_filter=plant_anatomy&max=20 +POWebService.TermDetail.URL=http://palea.cgrb.oregonstate.edu/services/PO_web_service.php?request_type=term_detail&accession_id= \ No newline at end of file diff --git a/Annotation/src/ie/dcu/apps/ist/AppWindow.java b/Annotation/src/ie/dcu/apps/ist/AppWindow.java index 48a77cf..8203b93 100644 --- a/Annotation/src/ie/dcu/apps/ist/AppWindow.java +++ b/Annotation/src/ie/dcu/apps/ist/AppWindow.java @@ -33,7 +33,7 @@ import org.eclipse.swt.widgets.*; public class AppWindow extends ApplicationWindow implements FileDropListener { private static final Logger log = Logger.getLogger("AppWindow"); - private final Properties props; + public static Properties props; private AppPrefsManager prefsManager; private ActionManager actions; diff --git a/Annotation/src/ie/dcu/apps/ist/labelling/Labels.java b/Annotation/src/ie/dcu/apps/ist/labelling/Labels.java index ce6cd69..c85b7f6 100644 --- a/Annotation/src/ie/dcu/apps/ist/labelling/Labels.java +++ b/Annotation/src/ie/dcu/apps/ist/labelling/Labels.java @@ -1,5 +1,7 @@ package ie.dcu.apps.ist.labelling; +import ie.dcu.apps.ist.AppWindow; + import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; @@ -29,11 +31,13 @@ public class Labels try { String encodedContent = URLEncoder.encode(content.toString(),"UTF-8"); - URL url = new URL("http://palea.cgrb.oregonstate.edu/services/PO_web_service.php?request_type=term_search&search_value="+encodedContent+"&inc_synonyms&branch_filter=plant_anatomy&max=20"); + String webServiceURL = AppWindow.props.getProperty("POWebService.TermSearch.URL"); + webServiceURL = webServiceURL.replace("", encodedContent); + URL url = new URL(webServiceURL); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); // if the response from Web service is 'OK' - if(connection.getResponseCode() == 200) + if (connection.getResponseCode() == 200) { String inputLine; JSONObject object = null; diff --git a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java index 6db9763..1359f80 100644 --- a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java +++ b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java @@ -228,6 +228,11 @@ public class SegmentationView extends Composite { dropdownLabels(e); } }); + comboLabel.addFocusListener(new FocusAdapter() { + public void focusGained(FocusEvent e) { + termDetailLookup(e); + } + }); assign = SwtUtils.addButton(termLookupBar, 52, "Assign"); assign.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent arg0) { @@ -275,7 +280,15 @@ public class SegmentationView extends Composite { comboLabel.add(listElements.get(i),i); } } - + + private void termDetailLookup(FocusEvent e) { + // call term detail web service method using accession id (from 1) segment obj or 2) label selection (before assign button is clicked)) + termDetailTable.setEnabled(true); + } + + /** + * Set initial properties of the Term Detail right pane + */ private void createTermDetailTable() { termDetailTable.setLinesVisible (true); termDetailTable.setHeaderVisible (true); @@ -289,16 +302,43 @@ public class SegmentationView extends Composite { TableColumn column = new TableColumn (termDetailTable, SWT.NONE); column.setText (titles [i]); } - + + TableItem item1 = new TableItem (termDetailTable, SWT.NONE); + item1.setText (0, "Name"); + item1.setText (1, ""); + + TableItem item2 = new TableItem (termDetailTable, SWT.NONE); + item2.setText (0, "Accession ID"); + item2.setText (1, ""); + + TableItem item3 = new TableItem (termDetailTable, SWT.NONE); + item3.setText (0, "Branch"); // a.k.a. "Aspect" + item3.setText (1, ""); + + TableItem item4 = new TableItem (termDetailTable, SWT.NONE); + item4.setText (0, "Definition"); + item4.setText (1, ""); + + TableItem item5 = new TableItem (termDetailTable, SWT.NONE); + item5.setText (0, "Comment"); + item5.setText (1, ""); + + TableItem item6 = new TableItem (termDetailTable, SWT.NONE); + item6.setText (0, "Synonyms"); + item6.setText (1, ""); + + /* int count = 6; for (int i=0; i