From: preecej Date: Tue, 31 Jan 2012 23:25:19 +0000 (+0000) Subject: Refactored web service response term data into Term object. Created Term class; now... X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=1b6df056f718bced80a22077ed065a30e0d6caae;p=old-jaiswallab-svn%2F.git Refactored web service response term data into Term object. Created Term class; now used by term lookup dropdown and "term edit" popup dialogue. Should also be added to term label, term detail web service response and file metadata export. svn path=/; revision=291 --- diff --git a/Annotation/src/ie/dcu/apps/ist/dialogs/PopUpLabelDialog.java b/Annotation/src/ie/dcu/apps/ist/dialogs/PopUpLabelDialog.java index 6b19e62..3ee09e5 100644 --- a/Annotation/src/ie/dcu/apps/ist/dialogs/PopUpLabelDialog.java +++ b/Annotation/src/ie/dcu/apps/ist/dialogs/PopUpLabelDialog.java @@ -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 listElements = new ArrayList(); + ArrayList terms = new ArrayList(); //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 containing each Label item * */ - public ArrayList getLabels(String content) { - ArrayList labels = new ArrayList(); + public ArrayList getLabels(String content) { + ArrayList terms = new ArrayList(); // 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 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 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 synonyms) { + this.synonyms = synonyms; + } + + // constructor + public OntologyTerm() { + this.synonyms = new ArrayList(); + } + +} diff --git a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java index c77c58e..d803e34 100644 --- a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java +++ b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java @@ -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 listElements = new ArrayList(); + ArrayList terms = new ArrayList(); //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