comboLabel.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
- comboLabel.remove(0,comboLabel.getItemCount()-1);
- setLabel(comboLabel.getText());
- Display.getCurrent().asyncExec(new Runnable() {
- public void run() {
- comboLabel.setText(comboLabel.getText());
- comboLabel.forceFocus();
- }
- });
+ if(e.keyCode == 16777218)
+ {
+ comboLabel.setListVisible(true);
+ }
+ else if (!(e.keyCode == 13))
+ {
+ comboLabel.setListVisible(false);
+ setLabel(comboLabel.getText());
+ }
+ //comboLabel.setSelection(arg0);
}
@Override
public void keyPressed(KeyEvent arg0) {
private void setLabel(String content) {
try
{
- String content1 = 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="+content1+"&inc_synonyms&branch_filter=plant_anatomy&max=20");
+ comboLabel.remove(0,comboLabel.getItemCount()-1);
+ 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");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
if(connection.getResponseCode() == 200)
{
String inputLine;
catch(Exception ex)
{
}
+ /*if(comboLabel.getText().equals(null) && comboLabel.getItemCount()>0)
+ {
+ comboLabel.setText(comboLabel.getItem(0));
+ }*/
assign.setEnabled(!(comboLabel.getText().isEmpty()));
}