Hello!

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

Note that updates take place every 10 minutes, commits may not be seen immediately.
UI for pop up label and modified the getLabels functionality for Annotation combo...
authorlingutln <lingutln@localhost>
Thu, 29 Dec 2011 22:58:48 +0000 (22:58 +0000)
committerlingutln <lingutln@localhost>
Thu, 29 Dec 2011 22:58:48 +0000 (22:58 +0000)
svn path=/; revision=244

Annotation/src/ie/dcu/apps/ist/dialogs/PopUpLabelDialog.java
Annotation/src/ie/dcu/apps/ist/views/SegmentationView.java

index d3d62f268e24cf4397da51347cbd3323c7982781..0e7d3b9e46cf2d67ce841011e61fcfd1ab6cbe91 100644 (file)
@@ -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);
        }
index 208c127660b8130c93ec3e10eb4150cb0d379f72..5594e8925a426fe4b0f6b52ebd4b623497d81815 100644 (file)
@@ -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<String> listElements = new ArrayList<String>();
                                /*
                                 * 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<listElements.size();i++)
+                               {
+                                       comboLabel.add(listElements.get(i),i);
                                }
-                               //comboLabel.setSelection(arg0);
                        }
                        @Override
                        public void keyPressed(KeyEvent arg0) {
@@ -851,7 +862,8 @@ public class SegmentationView extends Composite {
                setPainter(painter);
        }
        
-       private void setLabel(String content) {
+       private ArrayList<String> getLabels(String content) {
+               ArrayList<String> labels = new ArrayList<String>();
                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; i<array.length();i++)
                        {
                                listElement = (array.getJSONObject(i).getString("match")+" {"+array.getJSONObject(i).getString("accession_id")+"}");
-                               listElement = StringEscapeUtils.unescapeHtml4(listElement);
-                               comboLabel.add(listElement,i);
+                               labels.add(i,StringEscapeUtils.unescapeHtml4(listElement));
                        }
                        in.close();
                }
@@ -885,11 +899,7 @@ public class SegmentationView extends Composite {
            catch(Exception ex)
            {
            }
-           /*if(comboLabel.getText().equals(null) && comboLabel.getItemCount()>0)
-           {
-               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)