From: lingutln Date: Thu, 29 Dec 2011 22:58:48 +0000 (+0000) Subject: UI for pop up label and modified the getLabels functionality for Annotation combo... X-Git-Url: http://gitweb.planteome.org/?a=commitdiff_plain;h=eb8694ab4c74a401cc6e6c33fadf72d27b281576;p=old-jaiswallab-svn%2F.git UI for pop up label and modified the getLabels functionality for Annotation combo box. Done by Nikhil. svn path=/; revision=244 --- diff --git a/Annotation/src/ie/dcu/apps/ist/dialogs/PopUpLabelDialog.java b/Annotation/src/ie/dcu/apps/ist/dialogs/PopUpLabelDialog.java index d3d62f2..0e7d3b9 100644 --- a/Annotation/src/ie/dcu/apps/ist/dialogs/PopUpLabelDialog.java +++ b/Annotation/src/ie/dcu/apps/ist/dialogs/PopUpLabelDialog.java @@ -6,22 +6,24 @@ import ie.dcu.swt.layout.LayoutFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Dialog; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; public class PopUpLabelDialog extends Dialog { public class Result { - public final String html; public final String image; Result() { - html = htmlText.getText().trim(); image = imageText.getText().trim(); } }; @@ -36,8 +38,10 @@ public class PopUpLabelDialog extends Dialog { private Composite buttons; // Widgets - private Text htmlText; + private Combo labelCombo; + private Text curator; private Text imageText; + // Dialog buttons private Button cancelButton; private Button assignButton; @@ -78,9 +82,8 @@ public class PopUpLabelDialog extends Dialog { } private void createUI() { - // Overall layout content = new Composite(shell, 0); - content.setLayout(LayoutFactory.createGridLayout(0, 0, 2, false)); + content.setLayout(LayoutFactory.createGridLayout(0, 0, 1, false)); widgets = new Composite(content, 0); widgets.setLayout(LayoutFactory.createGridLayout(10, 5, 3, false)); widgets.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); @@ -88,13 +91,16 @@ public class PopUpLabelDialog extends Dialog { buttons = new Composite(content, 0); buttons.setLayout(LayoutFactory.createGridLayout(10, 5, 3, false)); buttons.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - // Form content - label(widgets, "HTML file name:"); - htmlText = text(widgets, "imagemap.html"); + label(widgets, "Annotate"); + labelCombo = combo(widgets); + spacer(widgets); + + label(widgets, "Curator"); + curator = text(widgets,"Enter your name"); spacer(widgets); hline(widgets); - + // Button bar expander(buttons); cancelButton = new Button(buttons, SWT.PUSH); @@ -108,6 +114,24 @@ public class PopUpLabelDialog extends Dialog { shell.setDefaultButton(assignButton); // Add listeners + addListeners(); + } + + private void addListeners() { + + cancelButton.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + result = null; + shell.dispose(); + } + }); + + assignButton.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + result = new Result(); + shell.dispose(); + } + }); } private Label hline(Composite parent) { @@ -121,7 +145,7 @@ public class PopUpLabelDialog extends Dialog { private Label spacer(Composite parent) { Label label = new Label(parent, SWT.NONE); - label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + label.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); return label; } @@ -145,6 +169,12 @@ public class PopUpLabelDialog extends Dialog { return text; } + private Combo combo(Composite parent) { + Combo combo = new Combo(parent, SWT.BORDER | SWT.DROP_DOWN); + combo.setLayoutData(layout2()); + return combo; + } + private GridData layout1() { return new GridData(SWT.LEFT, SWT.CENTER, false, false); } diff --git a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java index 208c127..5594e89 100644 --- a/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java +++ b/Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java @@ -15,6 +15,7 @@ import ie.dcu.apps.ist.dialogs.PopUpLabelDialog; import java.lang.reflect.InvocationTargetException; import java.net.*; +import java.util.ArrayList; import java.util.Properties; import java.util.logging.*; import java.awt.image.BufferedImage; @@ -215,6 +216,7 @@ public class SegmentationView extends Composite { comboLabel.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent e) { + ArrayList listElements = new ArrayList(); /* * For the down arrow functionality */ @@ -224,10 +226,19 @@ public class SegmentationView extends Composite { } else if (!(e.keyCode == 13)) { + if(listElements != null) + { + listElements = null; + } comboLabel.setListVisible(false); - setLabel(comboLabel.getText()); + listElements = getLabels(comboLabel.getText()); + assign.setEnabled(!(comboLabel.getText().isEmpty())); + + } + for (int i=0; i getLabels(String content) { + ArrayList labels = new ArrayList(); try { comboLabel.remove(0,comboLabel.getItemCount()-1); @@ -859,6 +871,9 @@ public class SegmentationView extends Composite { 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())); + /* + * if the response is 'OK' + */ if(connection.getResponseCode() == 200) { String inputLine; @@ -872,8 +887,7 @@ public class SegmentationView extends Composite { for(int i=0; i0) - { - comboLabel.setText(comboLabel.getItem(0)); - }*/ - assign.setEnabled(!(comboLabel.getText().isEmpty())); + return labels; } private void apply() { @@ -1067,7 +1077,6 @@ public class SegmentationView extends Composite { // Setup exporter Exporter exporter = new Exporter(image, mask); - exporter.setHtmlFile(result.html); exporter.setImageFile(result.image); String label = SegmentationView.comboLabel.getText(); if(label.indexOf('{') != -1)