JAL-2047 resolved structure chooser's displayed column configuration updating, added...
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 14 Jun 2016 10:17:44 +0000 (11:17 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 14 Jun 2016 10:17:44 +0000 (11:17 +0100)
src/jalview/fts/api/FTSRestClientI.java
src/jalview/fts/core/FTSDataColumnPreferences.java
src/jalview/fts/core/FTSRestClient.java
src/jalview/fts/core/GFTSPanel.java
src/jalview/fts/service/pdb/PDBFTSPanel.java
src/jalview/fts/service/pdb/PDBFTSRestClient.java
src/jalview/fts/service/uniprot/UniprotFTSPanel.java
src/jalview/gui/StructureChooser.java
src/jalview/jbgui/GStructureChooser.java
test/jalview/fts/core/FTSRestClientTest.java

index 2266ca0..3701c76 100644 (file)
@@ -115,7 +115,7 @@ public interface FTSRestClientI
    * 
    * @return list of columns to display by default
    */
-  public Collection<FTSDataColumnI> getAllDefaulDisplayedDataColumns();
+  public Collection<FTSDataColumnI> getAllDefaultDisplayedFTSDataColumns();
 
   /**
    * Return list of FTSDataColumnI objects that can be used to perform a search
index cddcc8e..1e38260 100644 (file)
@@ -23,6 +23,7 @@ package jalview.fts.core;
 import jalview.fts.api.FTSDataColumnI;
 import jalview.fts.api.FTSDataColumnI.FTSDataColumnGroupI;
 import jalview.fts.api.FTSRestClientI;
+import jalview.fts.service.pdb.PDBFTSRestClient;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -67,11 +68,8 @@ public class FTSDataColumnPreferences extends JScrollPane
           FTSRestClientI ftsRestClient)
   {
     this.ftsRestClient = ftsRestClient;
-    Collection<FTSDataColumnI> defaultCols = ftsRestClient
-            .getAllDefaulDisplayedDataColumns();
-
-    structSummaryColumns.addAll(defaultCols);
-
+    structSummaryColumns = ((PDBFTSRestClient) ftsRestClient)
+            .getAllDefaultDisplayedStructureDataColumns();
     allFTSDataColumns.addAll(ftsRestClient.getAllFTSDataColumns());
 
     tbl_FTSDataColumnPrefs.setAutoCreateRowSorter(true);
@@ -109,7 +107,7 @@ public class FTSDataColumnPreferences extends JScrollPane
       {
       case SEARCH_SUMMARY:
         data[x++] = new Object[] {
-            ftsRestClient.getAllDefaulDisplayedDataColumns()
+            ftsRestClient.getAllDefaultDisplayedFTSDataColumns()
                     .contains(field),
             field.getName(), field.getGroup() };
         break;
@@ -119,7 +117,7 @@ public class FTSDataColumnPreferences extends JScrollPane
         break;
       case PREFERENCES:
         data[x++] = new Object[] { field.getName(),
-            ftsRestClient.getAllDefaulDisplayedDataColumns()
+            ftsRestClient.getAllDefaultDisplayedFTSDataColumns()
                     .contains(field),
             structSummaryColumns.contains(field) };
         break;
@@ -300,7 +298,7 @@ public class FTSDataColumnPreferences extends JScrollPane
       if (currentSource == PreferenceSource.SEARCH_SUMMARY)
       {
         updatePrefs(ftsRestClient
-                .getAllDefaulDisplayedDataColumns(), ftsDataColumn,
+                .getAllDefaultDisplayedFTSDataColumns(), ftsDataColumn,
                 selected);
       }
       else if (currentSource == PreferenceSource.STRUCTURE_CHOOSER)
@@ -312,7 +310,7 @@ public class FTSDataColumnPreferences extends JScrollPane
         if (col == 1)
         {
           updatePrefs(ftsRestClient
-                  .getAllDefaulDisplayedDataColumns(), ftsDataColumn,
+                  .getAllDefaultDisplayedFTSDataColumns(), ftsDataColumn,
                   selected);
         }
         else if (col == 2)
index f2df461..00a081b 100644 (file)
@@ -367,7 +367,7 @@ public abstract class FTSRestClient implements FTSRestClientI
   }
 
   @Override
-  public Collection<FTSDataColumnI> getAllDefaulDisplayedDataColumns()
+  public Collection<FTSDataColumnI> getAllDefaultDisplayedFTSDataColumns()
   {
     if (defaulDisplayedDataColumns == null
             || defaulDisplayedDataColumns.isEmpty())
index ee71407..b288aa5 100644 (file)
@@ -548,7 +548,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
           txt_search.setEnabled(false);
           cmb_searchTarget.setEnabled(false);
           previousWantedFields = getFTSRestClient()
-                  .getAllDefaulDisplayedDataColumns()
+                  .getAllDefaultDisplayedFTSDataColumns()
                   .toArray(new Object[0]);
         }
         if (sourceTabbedPane.getTitleAt(index).equals(searchTabTitle))
@@ -648,7 +648,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI
     }
 
     return Arrays.equals(getFTSRestClient()
-            .getAllDefaulDisplayedDataColumns()
+            .getAllDefaultDisplayedFTSDataColumns()
             .toArray(new Object[0]), previousWantedFields) ? false
             : true;
 
index 0dd1369..32c171e 100644 (file)
@@ -71,7 +71,7 @@ public class PDBFTSPanel extends GFTSPanel
           String searchTarget = ((FTSDataColumnI) cmb_searchTarget
                   .getSelectedItem()).getCode();
           wantedFields = PDBFTSRestClient.getInstance()
-                  .getAllDefaulDisplayedDataColumns();
+                  .getAllDefaultDisplayedFTSDataColumns();
           String searchTerm = decodeSearchTerm(txt_search.getText(),
                   searchTarget);
 
index 93a7df3..219d6d6 100644 (file)
@@ -414,4 +414,18 @@ public class PDBFTSRestClient extends FTSRestClient
     }
     return instance;
   }
+
+  private Collection<FTSDataColumnI> allDefaultDisplayedStructureDataColumns;
+
+  public Collection<FTSDataColumnI> getAllDefaultDisplayedStructureDataColumns()
+  {
+    if (allDefaultDisplayedStructureDataColumns == null
+            || allDefaultDisplayedStructureDataColumns.isEmpty())
+    {
+      allDefaultDisplayedStructureDataColumns = new ArrayList<FTSDataColumnI>();
+      allDefaultDisplayedStructureDataColumns.addAll(super
+              .getAllDefaultDisplayedFTSDataColumns());
+    }
+    return allDefaultDisplayedStructureDataColumns;
+  }
 }
index f2fcb76..b1aa5f1 100644 (file)
@@ -74,7 +74,7 @@ public class UniprotFTSPanel extends GFTSPanel
                   .getSelectedItem()).getAltCode();
 
           wantedFields = UniProtFTSRestClient.getInstance()
-                  .getAllDefaulDisplayedDataColumns();
+                  .getAllDefaultDisplayedFTSDataColumns();
           String searchTerm = decodeSearchTerm(txt_search.getText(),
                   searchTarget);
 
index 2972c69..426f092 100644 (file)
@@ -148,8 +148,8 @@ public class StructureChooser extends GStructureChooser implements
   {
     long startTime = System.currentTimeMillis();
     pdbRestCleint = PDBFTSRestClient.getInstance();
-    Collection<FTSDataColumnI> wantedFields = pdbRestCleint
-            .getAllDefaulDisplayedDataColumns();
+    Collection<FTSDataColumnI> wantedFields = pdbDocFieldPrefs
+            .getStructureSummaryFields();
 
     discoveredStructuresSet = new LinkedHashSet<FTSData>();
     HashSet<String> errors = new HashSet<String>();
@@ -186,7 +186,8 @@ public class StructureChooser extends GStructureChooser implements
     if (discoveredStructuresSet != null
             && !discoveredStructuresSet.isEmpty())
     {
-      tbl_summary.setModel(FTSRestResponse.getTableModel(lastPdbRequest,
+      getResultTable().setModel(
+              FTSRestResponse.getTableModel(lastPdbRequest,
               discoveredStructuresSet));
       structuresDiscovered = true;
       noOfStructuresFound = discoveredStructuresSet.size();
@@ -397,8 +398,8 @@ public class StructureChooser extends GStructureChooser implements
         long startTime = System.currentTimeMillis();
         pdbRestCleint = PDBFTSRestClient.getInstance();
         lbl_loading.setVisible(true);
-        Collection<FTSDataColumnI> wantedFields = pdbRestCleint
-                .getAllDefaulDisplayedDataColumns();
+        Collection<FTSDataColumnI> wantedFields = pdbDocFieldPrefs
+                .getStructureSummaryFields();
         Collection<FTSData> filteredResponse = new HashSet<FTSData>();
         HashSet<String> errors = new HashSet<String>();
 
@@ -454,15 +455,18 @@ public class StructureChooser extends GStructureChooser implements
           Collection<FTSData> reorderedStructuresSet = new LinkedHashSet<FTSData>();
           reorderedStructuresSet.addAll(filteredResponse);
           reorderedStructuresSet.addAll(discoveredStructuresSet);
-          tbl_summary.setModel(FTSRestResponse.getTableModel(
+          getResultTable().setModel(
+                  FTSRestResponse.getTableModel(
                   lastPdbRequest, reorderedStructuresSet));
 
-          FTSRestResponse.configureTableColumn(tbl_summary, wantedFields);
-          tbl_summary.getColumn("Ref Sequence").setPreferredWidth(120);
-          tbl_summary.getColumn("Ref Sequence").setMinWidth(100);
-          tbl_summary.getColumn("Ref Sequence").setMaxWidth(200);
+          FTSRestResponse.configureTableColumn(getResultTable(),
+                  wantedFields);
+          getResultTable().getColumn("Ref Sequence").setPreferredWidth(120);
+          getResultTable().getColumn("Ref Sequence").setMinWidth(100);
+          getResultTable().getColumn("Ref Sequence").setMaxWidth(200);
           // Update table selection model here
-          tbl_summary.addRowSelectionInterval(0, filterResponseCount - 1);
+          getResultTable().addRowSelectionInterval(0,
+                  filterResponseCount - 1);
           mainFrame.setTitle(MessageManager.formatMessage(
                   "label.structure_chooser_filter_time", totalTime));
         }
@@ -591,7 +595,7 @@ public class StructureChooser extends GStructureChooser implements
     String currentView = selectedFilterOpt.getView();
     if (currentView == VIEWS_FILTER)
     {
-      if (tbl_summary.getSelectedRows().length > 0)
+      if (getResultTable().getSelectedRows().length > 0)
       {
         btn_view.setEnabled(true);
       }
@@ -729,19 +733,21 @@ public class StructureChooser extends GStructureChooser implements
     String currentView = selectedFilterOpt.getView();
     if (currentView == VIEWS_FILTER)
     {
-          int pdbIdColIndex = tbl_summary.getColumn("PDB Id")
+          int pdbIdColIndex = getResultTable().getColumn("PDB Id")
                   .getModelIndex();
-          int refSeqColIndex = tbl_summary.getColumn("Ref Sequence")
+          int refSeqColIndex = getResultTable().getColumn("Ref Sequence")
               .getModelIndex();
-          int[] selectedRows = tbl_summary.getSelectedRows();
+          int[] selectedRows = getResultTable().getSelectedRows();
       PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
       int count = 0;
       ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
       for (int row : selectedRows)
       {
-            String pdbIdStr = tbl_summary.getValueAt(row, pdbIdColIndex)
+            String pdbIdStr = getResultTable().getValueAt(row,
+                    pdbIdColIndex)
                 .toString();
-            SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(row,
+            SequenceI selectedSeq = (SequenceI) getResultTable()
+                    .getValueAt(row,
                 refSeqColIndex);
         selectedSeqsToView.add(selectedSeq);
             PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr);
@@ -962,7 +968,7 @@ public class StructureChooser extends GStructureChooser implements
         {
           String searchTerm = txt_search.getText().toLowerCase();
           searchTerm = searchTerm.split(":")[0];
-          System.out.println(">>>>> search term : " + searchTerm);
+          // System.out.println(">>>>> search term : " + searchTerm);
           List<FTSDataColumnI> wantedFields = new ArrayList<FTSDataColumnI>();
           FTSRestRequest pdbRequest = new FTSRestRequest();
           pdbRequest.setAllowEmptySeq(false);
index a1aa0d3..e9eab82 100644 (file)
@@ -165,13 +165,13 @@ public abstract class GStructureChooser extends JPanel implements
 
   private JTabbedPane pnl_filter = new JTabbedPane();
 
-  private FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences(
+  protected FTSDataColumnPreferences pdbDocFieldPrefs = new FTSDataColumnPreferences(
           PreferenceSource.STRUCTURE_CHOOSER,
           PDBFTSRestClient.getInstance());
 
   protected FTSDataColumnI[] previousWantedFields;
 
-  protected JTable tbl_summary = new JTable()
+  private JTable tbl_summary = new JTable()
   {
     private boolean inLayout;
 
@@ -440,11 +440,9 @@ public abstract class GStructureChooser extends JPanel implements
       }
     });
 
-    scrl_foundStructures.setPreferredSize(new Dimension(500, 300));
-    scrl_foundStructures
-            .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+    scrl_foundStructures.setPreferredSize(new Dimension(800, 400));
 
-    scrl_localPDB.setPreferredSize(new Dimension(500, 300));
+    scrl_localPDB.setPreferredSize(new Dimension(800, 400));
     scrl_localPDB
             .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
 
@@ -521,9 +519,9 @@ public abstract class GStructureChooser extends JPanel implements
           btn_cancel.setEnabled(false);
           btn_view.setVisible(false);
           btn_cancel.setVisible(false);
-          previousWantedFields = PDBFTSRestClient.getInstance()
-                  .getAllDefaulDisplayedDataColumns()
-                  .toArray(new FTSDataColumnI[0]);
+          previousWantedFields = pdbDocFieldPrefs
+                  .getStructureSummaryFields().toArray(
+                          new FTSDataColumnI[0]);
         }
         if (sourceTabbedPane.getTitleAt(index)
                 .equals(foundStructureSummary))
@@ -541,7 +539,7 @@ public abstract class GStructureChooser extends JPanel implements
       }
     };
     pnl_filter.addChangeListener(changeListener);
-    pnl_filter.setPreferredSize(new Dimension(500, 300));
+    pnl_filter.setPreferredSize(new Dimension(800, 400));
     pnl_filter.add(foundStructureSummary, scrl_foundStructures);
     pnl_filter.add(configureCols, pdbDocFieldPrefs);
 
@@ -565,7 +563,7 @@ public abstract class GStructureChooser extends JPanel implements
     mainFrame.setVisible(true);
     mainFrame.setContentPane(this);
     mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
-    Desktop.addInternalFrame(mainFrame, frameTitle, 800, 400);
+    Desktop.addInternalFrame(mainFrame, frameTitle, 900, 500);
   }
 
   public boolean wantedFieldsUpdated()
@@ -574,12 +572,12 @@ public abstract class GStructureChooser extends JPanel implements
     {
       return true;
     }
-
-    return Arrays.equals(
-            PDBFTSRestClient.getInstance()
-                    .getAllDefaulDisplayedDataColumns()
-            .toArray(new FTSDataColumnI[0]),
-            previousWantedFields) ? false : true;
+    
+    FTSDataColumnI[] currentWantedFields = pdbDocFieldPrefs
+            .getStructureSummaryFields()
+            .toArray(new FTSDataColumnI[0]);
+    return Arrays.equals(currentWantedFields, previousWantedFields) ? false
+            : true;
 
   }
 
@@ -753,6 +751,10 @@ public abstract class GStructureChooser extends JPanel implements
     }
   }
 
+  public JTable getResultTable()
+  {
+    return tbl_summary;
+  }
   public JComboBox<FilterOption> getCmbFilterOption()
   {
     return cmb_filterOption;
index ddf60bc..5ceb5cd 100644 (file)
@@ -40,7 +40,7 @@ public class FTSRestClientTest
   public void getPrimaryKeyColumIndexTest()
   {
     Collection<FTSDataColumnI> wantedFields = ftsRestClient
-            .getAllDefaulDisplayedDataColumns();
+            .getAllDefaultDisplayedFTSDataColumns();
     int foundIndex = -1;
     try
     {
@@ -61,10 +61,10 @@ public class FTSRestClientTest
   @Test(groups = { "Functional" })
   public void getAllDefaulDisplayedDataColumns()
   {
-    Assert.assertNotNull(ftsRestClient.getAllDefaulDisplayedDataColumns());
-    Assert.assertTrue(!ftsRestClient.getAllDefaulDisplayedDataColumns()
+    Assert.assertNotNull(ftsRestClient.getAllDefaultDisplayedFTSDataColumns());
+    Assert.assertTrue(!ftsRestClient.getAllDefaultDisplayedFTSDataColumns()
             .isEmpty());
-    Assert.assertEquals(ftsRestClient.getAllDefaulDisplayedDataColumns()
+    Assert.assertEquals(ftsRestClient.getAllDefaultDisplayedFTSDataColumns()
             .size(), 7);
   }
 
@@ -72,7 +72,7 @@ public class FTSRestClientTest
   public void getDataColumnsFieldsAsCommaDelimitedString()
   {
     Collection<FTSDataColumnI> wantedFields = ftsRestClient
-            .getAllDefaulDisplayedDataColumns();
+            .getAllDefaultDisplayedFTSDataColumns();
     String actual = ftsRestClient
             .getDataColumnsFieldsAsCommaDelimitedString(wantedFields);
     Assert.assertEquals(actual,