public class StructureChooser extends GStructureChooser implements
IProgressIndicator
{
- private boolean structuresDiscovered = false;
-
private SequenceI selectedSequence;
private SequenceI[] selectedSequences;
progressBar = new ProgressBar(this.statusPanel, this.statusBar);
}
+ // ensure a filter option is in force for search
+ populateFilterComboBox(true);
Thread discoverPDBStructuresThread = new Thread(new Runnable()
{
@Override
.getString("status.searching_for_pdb_structures"),
startTime);
fetchStructuresMetaData();
- populateFilterComboBox();
+ // revise filter options if no results were found
+ populateFilterComboBox(isStructuresDiscovered());
updateProgressIndicator(null, startTime);
mainFrame.setVisible(true);
updateCurrentView();
pdbRequest.setAllowEmptySeq(false);
pdbRequest.setResponseSize(500);
pdbRequest.setFieldToSearchBy("(");
+ FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
+ .getSelectedItem());
+ pdbRequest.setFieldToSortBy(selectedFilterOpt.getValue(),
+ !chk_invertFilter.isSelected());
pdbRequest.setWantedFields(wantedFields);
pdbRequest.setSearchTerm(buildQuery(seq) + ")");
pdbRequest.setAssociatedSequence(seq);
getResultTable().setModel(
FTSRestResponse.getTableModel(lastPdbRequest,
discoveredStructuresSet));
- structuresDiscovered = true;
noOfStructuresFound = discoveredStructuresSet.size();
mainFrame.setTitle(MessageManager.formatMessage(
"label.structure_chooser_no_of_structures",
* Populates the filter combo-box options dynamically depending on discovered
* structures
*/
- @Override
- protected void populateFilterComboBox()
+ protected void populateFilterComboBox(boolean haveData)
{
- if (isStructuresDiscovered())
+ /*
+ * temporarily suspend the change listener behaviour
+ */
+ cmb_filterOption.removeItemListener(this);
+
+ cmb_filterOption.removeAllItems();
+ if (haveData)
{
cmb_filterOption.addItem(new FilterOption("Best Quality",
"overall_quality", VIEWS_FILTER));
VIEWS_FROM_FILE));
cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-",
VIEWS_LOCAL_PDB));
+
+ cmb_filterOption.addItemListener(this);
}
/**
* Updates the displayed view based on the selected filter option
*/
- @Override
protected void updateCurrentView()
{
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
public boolean isStructuresDiscovered()
{
- return structuresDiscovered;
- }
-
- public void setStructuresDiscovered(boolean structuresDiscovered)
- {
- this.structuresDiscovered = structuresDiscovered;
+ return discoveredStructuresSet != null
+ && !discoveredStructuresSet.isEmpty();
}
public Collection<FTSData> getDiscoveredStructuresSet()
}
@Test(groups = { "Functional" })
- public void populateFilterComboBoxTest()
+ public void populateFilterComboBoxTest() throws InterruptedException
{
SequenceI[] selectedSeqs = new SequenceI[] { seq };
StructureChooser sc = new StructureChooser(selectedSeqs, seq, null);
- sc.populateFilterComboBox();
+ sc.populateFilterComboBox(false);
int optionsSize = sc.getCmbFilterOption().getItemCount();
assertEquals(3, optionsSize); // if structures are not discovered then don't
// populate filter options
- sc.setStructuresDiscovered(true);
- sc.populateFilterComboBox();
- try
- {
- Thread.sleep(2000);
- } catch (InterruptedException e)
- {
- e.printStackTrace();
- }
+ sc.populateFilterComboBox(true);
optionsSize = sc.getCmbFilterOption().getItemCount();
assertTrue(optionsSize > 3); // if structures are found, filter options
// should be populated