X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FStructureChooser.java;h=0c3aa2a0f8fabcbe0766f74126b31d297014a49d;hb=fee1b781ca14aadea5d112fc554fe14879c787c5;hp=57debe394984c2a8a391670796ef555c84f14b9d;hpb=853624fb32058cccc544ae7d13af6ad4b0800b6c;p=jalview.git diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 57debe3..0c3aa2a 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -81,6 +81,10 @@ public class StructureChooser extends GStructureChooser implements private boolean isValidPBDEntry; + private boolean cachedPDBExists; + + private static int MAX_QLENGHT = 7820; + public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq, AlignmentPanel ap) { @@ -102,7 +106,7 @@ public class StructureChooser extends GStructureChooser implements } // ensure a filter option is in force for search - populateFilterComboBox(true); + populateFilterComboBox(true, cachedPDBExists); Thread discoverPDBStructuresThread = new Thread(new Runnable() { @Override @@ -118,7 +122,7 @@ public class StructureChooser extends GStructureChooser implements startTime); fetchStructuresMetaData(); // revise filter options if no results were found - populateFilterComboBox(isStructuresDiscovered()); + populateFilterComboBox(isStructuresDiscovered(), cachedPDBExists); updateProgressIndicator(null, startTime); mainFrame.setVisible(true); updateCurrentView(); @@ -212,9 +216,9 @@ public class StructureChooser extends GStructureChooser implements { errorMsg.append(error).append("\n"); } - JOptionPane.showMessageDialog(this, errorMsg.toString(), + JvOptionPane.showMessageDialog(this, errorMsg.toString(), MessageManager.getString("label.pdb_web-service_error"), - JOptionPane.ERROR_MESSAGE); + JvOptionPane.ERROR_MESSAGE); } } } @@ -237,7 +241,7 @@ public class StructureChooser extends GStructureChooser implements } } } - + cachedPDBExists = !entries.isEmpty(); PDBEntryTableModel tableModelx = new PDBEntryTableModel(entries); tbl_local_pdb.setModel(tableModelx); } @@ -257,7 +261,8 @@ public class StructureChooser extends GStructureChooser implements StringBuilder queryBuilder = new StringBuilder(); Set seqRefs = new LinkedHashSet(); - if (seq.getAllPDBEntries() != null) + if (seq.getAllPDBEntries() != null + && queryBuilder.length() < MAX_QLENGHT) { for (PDBEntry entry : seq.getAllPDBEntries()) { @@ -266,7 +271,6 @@ public class StructureChooser extends GStructureChooser implements queryBuilder.append("pdb_id:") .append(entry.getId().toLowerCase()).append(" OR "); isPDBRefsFound = true; - // seqRefs.add(entry.getId()); } } } @@ -275,7 +279,8 @@ public class StructureChooser extends GStructureChooser implements { for (DBRefEntry dbRef : seq.getDBRefs()) { - if (isValidSeqName(getDBRefId(dbRef))) + if (isValidSeqName(getDBRefId(dbRef)) + && queryBuilder.length() < MAX_QLENGHT) { if (dbRef.getSource().equalsIgnoreCase(DBRefSource.UNIPROT)) { @@ -479,11 +484,11 @@ public class StructureChooser extends GStructureChooser implements { errorMsg.append(error).append("\n"); } - JOptionPane.showMessageDialog( + JvOptionPane.showMessageDialog( null, errorMsg.toString(), MessageManager.getString("label.pdb_web-service_error"), - JOptionPane.ERROR_MESSAGE); + JvOptionPane.ERROR_MESSAGE); } } @@ -524,7 +529,8 @@ public class StructureChooser extends GStructureChooser implements * Populates the filter combo-box options dynamically depending on discovered * structures */ - protected void populateFilterComboBox(boolean haveData) + protected void populateFilterComboBox(boolean haveData, + boolean cachedPDBExists) { /* * temporarily suspend the change listener behaviour @@ -549,8 +555,14 @@ public class StructureChooser extends GStructureChooser implements VIEWS_ENTER_ID)); cmb_filterOption.addItem(new FilterOption("From File", "-", VIEWS_FROM_FILE)); - cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-", - VIEWS_LOCAL_PDB)); + FilterOption cachedOption = new FilterOption("Cached PDB Entries", "-", + VIEWS_LOCAL_PDB); + cmb_filterOption.addItem(cachedOption); + + if (/*!haveData &&*/cachedPDBExists) + { + cmb_filterOption.setSelectedItem(cachedOption); + } cmb_filterOption.addItemListener(this); }