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
import java.util.Comparator;
import java.util.List;
+import javax.swing.table.DefaultTableModel;
+
@SuppressWarnings("serial")
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();
/*
+
* Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
* Copyright (C) 2014 The Jalview Authors
*
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
private IProgressIndicator progressIndicator;
- private Collection<PDBResponseSummary> discoveredStructuresSet = new HashSet<PDBResponseSummary>();
+ private Collection<PDBResponseSummary> discoveredStructuresSet;
- private PDBRestRequest pdbRequest;
+ private PDBRestRequest lastPdbRequest;
private PDBRestClient pdbRestCleint;
Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
.getStructureSummaryFields();
- pdbRequest = new PDBRestRequest();
- pdbRequest.setAllowEmptySeq(false);
- pdbRequest.setResponseSize(500);
- pdbRequest.setFieldToSearchBy("(text:");
- pdbRequest.setWantedFields(wantedFields);
+ discoveredStructuresSet = new LinkedHashSet<PDBResponseSummary>();
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())
{
if (discoveredStructuresSet != null
&& !discoveredStructuresSet.isEmpty())
{
- tbl_summary.setModel(PDBRestResponse.getTableModel(pdbRequest,
+ tbl_summary.setModel(PDBRestResponse.getTableModel(lastPdbRequest,
discoveredStructuresSet));
structuresDiscovered = true;
noOfStructuresFound = discoveredStructuresSet.size();
*/
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<PDBDocField> wantedFields = PDBDocFieldPreferences
+ // .getStructureSummaryFields();
+ // Collection<PDBResponseSummary> filteredResponse = new
+ // HashSet<PDBResponseSummary>();
+ // 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<PDBResponseSummary> reorderedStructuresSet = new
+ // LinkedHashSet<PDBResponseSummary>();
+ // 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
try
{
lbl_loading.setVisible(true);
- pdbRequest.setResponseSize(1);
- pdbRequest.setFieldToSearchBy("(text:");
- pdbRequest.setFieldToSortBy(fieldToFilterBy,
- !chk_invertFilter.isSelected());
+ Collection<PDBDocField> wantedFields = PDBDocFieldPreferences
+ .getStructureSummaryFields();
Collection<PDBResponseSummary> filteredResponse = new HashSet<PDBResponseSummary>();
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())
{
}
}
- if (filteredResponse != null)
+ if (!filteredResponse.isEmpty())
{
- int filterResponseCount = filteredResponse.size();
- List<PDBResponseSummary> originalDiscoveredStructuresList = new ArrayList<PDBResponseSummary>(
- discoveredStructuresSet);
- originalDiscoveredStructuresList.removeAll(filteredResponse);
- Collection<PDBResponseSummary> reorderedStructuresSet = new ArrayList<PDBResponseSummary>();
+ final int filterResponseCount = filteredResponse.size();
+ Collection<PDBResponseSummary> reorderedStructuresSet = new LinkedHashSet<PDBResponseSummary>();
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
*/
{
validateAssociationFromFile();
}
-
}
/**
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;
* a unique sequence when more than one sequence selection is made.
*/
public void populateCmbAssociateSeqOptions(
- JComboBox<AssociateSeqOptions> cmb_assSeq)
+ JComboBox<AssociateSeqOptions> 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)
}
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);
}
}
{
List<PDBDocField> wantedFields = new ArrayList<PDBDocField>();
wantedFields.add(PDBDocField.PDB_ID);
- pdbRequest = new PDBRestRequest();
+ PDBRestRequest pdbRequest = new PDBRestRequest();
pdbRequest.setAllowEmptySeq(false);
pdbRequest.setResponseSize(1);
pdbRequest.setFieldToSearchBy("(pdb_id:");
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();
+ }
+ }
+
}
package jalview.jbgui;
import jalview.gui.Desktop;
+import jalview.jbgui.PDBDocFieldPreferences.PreferenceSource;
import jalview.util.MessageManager;
import jalview.ws.dbsources.PDBRestClient.PDBDocField;
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;
protected JTextField txt_search = new JTextField(20);
- // protected JList<PDBResponseSummary> lst_searchResult = new
- // JList<PDBResponseSummary>();
-
- // 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();
*/
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()
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()
}
});
+ 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);
import jalview.gui.JvSwingUtils;
import jalview.gui.StructureViewer.ViewerType;
+import jalview.jbgui.PDBDocFieldPreferences.PreferenceSource;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
// .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);
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;
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;
protected JComboBox<FilterOption> cmb_filterOption = new JComboBox<FilterOption>();
-
protected AlignmentPanel ap;
protected JLabel lbl_result = new JLabel(
protected JLabel lbl_fromFileStatus = new JLabel(errorImage);
+
protected AssciateSeqPanel idInputAssSeqPanel = new AssciateSeqPanel();
protected AssciateSeqPanel fileChooserAssSeqPanel = new AssciateSeqPanel();
protected static final String VIEWS_ENTER_ID = "VIEWS_ENTER_ID";
- // protected JList<PDBResponseSummary> jList_FoundStructures = new
- // JList<PDBResponseSummary>();
-
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
*/
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()
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"));
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);
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);
public class AssciateSeqPanel extends JPanel implements ItemListener
{
private JComboBox<AssociateSeqOptions> cmb_assSeq = new JComboBox<AssociateSeqOptions>();
+
+ 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);
public void loadCmbAssSeq()
{
- populateCmbAssociateSeqOptions(cmb_assSeq);
+ populateCmbAssociateSeqOptions(cmb_assSeq, lbl_associateSeq);
}
public JComboBox<AssociateSeqOptions> getCmb_assSeq()
protected abstract void txt_search_ActionPerformed();
public abstract void populateCmbAssociateSeqOptions(
- JComboBox<AssociateSeqOptions> cmb_assSeq);
+ JComboBox<AssociateSeqOptions> cmb_assSeq, JLabel lbl_associateSeq);
public abstract void cmbAssSeqStateChanged();
+
+ public abstract void tabRefresh();
}
import jalview.ws.dbsources.PDBRestClient.PDBDocField;
-import java.awt.Rectangle;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@SuppressWarnings("serial")
public class PDBDocFieldPreferences extends JScrollPane
{
-
protected JTable tbl_pdbDocFieldConfig = new JTable();
protected JScrollPane scrl_pdbDocFieldConfig = new JScrollPane(
private static Collection<PDBDocField> structureSummaryFields = new HashSet<PDBDocField>();
+ 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;
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);
}
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;
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<PDBDocField> prefConfig,
+ PDBDocField pdbField,
+ boolean selected)
+ {
+ if (prefConfig.contains(pdbField) && !selected)
+ {
+ prefConfig.remove(pdbField);
+ }
+ if (!prefConfig.contains(pdbField) && selected)
+ {
+ prefConfig.add(pdbField);
+ }
}
+
}
}
return fieldToSearchBy + searchTerm
+ (isAllowEmptySeq() ? "" : " AND molecule_sequence:['' TO *]");
}
+
+ public String toString()
+ {
+ return "Query : " + getQuery() + " sort field: " + fieldToSortBy
+ + " isAsc: " + isAscending() + " Associated Seq : "
+ + associatedSequence;
+ }
}
tableModel.addRow(res.getSummaryData()); // Populate table rows with
// summary list
}
+
return tableModel;
}
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;