JAL-2028 added improvement for preconfigured ordering of custom display options
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Mon, 21 Mar 2016 14:34:34 +0000 (14:34 +0000)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Mon, 21 Mar 2016 14:34:34 +0000 (14:34 +0000)
src/jalview/gui/PDBSearchPanel.java
src/jalview/jbgui/PDBDocFieldPreferences.java
src/jalview/ws/dbsources/PDBRestClient.java

index cef9ddd..a228c67 100644 (file)
@@ -62,6 +62,7 @@ public class PDBSearchPanel extends GPDBSearchPanel
   {
     new Thread()
     {
+      @Override
       public void run()
       {
         lbl_loading.setVisible(false);
@@ -109,6 +110,9 @@ public class PDBSearchPanel extends GPDBSearchPanel
           {
             tbl_summary.setModel(PDBRestResponse.getTableModel(request,
                     resultList.getSearchSummary()));
+            // request.ge
+            // TableRowSorter<TableModel> sorter = new TableRowSorter<>(
+            // tbl_pdbDocFieldConfig.getModel());
           }
 
           long endTime = System.currentTimeMillis();
@@ -179,6 +183,7 @@ public class PDBSearchPanel extends GPDBSearchPanel
     mainFrame.dispose();
   }
 
+  @Override
   public void transferToSequenceFetcher(String ids)
   {
     // mainFrame.dispose();
@@ -231,6 +236,7 @@ public class PDBSearchPanel extends GPDBSearchPanel
   {
     new Thread()
     {
+      @Override
       public void run()
       {
         try
@@ -276,6 +282,7 @@ public class PDBSearchPanel extends GPDBSearchPanel
   /**
    * Populates search target combo-box options
    */
+  @Override
   public void populateCmbSearchTargetOptions()
   {
     List<PDBDocField> searchableTargets = new ArrayList<PDBDocField>();
index 875eb2e..da67196 100644 (file)
 package jalview.jbgui;
 
 import jalview.ws.dbsources.PDBRestClient.PDBDocField;
+import jalview.ws.dbsources.PDBRestClient.PDBDocField.Group;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -36,6 +38,7 @@ import javax.swing.table.AbstractTableModel;
 import javax.swing.table.TableModel;
 import javax.swing.table.TableRowSorter;
 
+
 @SuppressWarnings("serial")
 public class PDBDocFieldPreferences extends JScrollPane
 {
@@ -82,7 +85,7 @@ public class PDBDocFieldPreferences extends JScrollPane
       columnNames = new String[] { "", "Display", "Group" };
       break;
     case STRUCTURE_CHOOSER:
-      columnNames = new String[] { " ", "Display", "Group" };
+      columnNames = new String[] { "", "Display", "Group" };
       break;
     case PREFERENCES:
       columnNames = new String[] { "PDB Field", "Show in search summary",
@@ -148,6 +151,16 @@ public class PDBDocFieldPreferences extends JScrollPane
       sortKeys.add(new RowSorter.SortKey(columnIndexToSort,
               SortOrder.ASCENDING));
       sorter.setSortKeys(sortKeys);
+      sorter.setComparator(
+              columnIndexToSort,
+              new Comparator<jalview.ws.dbsources.PDBRestClient.PDBDocField.Group>()
+              {
+                @Override
+                public int compare(Group o1, Group o2)
+                {
+                  return o1.getSortOrder() - o2.getSortOrder();
+                }
+              });
       sorter.sort();
       break;
     case PREFERENCES:
index ebe18f7..59cbe67 100644 (file)
@@ -492,24 +492,38 @@ public class PDBRestClient
             "Version", "_version_", Group.MISCELLENOUS), ALL("ALL", "text",
             Group.MISCELLENOUS);
 
-    private enum Group
+    public enum Group
     {
-      DATE_OF("Date Of"), NAMES_AND_TAXONOMY("Names & Taxonomy"), MISCELLENOUS(
-              "Miscellenous"), QUALITY_MEASURES("Quality Measures"), CROSS_REFS(
-              "Cross References"), PROCEDURE_AND_SOFTWARE(
-              "Procedures & Softwares");
+      DATE_OF("Date Of", 5), NAMES_AND_TAXONOMY("Names & Taxonomy", 3),
+      MISCELLENOUS("Miscellenous", 6), QUALITY_MEASURES("Quality Measures",
+              1), CROSS_REFS("Cross References", 2),
+      PROCEDURE_AND_SOFTWARE("Procedures & Softwares", 4);
 
-      Group(String name)
+      Group(String name, int sortOrder)
       {
         this.name = name;
+        this.sortOrder = sortOrder;
       }
 
       private String name;
 
+      private int sortOrder;
+
       public String getName()
       {
         return this.name;
       }
+
+      public int getSortOrder()
+      {
+        return sortOrder;
+      }
+
+      @Override
+      public String toString()
+      {
+        return this.name;
+      }
     };
     private String name;
 
@@ -534,9 +548,9 @@ public class PDBRestClient
       return code;
     }
 
-    public String getGroup()
+    public Group getGroup()
     {
-      return group.getName();
+      return group;
     }
 
     @Override