X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FStructureChooser.java;fp=src%2Fjalview%2Fgui%2FStructureChooser.java;h=af8b2f33c8522c0aab0012914e4dd00be76f8711;hb=4d9ad51dc8a445c2f1fb02b997e13bd945fa8ad2;hp=7d8f1bfa1365de768137e4ee8ccf0bf39219fbb2;hpb=bac4802486edabc43143c926c0615f8fb577b1b5;p=jalview.git diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 7d8f1bf..af8b2f3 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -65,8 +65,6 @@ import javax.swing.table.AbstractTableModel; public class StructureChooser extends GStructureChooser implements IProgressIndicator { - private boolean structuresDiscovered = false; - private SequenceI selectedSequence; private SequenceI[] selectedSequences; @@ -103,6 +101,8 @@ public class StructureChooser extends GStructureChooser implements 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 @@ -117,7 +117,8 @@ public class StructureChooser extends GStructureChooser implements .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(); @@ -161,6 +162,10 @@ public class StructureChooser extends GStructureChooser implements 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); @@ -191,7 +196,6 @@ public class StructureChooser extends GStructureChooser implements getResultTable().setModel( FTSRestResponse.getTableModel(lastPdbRequest, discoveredStructuresSet)); - structuresDiscovered = true; noOfStructuresFound = discoveredStructuresSet.size(); mainFrame.setTitle(MessageManager.formatMessage( "label.structure_chooser_no_of_structures", @@ -524,10 +528,15 @@ public class StructureChooser extends GStructureChooser implements * 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)); @@ -546,12 +555,13 @@ public class StructureChooser extends GStructureChooser implements 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 @@ -963,12 +973,8 @@ public class StructureChooser extends GStructureChooser implements public boolean isStructuresDiscovered() { - return structuresDiscovered; - } - - public void setStructuresDiscovered(boolean structuresDiscovered) - { - this.structuresDiscovered = structuresDiscovered; + return discoveredStructuresSet != null + && !discoveredStructuresSet.isEmpty(); } public Collection getDiscoveredStructuresSet()