Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
Refactored web service response term data into Term object. Created Term class; now...
authorpreecej <preecej@localhost>
Tue, 31 Jan 2012 23:25:19 +0000 (23:25 +0000)
committerpreecej <preecej@localhost>
Tue, 31 Jan 2012 23:25:19 +0000 (23:25 +0000)
svn path=/; revision=291

Annotation/src/ie/dcu/apps/ist/dialogs/PopUpLabelDialog.java
Annotation/src/ie/dcu/apps/ist/labelling/Labels.java
Annotation/src/ie/dcu/apps/ist/labelling/OntologyTerm.java [new file with mode: 0644]
Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java

index 6b19e62260c00d9437fd99e05f86960bf81c70e6..3ee09e51e61dc83277d51b87c43d212e920db4a2 100644 (file)
@@ -6,6 +6,7 @@ import ie.dcu.swt.SwtUtils;
 import ie.dcu.apps.ist.labelling.*;
 import ie.dcu.swt.layout.LayoutFactory;
 
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.events.KeyListener;
@@ -104,22 +105,25 @@ public class PopUpLabelDialog extends Dialog {
                labelCombo.addKeyListener(new KeyListener() {
                        @Override
                        public void keyReleased(KeyEvent e) {
-                               ArrayList<String> listElements = new ArrayList<String>();
+                               ArrayList<OntologyTerm> terms = new ArrayList<OntologyTerm>();
                                //For the down arrow functionality
                                if(e.keyCode == 16777218)
                                {
                                        labelCombo.setListVisible(true);
                                }
-                               // If key pressed is only a number of charecter or space.
+                               // If key pressed is only a number of character or space.
                                else if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 97 && e.keyCode <= 122) || e.keyCode == 32)
                                {
                                        //For removing all previously assigned labels
                                        labelCombo.remove(0,labelCombo.getItemCount()-1);
-                                       listElements = labels.getLabels(labelCombo.getText());
+                                       terms = labels.getLabels(labelCombo.getText());
                                }
-                               for (int i=0; i<listElements.size();i++)
+                               int i = 0;
+                               for (OntologyTerm term : terms)
                                {
-                                       labelCombo.add(listElements.get(i),i);
+                               // set text for term label
+                                       labelCombo.add(term.getFormattedTerm(),i);
+                                       i++;
                                }
                        }
 
index c85b7f6361bd4ff0cdaa8a8bb449bacf74439feb..f5235d3e90be0a8fdcd474a4f55d8e43f038d2ee 100644 (file)
@@ -2,6 +2,7 @@ package ie.dcu.apps.ist.labelling;
 
 import ie.dcu.apps.ist.AppWindow;
 
+import java.awt.List;
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.net.HttpURLConnection;
@@ -24,10 +25,9 @@ public class Labels
         * ArrayList<String> containing each Label item
         * 
         */
-       public ArrayList<String> getLabels(String content) {
-               ArrayList<String> labels = new ArrayList<String>();
+       public ArrayList<OntologyTerm> getLabels(String content) {
+        ArrayList<OntologyTerm> terms = new ArrayList<OntologyTerm>();
                // temporary variable for storing each list element in the loop
-               String listElement;
                try
            {
                        String encodedContent = URLEncoder.encode(content.toString(),"UTF-8");
@@ -45,11 +45,14 @@ public class Labels
                        {
                                object = new JSONObject(inputLine);
                        }
+                       
                        JSONArray array = new JSONArray(object.getString("PO_term_search_response"));
                        for(int i=0; i<array.length();i++)
                        {
-                               listElement = (array.getJSONObject(i).getString("match")+" {"+array.getJSONObject(i).getString("accession_id")+"}");
-                               labels.add(i,StringEscapeUtils.unescapeHtml4(listElement));
+                               OntologyTerm term = new OntologyTerm();
+                               term.setAccessionId(array.getJSONObject(i).getString("accession_id"));
+                               term.setName(array.getJSONObject(i).getString("match"));
+                               terms.add(term);
                        }
                        in.close();
                }
@@ -61,7 +64,7 @@ public class Labels
            catch(Exception ex)
            {
            }
-           return labels;
+           return terms;
        }
        
 }
\ No newline at end of file
diff --git a/Annotation/src/ie/dcu/apps/ist/labelling/OntologyTerm.java b/Annotation/src/ie/dcu/apps/ist/labelling/OntologyTerm.java
new file mode 100644 (file)
index 0000000..76b22ab
--- /dev/null
@@ -0,0 +1,70 @@
+/**
+ * 
+ */
+package ie.dcu.apps.ist.labelling;
+
+import java.util.ArrayList;
+
+import org.apache.commons.lang3.StringEscapeUtils;
+
+/**
+ * @author preecej
+ * Contains attributes associated with terms received from ontologies.
+ */
+public class OntologyTerm {
+
+       private String accessionId;
+       private String name;
+       private String aspect;
+       private String definition;
+       private String comment;
+       private ArrayList<String> synonyms;
+
+       public String getAccessionId() {
+               return this.accessionId;
+       }
+       public String getName() {
+               return this.name;
+       }
+       public String getAspect() {
+               return this.aspect;
+       }
+       public String getDefinition() {
+               return this.definition;
+       }
+       public String getComment() {
+               return this.comment;
+       }
+       public ArrayList<String> getSynonyms() {
+               return this.synonyms;
+       }
+       // returns an HTML-safe label formatted to include both name and accession id
+       public String getFormattedTerm() {
+               return StringEscapeUtils.unescapeHtml4(this.name) + " {" + this.accessionId + "}";
+       }
+
+       public void setAccessionId(String accessionId) {
+               this.accessionId = accessionId;
+       }
+       public void setName(String name) {
+               this.name = name;
+       }
+       public void setAspect(String aspect) {
+               this.aspect = aspect;
+       }
+       public void setDefinition(String definition) {
+               this.definition = definition;
+       }
+       public void setComment(String comment) {
+               this.comment = comment;
+       }
+       public void setSynonyms(ArrayList<String> synonyms) {
+               this.synonyms = synonyms;
+       }
+
+       // constructor
+       public OntologyTerm() {
+               this.synonyms = new ArrayList<String>();
+       }
+       
+}
index c77c58e0e11c99623ae15d88f209a68141009ac2..d803e3484a6e3f9e643d5ee9b8662c42ca1522bb 100644 (file)
@@ -20,6 +20,7 @@ import java.util.ArrayList;
 import java.util.Properties;
 import java.util.logging.*;
 
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.action.*;
 import org.eclipse.jface.operation.*;
@@ -239,11 +240,13 @@ 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) {
@@ -271,7 +274,7 @@ public class SegmentationView extends Composite {
         */
        public void dropdownLabels(KeyEvent e)
        {
-               ArrayList<String> listElements = new ArrayList<String>();
+               ArrayList<OntologyTerm> terms = new ArrayList<OntologyTerm>();
                //For the down arrow functionality
                if(e.keyCode == 16777218)
                {
@@ -282,17 +285,22 @@ public class SegmentationView extends Composite {
                {
                        //For removing all previously assigned labels
                        comboLabel.remove(0,comboLabel.getItemCount()-1);
-                       listElements = labels.getLabels(comboLabel.getText());
+                       terms = labels.getLabels(comboLabel.getText());
                        assign.setEnabled(!(comboLabel.getText().isEmpty()));
-                       
+                       if (e.keyCode == 32) {
+                               termDetailLookup();
+                       }
                }
-               for (int i=0; i<listElements.size();i++)
+               int i = 0;
+               for (OntologyTerm term : terms)
                {
-                       comboLabel.add(listElements.get(i),i);
+               // set text for term label
+                       comboLabel.add(term.getFormattedTerm(),i);
+                       i++;
                }
        }
 
-       private void termDetailLookup(FocusEvent e) {
+       private void termDetailLookup() {
                // 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);
        }