From: tcofoegbu Date: Wed, 25 Mar 2015 09:39:53 +0000 (+0000) Subject: JAL-1668 Tab for summary config, auto refresh after config and table column sorting X-Git-Tag: Jalview_2_9~71^2~3 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5dc62d509b6d0f90f3545bf40b272390410eda45;p=jalview.git JAL-1668 Tab for summary config, auto refresh after config and table column sorting --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 3815cdf..317f043 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1204,4 +1204,7 @@ label.select = Select : label.invert = Invert label.select_pdb_file = Select PDB File info.select_filter_option = Select Filter Option/Manual Entry -info.associate_wit_sequence = Associate with Sequence \ No newline at end of file +info.associate_wit_sequence = Associate with Sequence +label.search_result = Search Result +label.found_structures_summary = Found Structures Summary +label.configure_displayed_columns = Configure Displayed Columns \ No newline at end of file diff --git a/src/jalview/gui/PDBSearchPanel.java b/src/jalview/gui/PDBSearchPanel.java index bb75413..2d46714 100644 --- a/src/jalview/gui/PDBSearchPanel.java +++ b/src/jalview/gui/PDBSearchPanel.java @@ -35,6 +35,8 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; +import javax.swing.table.DefaultTableModel; + @SuppressWarnings("serial") public class PDBSearchPanel extends GPDBSearchPanel { @@ -61,6 +63,7 @@ public class PDBSearchPanel extends GPDBSearchPanel boolean allowEmptySequence = false; mainFrame.setTitle(MessageManager .getString("label.pdb_sequence_getcher")); + tbl_summary.setModel(new DefaultTableModel()); if (txt_search.getText().trim().length() > 0) { long startTime = System.currentTimeMillis(); diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index f28ef68..35c5791 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -1,4 +1,5 @@ /* + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) * Copyright (C) 2014 The Jalview Authors * @@ -37,12 +38,13 @@ import java.awt.event.ItemEvent; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Vector; import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.ListSelectionModel; +import javax.swing.JLabel; /** * Provides the behaviors for the Structure chooser Panel @@ -61,9 +63,9 @@ public class StructureChooser extends GStructureChooser private IProgressIndicator progressIndicator; - private Collection discoveredStructuresSet = new HashSet(); + private Collection discoveredStructuresSet; - private PDBRestRequest pdbRequest; + private PDBRestRequest lastPdbRequest; private PDBRestClient pdbRestCleint; @@ -130,17 +132,19 @@ public class StructureChooser extends GStructureChooser Collection wantedFields = PDBDocFieldPreferences .getStructureSummaryFields(); - pdbRequest = new PDBRestRequest(); - pdbRequest.setAllowEmptySeq(false); - pdbRequest.setResponseSize(500); - pdbRequest.setFieldToSearchBy("(text:"); - pdbRequest.setWantedFields(wantedFields); + discoveredStructuresSet = new LinkedHashSet(); for (SequenceI seq : selectedSequences) { + PDBRestRequest pdbRequest = new PDBRestRequest(); + pdbRequest.setAllowEmptySeq(false); + pdbRequest.setResponseSize(500); + pdbRequest.setFieldToSearchBy("(text:"); + pdbRequest.setWantedFields(wantedFields); pdbRequest.setSearchTerm(buildQuery(seq) + ")"); pdbRequest.setAssociatedSequence(seq.getName()); pdbRestCleint = new PDBRestClient(); PDBRestResponse resultList = pdbRestCleint.executeRequest(pdbRequest); + lastPdbRequest = pdbRequest; if (resultList.getSearchSummary() != null && !resultList.getSearchSummary().isEmpty()) { @@ -153,7 +157,7 @@ public class StructureChooser extends GStructureChooser if (discoveredStructuresSet != null && !discoveredStructuresSet.isEmpty()) { - tbl_summary.setModel(PDBRestResponse.getTableModel(pdbRequest, + tbl_summary.setModel(PDBRestResponse.getTableModel(lastPdbRequest, discoveredStructuresSet)); structuresDiscovered = true; noOfStructuresFound = discoveredStructuresSet.size(); @@ -234,6 +238,84 @@ public class StructureChooser extends GStructureChooser */ public void filterResultSet(final String fieldToFilterBy) { + + // SwingWorker aWorker = new SwingWorker() + // { + // long startTime = System.currentTimeMillis(); + // + // @Override + // protected Object doInBackground() throws Exception + // { + // lbl_loading.setVisible(true); + // + // Collection wantedFields = PDBDocFieldPreferences + // .getStructureSummaryFields(); + // Collection filteredResponse = new + // HashSet(); + // for (SequenceI seq : selectedSequences) + // { + // PDBRestRequest pdbRequest = new PDBRestRequest(); + // pdbRequest.setAllowEmptySeq(false); + // pdbRequest.setResponseSize(1); + // pdbRequest.setFieldToSearchBy("(text:"); + // pdbRequest.setFieldToSortBy(fieldToFilterBy, + // !chk_invertFilter.isSelected()); + // pdbRequest.setSearchTerm(buildQuery(seq) + ")"); + // pdbRequest.setWantedFields(wantedFields); + // pdbRequest.setAssociatedSequence(seq.getName()); + // pdbRestCleint = new PDBRestClient(); + // PDBRestResponse resultList = pdbRestCleint + // .executeRequest(pdbRequest); + // lastPdbRequest = pdbRequest; + // if (resultList.getSearchSummary() != null + // && !resultList.getSearchSummary().isEmpty()) + // { + // filteredResponse.addAll(resultList.getSearchSummary()); + // } + // } + // + // if (!filteredResponse.isEmpty()) + // { + // final int filterResponseCount = filteredResponse.size(); + // Collection reorderedStructuresSet = new + // LinkedHashSet(); + // reorderedStructuresSet.addAll(filteredResponse); + // reorderedStructuresSet.addAll(discoveredStructuresSet); + // tbl_summary.setModel(PDBRestResponse.getTableModel( + // lastPdbRequest, reorderedStructuresSet)); + // + // // Update the model here + // // ListSelectionModel model = tbl_summary.getSelectionModel(); + // // model.clearSelection(); + // // model.addSelectionInterval(0, filterResponseCount - 1); + // // EventQueue.invokeLater(new Runnable() + // // { + // // public void run() + // // { + // // tbl_summary.addRowSelectionInterval(0, filterResponseCount - 1); + // + // // } + // // }); + // // Discard unwanted objects to make them eligible for garbage + // // collection + // reorderedStructuresSet = null; + // } + // return null; + // } + // + // public void done() + // { + // lbl_loading.setVisible(false); + // tbl_summary.addRowSelectionInterval(0, 2); + // String totalTime = (System.currentTimeMillis() - startTime) + // + " milli secs"; + // mainFrame.setTitle("Structure Chooser - Filter time (" + totalTime + // + ")"); + // validateSelections(); + // } + // }; + // aWorker.execute(); + Thread filterThread = new Thread(new Runnable() { @Override @@ -243,19 +325,25 @@ public class StructureChooser extends GStructureChooser try { lbl_loading.setVisible(true); - pdbRequest.setResponseSize(1); - pdbRequest.setFieldToSearchBy("(text:"); - pdbRequest.setFieldToSortBy(fieldToFilterBy, - !chk_invertFilter.isSelected()); + Collection wantedFields = PDBDocFieldPreferences + .getStructureSummaryFields(); Collection filteredResponse = new HashSet(); for (SequenceI seq : selectedSequences) { + PDBRestRequest pdbRequest = new PDBRestRequest(); + pdbRequest.setAllowEmptySeq(false); + pdbRequest.setResponseSize(1); + pdbRequest.setFieldToSearchBy("(text:"); + pdbRequest.setFieldToSortBy(fieldToFilterBy, + !chk_invertFilter.isSelected()); pdbRequest.setSearchTerm(buildQuery(seq) + ")"); + pdbRequest.setWantedFields(wantedFields); pdbRequest.setAssociatedSequence(seq.getName()); pdbRestCleint = new PDBRestClient(); PDBRestResponse resultList = pdbRestCleint .executeRequest(pdbRequest); + lastPdbRequest = pdbRequest; if (resultList.getSearchSummary() != null && !resultList.getSearchSummary().isEmpty()) { @@ -263,50 +351,49 @@ public class StructureChooser extends GStructureChooser } } - if (filteredResponse != null) + if (!filteredResponse.isEmpty()) { - int filterResponseCount = filteredResponse.size(); - List originalDiscoveredStructuresList = new ArrayList( - discoveredStructuresSet); - originalDiscoveredStructuresList.removeAll(filteredResponse); - Collection reorderedStructuresSet = new ArrayList(); + final int filterResponseCount = filteredResponse.size(); + Collection reorderedStructuresSet = new LinkedHashSet(); reorderedStructuresSet.addAll(filteredResponse); - reorderedStructuresSet.addAll(originalDiscoveredStructuresList); - - tbl_summary.setModel(PDBRestResponse.getTableModel(pdbRequest, - reorderedStructuresSet)); - - ListSelectionModel model = tbl_summary.getSelectionModel(); - model.clearSelection(); - for (int x = 0; x < filterResponseCount; x++) - { - model.addSelectionInterval(x, x); - } - + reorderedStructuresSet.addAll(discoveredStructuresSet); + tbl_summary.setModel(PDBRestResponse.getTableModel( + lastPdbRequest, reorderedStructuresSet)); + + // Update the model here + // ListSelectionModel model = tbl_summary.getSelectionModel(); + // model.clearSelection(); + // model.addSelectionInterval(0, filterResponseCount - 1); + // EventQueue.invokeLater(new Runnable() + // { + // public void run() + // { + tbl_summary.addRowSelectionInterval(0, filterResponseCount - 1); + + // } + // }); // Discard unwanted objects to make them eligible for garbage // collection - originalDiscoveredStructuresList = null; reorderedStructuresSet = null; } lbl_loading.setVisible(false); + String totalTime = (System.currentTimeMillis() - startTime) + + " milli secs"; + mainFrame.setTitle("Structure Chooser - Filter time (" + + totalTime + ")"); + + validateSelections(); } catch (Exception e) { e.printStackTrace(); } - String totalTime = (System.currentTimeMillis() - startTime) - + " milli secs"; - mainFrame.setTitle("Structure Chooser - Filter time (" + totalTime - + ")"); - - validateSelections(); } }); filterThread.start(); } - /** * Handles action event for btn_pdbFromFile */ @@ -409,7 +496,6 @@ public class StructureChooser extends GStructureChooser { validateAssociationFromFile(); } - } /** @@ -504,7 +590,7 @@ public class StructureChooser extends GStructureChooser if (currentView == VIEWS_FILTER) { int pdbIdCol = PDBRestClient.getPDBIdColumIndex( - pdbRequest.getWantedFields(), true); + lastPdbRequest.getWantedFields(), true); int[] selectedRows = tbl_summary.getSelectedRows(); PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length]; int count = 0; @@ -551,12 +637,13 @@ public class StructureChooser extends GStructureChooser * a unique sequence when more than one sequence selection is made. */ public void populateCmbAssociateSeqOptions( - JComboBox cmb_assSeq) + JComboBox cmb_assSeq, JLabel lbl_associateSeq) { cmb_assSeq.removeAllItems(); cmb_assSeq.addItem(new AssociateSeqOptions("-Select Associated Seq-", null)); // cmb_assSeq.addItem(new AssociateSeqOptions("Auto Detect", null)); + lbl_associateSeq.setVisible(false); if (selectedSequences.length > 1) { for (SequenceI seq : selectedSequences) @@ -566,6 +653,10 @@ public class StructureChooser extends GStructureChooser } else { + String seqName = selectedSequence.getDisplayId(false); + seqName = seqName.length() <= 40 ? seqName : seqName.substring(0, 39); + lbl_associateSeq.setText(seqName); + lbl_associateSeq.setVisible(true); cmb_assSeq.setVisible(false); } } @@ -593,7 +684,7 @@ public class StructureChooser extends GStructureChooser { List wantedFields = new ArrayList(); wantedFields.add(PDBDocField.PDB_ID); - pdbRequest = new PDBRestRequest(); + PDBRestRequest pdbRequest = new PDBRestRequest(); pdbRequest.setAllowEmptySeq(false); pdbRequest.setResponseSize(1); pdbRequest.setFieldToSearchBy("(pdb_id:"); @@ -611,4 +702,23 @@ public class StructureChooser extends GStructureChooser validateSelections(); } + @Override + public void tabRefresh() + { + if (selectedSequences != null) + { + Thread refreshThread = new Thread(new Runnable() + { + @Override + public void run() + { + fetchStructuresMetaData(); + filterResultSet(((FilterOption) cmb_filterOption + .getSelectedItem()).getValue()); + } + }); + refreshThread.start(); + } + } + } diff --git a/src/jalview/jbgui/GPDBSearchPanel.java b/src/jalview/jbgui/GPDBSearchPanel.java index b350a0f..29a0014 100644 --- a/src/jalview/jbgui/GPDBSearchPanel.java +++ b/src/jalview/jbgui/GPDBSearchPanel.java @@ -22,6 +22,7 @@ package jalview.jbgui; import jalview.gui.Desktop; +import jalview.jbgui.PDBDocFieldPreferences.PreferenceSource; import jalview.util.MessageManager; import jalview.ws.dbsources.PDBRestClient.PDBDocField; @@ -36,8 +37,11 @@ import javax.swing.JFrame; import javax.swing.JInternalFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; import javax.swing.JTable; import javax.swing.JTextField; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; @@ -65,17 +69,16 @@ public abstract class GPDBSearchPanel extends JPanel protected JTextField txt_search = new JTextField(20); - // protected JList lst_searchResult = new - // JList(); - - // protected JScrollPane scrl_searchResult = new JScrollPane( - // lst_searchResult); - protected JTable tbl_summary = new JTable(); protected JScrollPane scrl_searchResult = new JScrollPane( tbl_summary); + private JTabbedPane tabbedPane = new JTabbedPane(); + + private PDBDocFieldPreferences pdbDocFieldPrefs = new PDBDocFieldPreferences( + PreferenceSource.SEARCH_SUMMARY); + private JPanel pnl_actions = new JPanel(); private JPanel pnl_results = new JPanel(); @@ -104,6 +107,7 @@ tbl_summary); */ private void jbInit() throws Exception { + tbl_summary.setAutoCreateRowSorter(true); btn_back.setFont(new java.awt.Font("Verdana", 0, 12)); btn_back.setText(MessageManager.getString("action.back")); btn_back.addActionListener(new java.awt.event.ActionListener() @@ -131,19 +135,10 @@ tbl_summary); btn_cancel_ActionPerformed(); } }); - pnl_actions.add(btn_back); - pnl_actions.add(btn_ok); - pnl_actions.add(btn_cancel); - - // lst_searchResult - // .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - // lst_searchResult.setLayoutOrientation(JList.VERTICAL); - // lst_searchResult.setVisibleRowCount(-1); scrl_searchResult.setPreferredSize(new Dimension(500, 300)); scrl_searchResult .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); - pnl_results.add(scrl_searchResult); cmb_searchTarget.setFont(new java.awt.Font("Verdana", 0, 12)); cmb_searchTarget.addActionListener(new ActionListener() @@ -179,6 +174,33 @@ tbl_summary); } }); + final String searchTabTitle = MessageManager + .getString("label.search_result"); + ChangeListener changeListener = new ChangeListener() + { + public void stateChanged(ChangeEvent changeEvent) + { + JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent + .getSource(); + int index = sourceTabbedPane.getSelectedIndex(); + if (sourceTabbedPane.getTitleAt(index).equals(searchTabTitle)) + { + txt_search_ActionPerformed(); + } + } + }; + tabbedPane.addChangeListener(changeListener); + tabbedPane.setPreferredSize(new Dimension(500, 300)); + tabbedPane.add(searchTabTitle, scrl_searchResult); + tabbedPane.add( + MessageManager.getString("label.configure_displayed_columns"), + pdbDocFieldPrefs); + + pnl_actions.add(btn_back); + pnl_actions.add(btn_ok); + pnl_actions.add(btn_cancel); + + pnl_results.add(tabbedPane); pnl_inputs.add(cmb_searchTarget); pnl_inputs.add(txt_search); diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index 713a747..13120e0 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -22,6 +22,7 @@ package jalview.jbgui; import jalview.gui.JvSwingUtils; import jalview.gui.StructureViewer.ViewerType; +import jalview.jbgui.PDBDocFieldPreferences.PreferenceSource; import jalview.util.MessageManager; import java.awt.BorderLayout; @@ -831,7 +832,8 @@ public class GPreferences extends JPanel // .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); // scrl_pdbDocFieldConfig.setBounds(); PDBDocFieldPreferences docFieldPref = new PDBDocFieldPreferences( - new Rectangle(10, ypos + 5, 450, 120)); + PreferenceSource.PREFERENCES); + docFieldPref.setBounds(new Rectangle(10, ypos + 5, 450, 120)); structureTab.add(docFieldPref); diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index 080fce9..b79a7f7 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -24,6 +24,7 @@ package jalview.jbgui; import jalview.datamodel.SequenceI; import jalview.gui.AlignmentPanel; import jalview.gui.Desktop; +import jalview.jbgui.PDBDocFieldPreferences.PreferenceSource; import jalview.util.MessageManager; import java.awt.BorderLayout; @@ -43,8 +44,11 @@ import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; import javax.swing.JTable; import javax.swing.JTextField; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; @@ -64,7 +68,6 @@ public abstract class GStructureChooser extends JPanel implements protected JComboBox cmb_filterOption = new JComboBox(); - protected AlignmentPanel ap; protected JLabel lbl_result = new JLabel( @@ -118,6 +121,7 @@ public abstract class GStructureChooser extends JPanel implements protected JLabel lbl_fromFileStatus = new JLabel(errorImage); + protected AssciateSeqPanel idInputAssSeqPanel = new AssciateSeqPanel(); protected AssciateSeqPanel fileChooserAssSeqPanel = new AssciateSeqPanel(); @@ -128,14 +132,16 @@ public abstract class GStructureChooser extends JPanel implements protected static final String VIEWS_ENTER_ID = "VIEWS_ENTER_ID"; - // protected JList jList_FoundStructures = new - // JList(); - protected JTable tbl_summary = new JTable(); protected JScrollPane scrl_foundStructures = new JScrollPane( tbl_summary); + private JTabbedPane tabbedPane = new JTabbedPane(); + + private PDBDocFieldPreferences pdbDocFieldPrefs = new PDBDocFieldPreferences( + PreferenceSource.STRUCTURE_CHOOSER); + public GStructureChooser() { try @@ -157,6 +163,7 @@ public abstract class GStructureChooser extends JPanel implements */ private void jbInit() throws Exception { + tbl_summary.setAutoCreateRowSorter(true); btn_view.setFont(new java.awt.Font("Verdana", 0, 12)); btn_view.setText(MessageManager.getString("action.view")); btn_view.addActionListener(new java.awt.event.ActionListener() @@ -195,18 +202,6 @@ public abstract class GStructureChooser extends JPanel implements chk_invertFilter.setFont(new java.awt.Font("Verdana", 0, 12)); chk_rememberSettings.setFont(new java.awt.Font("Verdana", 0, 12)); - cmb_filterOption.addItemListener(this); - chk_invertFilter.addItemListener(this); - - pnl_actions.add(chk_rememberSettings); - pnl_actions.add(btn_view); - pnl_actions.add(btn_cancel); - - // pnl_filter.add(lbl_result); - pnl_filter.add(cmb_filterOption); - pnl_filter.add(lbl_loading); - pnl_filter.add(chk_invertFilter); - lbl_loading.setVisible(false); txt_search.setToolTipText(MessageManager .getString("label.enter_pdb_id")); @@ -232,6 +227,20 @@ public abstract class GStructureChooser extends JPanel implements txt_search_ActionPerformed(); } }); + + cmb_filterOption.addItemListener(this); + chk_invertFilter.addItemListener(this); + + pnl_actions.add(chk_rememberSettings); + pnl_actions.add(btn_view); + pnl_actions.add(btn_cancel); + + // pnl_filter.add(lbl_result); + pnl_filter.add(cmb_filterOption); + pnl_filter.add(lbl_loading); + pnl_filter.add(chk_invertFilter); + lbl_loading.setVisible(false); + pnl_idInput.add(txt_search); pnl_idInput.add(lbl_pdbManualFetchStatus); @@ -243,10 +252,35 @@ public abstract class GStructureChooser extends JPanel implements pnl_idInputBL.add(idInputAssSeqPanel, BorderLayout.NORTH); pnl_idInputBL.add(pnl_idInput, BorderLayout.CENTER); + + final String foundStructureSummary = MessageManager + .getString("label.found_structures_summary"); + + ChangeListener changeListener = new ChangeListener() + { + public void stateChanged(ChangeEvent changeEvent) + { + JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent + .getSource(); + int index = sourceTabbedPane.getSelectedIndex(); + if (sourceTabbedPane.getTitleAt(index) + .equals(foundStructureSummary)) + { + tabRefresh(); + } + } + }; + tabbedPane.addChangeListener(changeListener); + tabbedPane.setPreferredSize(new Dimension(500, 300)); + tabbedPane.add(foundStructureSummary, scrl_foundStructures); + tabbedPane.add( + MessageManager.getString("label.configure_displayed_columns"), + pdbDocFieldPrefs); + pnl_switchableViews.add(pnl_fileChooserBL, VIEWS_FROM_FILE); pnl_switchableViews.add(pnl_idInputBL, VIEWS_ENTER_ID); - pnl_switchableViews.add(scrl_foundStructures, VIEWS_FILTER); + pnl_switchableViews.add(tabbedPane, VIEWS_FILTER); this.setLayout(mainLayout); this.add(pnl_filter, java.awt.BorderLayout.NORTH); @@ -389,10 +423,14 @@ public abstract class GStructureChooser extends JPanel implements public class AssciateSeqPanel extends JPanel implements ItemListener { private JComboBox cmb_assSeq = new JComboBox(); + + private JLabel lbl_associateSeq = new JLabel(); + public AssciateSeqPanel() { this.setLayout(new FlowLayout()); this.add(cmb_assSeq); + this.add(lbl_associateSeq); cmb_assSeq.setToolTipText(MessageManager .getString("info.associate_wit_sequence")); cmb_assSeq.addItemListener(this); @@ -400,7 +438,7 @@ public abstract class GStructureChooser extends JPanel implements public void loadCmbAssSeq() { - populateCmbAssociateSeqOptions(cmb_assSeq); + populateCmbAssociateSeqOptions(cmb_assSeq, lbl_associateSeq); } public JComboBox getCmb_assSeq() @@ -441,7 +479,9 @@ public abstract class GStructureChooser extends JPanel implements protected abstract void txt_search_ActionPerformed(); public abstract void populateCmbAssociateSeqOptions( - JComboBox cmb_assSeq); + JComboBox cmb_assSeq, JLabel lbl_associateSeq); public abstract void cmbAssSeqStateChanged(); + + public abstract void tabRefresh(); } diff --git a/src/jalview/jbgui/PDBDocFieldPreferences.java b/src/jalview/jbgui/PDBDocFieldPreferences.java index 9380380..2021d0b 100644 --- a/src/jalview/jbgui/PDBDocFieldPreferences.java +++ b/src/jalview/jbgui/PDBDocFieldPreferences.java @@ -2,7 +2,6 @@ package jalview.jbgui; import jalview.ws.dbsources.PDBRestClient.PDBDocField; -import java.awt.Rectangle; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -14,7 +13,6 @@ import javax.swing.table.AbstractTableModel; @SuppressWarnings("serial") public class PDBDocFieldPreferences extends JScrollPane { - protected JTable tbl_pdbDocFieldConfig = new JTable(); protected JScrollPane scrl_pdbDocFieldConfig = new JScrollPane( @@ -26,18 +24,46 @@ public class PDBDocFieldPreferences extends JScrollPane private static Collection structureSummaryFields = new HashSet(); + public enum PreferenceSource + { + SEARCH_SUMMARY, STRUCTURE_CHOOSER, PREFERENCES; + } + + private PreferenceSource currentSource; + static { searchSummaryFields.add(PDBDocField.PDB_ID); searchSummaryFields.add(PDBDocField.TITLE); + structureSummaryFields.add(PDBDocField.PDB_ID); structureSummaryFields.add(PDBDocField.TITLE); } - public PDBDocFieldPreferences(Rectangle position) + public PDBDocFieldPreferences(PreferenceSource source) { - this.setBounds(position); + tbl_pdbDocFieldConfig.setAutoCreateRowSorter(true); this.getViewport().add(tbl_pdbDocFieldConfig); + this.currentSource = source; + + String[] columnNames = null; + switch (source) + { + case SEARCH_SUMMARY: + columnNames = new String[] + { "PDB Feild", "Show in search summary" }; + break; + case STRUCTURE_CHOOSER: + columnNames = new String[] + { "PDB Feild", "Show in structure summary" }; + break; + case PREFERENCES: + columnNames = new String[] + { "PDB Feild", "Show in search summary", "Show in structure summary" }; + break; + default: + break; + } Object[][] data = new Object[PDBDocField.values().length - 1][3]; int x = 0; @@ -48,13 +74,28 @@ public class PDBDocFieldPreferences extends JScrollPane continue; } - data[x++] = new Object[] - { field.getName(), searchSummaryFields.contains(field), - structureSummaryFields.contains(field) }; + switch (source) + { + case SEARCH_SUMMARY: + data[x++] = new Object[] + { field.getName(), searchSummaryFields.contains(field) }; + break; + case STRUCTURE_CHOOSER: + data[x++] = new Object[] + { field.getName(), structureSummaryFields.contains(field) }; + break; + case PREFERENCES: + data[x++] = new Object[] + { field.getName(), searchSummaryFields.contains(field), + structureSummaryFields.contains(field) }; + break; + default: + break; + } map.put(field.getName(), field); } - PDBFieldTableModel model = new PDBFieldTableModel(data); + PDBFieldTableModel model = new PDBFieldTableModel(columnNames, data); tbl_pdbDocFieldConfig.setModel(model); } @@ -83,17 +124,16 @@ public class PDBDocFieldPreferences extends JScrollPane class PDBFieldTableModel extends AbstractTableModel { - public PDBFieldTableModel(Object[][] data) + public PDBFieldTableModel(String[] columnNames, Object[][] data) { this.data = data; + this.columnNames = columnNames; } - private String[] columnNames = new String[] - { "PDB Feild", "Show in search summary", - "Show in structure chooser summary" }; - private Object[][] data; + private String[] columnNames; + public int getColumnCount() { return columnNames.length; @@ -148,31 +188,41 @@ public class PDBDocFieldPreferences extends JScrollPane PDBDocField pdbField = map.get(name); - if (col == 1) + if (currentSource == PreferenceSource.SEARCH_SUMMARY) { - if (searchSummaryFields.contains(pdbField) && !selected) - { - searchSummaryFields.remove(pdbField); - } - - if (!searchSummaryFields.contains(pdbField) && selected) - { - searchSummaryFields.add(pdbField); - } + updatePrefs(searchSummaryFields, pdbField, selected); } - else if (col == 2) + else if (currentSource == PreferenceSource.STRUCTURE_CHOOSER) { - if (structureSummaryFields.contains(pdbField) && !selected) + updatePrefs(structureSummaryFields, pdbField, selected); + } + else if (currentSource == PreferenceSource.PREFERENCES) + { + if (col == 1) { - structureSummaryFields.remove(pdbField); + updatePrefs(searchSummaryFields, pdbField, selected); } - - if (!structureSummaryFields.contains(pdbField) && selected) + else if (col == 2) { - structureSummaryFields.add(pdbField); + updatePrefs(structureSummaryFields, pdbField, selected); } } + } + + private void updatePrefs(Collection prefConfig, + PDBDocField pdbField, + boolean selected) + { + if (prefConfig.contains(pdbField) && !selected) + { + prefConfig.remove(pdbField); + } + if (!prefConfig.contains(pdbField) && selected) + { + prefConfig.add(pdbField); + } } + } } diff --git a/src/jalview/ws/uimodel/PDBRestRequest.java b/src/jalview/ws/uimodel/PDBRestRequest.java index 70dae0b..58d7aeb 100644 --- a/src/jalview/ws/uimodel/PDBRestRequest.java +++ b/src/jalview/ws/uimodel/PDBRestRequest.java @@ -132,4 +132,11 @@ public class PDBRestRequest return fieldToSearchBy + searchTerm + (isAllowEmptySeq() ? "" : " AND molecule_sequence:['' TO *]"); } + + public String toString() + { + return "Query : " + getQuery() + " sort field: " + fieldToSortBy + + " isAsc: " + isAscending() + " Associated Seq : " + + associatedSequence; + } } diff --git a/src/jalview/ws/uimodel/PDBRestResponse.java b/src/jalview/ws/uimodel/PDBRestResponse.java index 7f570a4..3b5b05c 100644 --- a/src/jalview/ws/uimodel/PDBRestResponse.java +++ b/src/jalview/ws/uimodel/PDBRestResponse.java @@ -109,6 +109,7 @@ public class PDBRestResponse tableModel.addRow(res.getSummaryData()); // Populate table rows with // summary list } + return tableModel; } @@ -144,8 +145,7 @@ public class PDBRestResponse String fieldData = (pdbJsonDoc.get(field.getCode()) == null) ? "" : pdbJsonDoc .get(field.getCode()).toString(); - if (field.equals(PDBDocField.PDB_ID) - && pdbJsonDoc.get(PDBDocField.PDB_ID.getCode()) != null) + if (field.equals(PDBDocField.PDB_ID)) { this.pdbId = fieldData; summaryRowData[colCounter++] = this.pdbId;