From 2051c117e19e8b7c72bf5a9f1db48f2b4687f71e Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Tue, 14 Jun 2016 11:17:44 +0100 Subject: [PATCH] JAL-2047 resolved structure chooser's displayed column configuration updating, added horizontal scrollbar to structure chooser summary table and minor house keeping --- src/jalview/fts/api/FTSRestClientI.java | 2 +- src/jalview/fts/core/FTSDataColumnPreferences.java | 16 ++++---- src/jalview/fts/core/FTSRestClient.java | 2 +- src/jalview/fts/core/GFTSPanel.java | 4 +- src/jalview/fts/service/pdb/PDBFTSPanel.java | 2 +- src/jalview/fts/service/pdb/PDBFTSRestClient.java | 14 +++++++ .../fts/service/uniprot/UniprotFTSPanel.java | 2 +- src/jalview/gui/StructureChooser.java | 42 +++++++++++--------- src/jalview/jbgui/GStructureChooser.java | 36 +++++++++-------- test/jalview/fts/core/FTSRestClientTest.java | 10 ++--- 10 files changed, 75 insertions(+), 55 deletions(-) diff --git a/src/jalview/fts/api/FTSRestClientI.java b/src/jalview/fts/api/FTSRestClientI.java index 2266ca0..3701c76 100644 --- a/src/jalview/fts/api/FTSRestClientI.java +++ b/src/jalview/fts/api/FTSRestClientI.java @@ -115,7 +115,7 @@ public interface FTSRestClientI * * @return list of columns to display by default */ - public Collection getAllDefaulDisplayedDataColumns(); + public Collection getAllDefaultDisplayedFTSDataColumns(); /** * Return list of FTSDataColumnI objects that can be used to perform a search diff --git a/src/jalview/fts/core/FTSDataColumnPreferences.java b/src/jalview/fts/core/FTSDataColumnPreferences.java index cddcc8e..1e38260 100644 --- a/src/jalview/fts/core/FTSDataColumnPreferences.java +++ b/src/jalview/fts/core/FTSDataColumnPreferences.java @@ -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 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) diff --git a/src/jalview/fts/core/FTSRestClient.java b/src/jalview/fts/core/FTSRestClient.java index f2df461..00a081b 100644 --- a/src/jalview/fts/core/FTSRestClient.java +++ b/src/jalview/fts/core/FTSRestClient.java @@ -367,7 +367,7 @@ public abstract class FTSRestClient implements FTSRestClientI } @Override - public Collection getAllDefaulDisplayedDataColumns() + public Collection getAllDefaultDisplayedFTSDataColumns() { if (defaulDisplayedDataColumns == null || defaulDisplayedDataColumns.isEmpty()) diff --git a/src/jalview/fts/core/GFTSPanel.java b/src/jalview/fts/core/GFTSPanel.java index ee71407..b288aa5 100644 --- a/src/jalview/fts/core/GFTSPanel.java +++ b/src/jalview/fts/core/GFTSPanel.java @@ -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; diff --git a/src/jalview/fts/service/pdb/PDBFTSPanel.java b/src/jalview/fts/service/pdb/PDBFTSPanel.java index 0dd1369..32c171e 100644 --- a/src/jalview/fts/service/pdb/PDBFTSPanel.java +++ b/src/jalview/fts/service/pdb/PDBFTSPanel.java @@ -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); diff --git a/src/jalview/fts/service/pdb/PDBFTSRestClient.java b/src/jalview/fts/service/pdb/PDBFTSRestClient.java index 93a7df3..219d6d6 100644 --- a/src/jalview/fts/service/pdb/PDBFTSRestClient.java +++ b/src/jalview/fts/service/pdb/PDBFTSRestClient.java @@ -414,4 +414,18 @@ public class PDBFTSRestClient extends FTSRestClient } return instance; } + + private Collection allDefaultDisplayedStructureDataColumns; + + public Collection getAllDefaultDisplayedStructureDataColumns() + { + if (allDefaultDisplayedStructureDataColumns == null + || allDefaultDisplayedStructureDataColumns.isEmpty()) + { + allDefaultDisplayedStructureDataColumns = new ArrayList(); + allDefaultDisplayedStructureDataColumns.addAll(super + .getAllDefaultDisplayedFTSDataColumns()); + } + return allDefaultDisplayedStructureDataColumns; + } } diff --git a/src/jalview/fts/service/uniprot/UniprotFTSPanel.java b/src/jalview/fts/service/uniprot/UniprotFTSPanel.java index f2fcb76..b1aa5f1 100644 --- a/src/jalview/fts/service/uniprot/UniprotFTSPanel.java +++ b/src/jalview/fts/service/uniprot/UniprotFTSPanel.java @@ -74,7 +74,7 @@ public class UniprotFTSPanel extends GFTSPanel .getSelectedItem()).getAltCode(); wantedFields = UniProtFTSRestClient.getInstance() - .getAllDefaulDisplayedDataColumns(); + .getAllDefaultDisplayedFTSDataColumns(); String searchTerm = decodeSearchTerm(txt_search.getText(), searchTarget); diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 2972c69..426f092 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -148,8 +148,8 @@ public class StructureChooser extends GStructureChooser implements { long startTime = System.currentTimeMillis(); pdbRestCleint = PDBFTSRestClient.getInstance(); - Collection wantedFields = pdbRestCleint - .getAllDefaulDisplayedDataColumns(); + Collection wantedFields = pdbDocFieldPrefs + .getStructureSummaryFields(); discoveredStructuresSet = new LinkedHashSet(); HashSet errors = new HashSet(); @@ -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 wantedFields = pdbRestCleint - .getAllDefaulDisplayedDataColumns(); + Collection wantedFields = pdbDocFieldPrefs + .getStructureSummaryFields(); Collection filteredResponse = new HashSet(); HashSet errors = new HashSet(); @@ -454,15 +455,18 @@ public class StructureChooser extends GStructureChooser implements Collection reorderedStructuresSet = new LinkedHashSet(); 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 selectedSeqsToView = new ArrayList(); 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 wantedFields = new ArrayList(); FTSRestRequest pdbRequest = new FTSRestRequest(); pdbRequest.setAllowEmptySeq(false); diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index a1aa0d3..e9eab82 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -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 getCmbFilterOption() { return cmb_filterOption; diff --git a/test/jalview/fts/core/FTSRestClientTest.java b/test/jalview/fts/core/FTSRestClientTest.java index ddf60bc..5ceb5cd 100644 --- a/test/jalview/fts/core/FTSRestClientTest.java +++ b/test/jalview/fts/core/FTSRestClientTest.java @@ -40,7 +40,7 @@ public class FTSRestClientTest public void getPrimaryKeyColumIndexTest() { Collection 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 wantedFields = ftsRestClient - .getAllDefaulDisplayedDataColumns(); + .getAllDefaultDisplayedFTSDataColumns(); String actual = ftsRestClient .getDataColumnsFieldsAsCommaDelimitedString(wantedFields); Assert.assertEquals(actual, -- 1.7.10.2