Hello!

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

Note that updates take place every 10 minutes, commits may not be seen immediately.
Moved term detail synonyms to separate table; more debugging to to, alon with bolding...
authorpreecej <preecej@localhost>
Sat, 26 May 2012 00:09:53 +0000 (00:09 +0000)
committerpreecej <preecej@localhost>
Sat, 26 May 2012 00:09:53 +0000 (00:09 +0000)
svn path=/; revision=337

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

index b191cfe39df54f16b16db8b31dbddb3fe275692a..1b84b5516dea9bee515fcf302d771e4295decb86 100644 (file)
@@ -59,6 +59,12 @@ public class SegmentationView extends Composite {
        // term detail table
        private static Table termDetailTable;
 
+       // Composite for Term synonyms (nested in Term details table)
+       private Composite termSynonymComposite;
+       
+       // term synonym table (1-col list of nested synonyms)
+       private static Table termSynonymTable;
+
        // Control to change brush size
        private final BrushControl brushControl;
                
@@ -131,8 +137,8 @@ public class SegmentationView extends Composite {
                accession_id("Accession ID"),
                aspect("Branch") /* a.k.a. "Aspect" */, 
                definition("Definition"), 
-               comment("Comment"), 
-               synonyms("Synonyms");
+               comment("Comment")/*
+               synonyms("Synonyms")*/;
                final String extendedLabel;
                termDetailLabels(String extendedLabel) {
                        this.extendedLabel = extendedLabel;
@@ -170,6 +176,7 @@ public class SegmentationView extends Composite {
                createToolViewSelectionToolbar();
                createToolTermLookupBar();
                createTermDetailTable();
+               createTermSynonymTable();
                createTermDetailFields();
                
                // lay out the controls
@@ -335,6 +342,8 @@ public class SegmentationView extends Composite {
        */
        public static void termDetailLookup(String accessionId) {
                termDetailTable.setEnabled(true);
+               termSynonymTable.setEnabled(true);
+               termSynonymTable.clearAll();
 
                String webServiceURL = new String(); 
                try {
@@ -363,23 +372,36 @@ public class SegmentationView extends Composite {
                                for (termDetailLabels code : values) {
                                        String currResponseValue = responseArray.getJSONObject(0).getString(code.toString()); // assumes an array of one response
                                        if (items[i].getText(0).equals(code.extendedLabel)) {
-                                               if (code.extendedLabel.equals("Synonyms")) {
+                                               /*if (code.extendedLabel.equals("Synonyms")) {
                                                        String formattedSyns = new String();
+                                                       
                                                        JSONArray synArray = responseArray.getJSONObject(0).getJSONArray("synonyms");
                                                        for (int j=0; j<synArray.length(); j++) {
                                                                formattedSyns += synArray.getString(j) + System.getProperty("line.separator");
                                                        }
                                                        items[i].setText(1, formattedSyns);
-                                               } else {
+                                               } else {*/
                                                        items[i].setText(1, currResponseValue);
-                                               }
+                                               //}
                                        }
                                }
                                termDetailTable.getColumn(1).pack();
                                termDetailTable.pack();
                        }
+                               // populate termSynonymTable w/ synonyms
+                       JSONArray synArray = responseArray.getJSONObject(0).getJSONArray("synonyms");
+                       
+                               for (int j=0; j<synArray.length(); j++) {
+                               TableItem item = new TableItem (termSynonymTable, SWT.NONE);
+                                       item.setText(0,synArray.getString(j));
+                               }
+                       termSynonymTable.getColumn(0).pack();
+                               termSynonymTable.pack();
+                       
                        in.close();
                } else {
+                       termDetailTable.setEnabled(false);
+                       termSynonymTable.setEnabled(false);
                        throw new Exception("Bad HTTP response code: " + connection.getResponseCode());
                }
            }
@@ -390,6 +412,26 @@ public class SegmentationView extends Composite {
            }
        }
        
+       /**
+        * Set initial properties of the Term Synonyms inner composite
+        */
+       private void createTermSynonymTable() {
+               // Toolbar for holding detail fields
+               termSynonymTable = SwtUtils.addTable(termDetailComposite);
+               termSynonymTable.setLinesVisible (true);
+               termSynonymTable.setHeaderVisible (true);
+
+               TableColumn column = new TableColumn (termSynonymTable, SWT.BORDER_SOLID);
+               column.setText("Synonyms");
+
+               TableItem item = new TableItem (termSynonymTable, SWT.NONE);
+               item.setText(0,"");
+               termSynonymTable.getColumn(0).pack();
+
+               termSynonymTable.setEnabled(false);
+               termSynonymTable.pack();
+       }
+       
        /**
         * Set initial properties of the Term Detail right pane
         */
@@ -408,8 +450,8 @@ public class SegmentationView extends Composite {
                termDetailLabels[] values = termDetailLabels.values();
                for (termDetailLabels code : values) {
                        TableItem item = new TableItem (termDetailTable, SWT.NONE);
-                       item.setText (0, code.extendedLabel);
-                       item.setText (1,"");
+                       item.setText(0, code.extendedLabel);
+                       item.setText(1,"");
                }
                                
                for (int i=0; i<titles.length; i++) {
@@ -537,6 +579,21 @@ public class SegmentationView extends Composite {
                gd.widthHint = 70;
                termDetailTable.setLayoutData(gd);
 
+               /**/
+               
+               // Layout term synonym table                            
+               gd = new GridData();
+               gd.horizontalSpan = 2;
+               gd.grabExcessHorizontalSpace = true;
+               gd.grabExcessVerticalSpace = true;
+               gd.horizontalAlignment = SWT.FILL;
+               gd.verticalAlignment = GridData.BEGINNING;
+               gd.heightHint = 200;
+               gd.widthHint = 70;
+               termSynonymTable.setLayoutData(gd);
+               
+               /**/
+               
                // Layout species dropdown                              
                gd = new GridData();
                gd.widthHint = width/2;