From: Jim Procter Date: Wed, 7 Feb 2018 12:55:30 +0000 (+0000) Subject: JAL-2780 JAL-2781 JAL-2902 refactor ‘OK’ action to optionally blocking method for... X-Git-Tag: Release_2_10_4~68^2~35 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2cf5d7bb20203f70d6839b579a7a205f49a46f1d;p=jalview.git JAL-2780 JAL-2781 JAL-2902 refactor ‘OK’ action to optionally blocking method for retrieval/opening view for selected structures and getter for retrieving the handle for the last opened viewer --- diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 6e73724..5de3082 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -21,6 +21,7 @@ package jalview.gui; +import jalview.api.structures.JalviewStructureDisplayI; import jalview.bin.Jalview; import jalview.datamodel.DBRefEntry; import jalview.datamodel.DBRefSource; @@ -728,31 +729,43 @@ public class StructureChooser extends GStructureChooser } - public void selectStructure(String...pdbids) + /** + * select structures for viewing by their PDB IDs + * + * @param pdbids + * @return true if structures were found and marked as selected + */ + public boolean selectStructure(String... pdbids) { + boolean found = false; + FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption .getSelectedItem()); String currentView = selectedFilterOpt.getView(); JTable restable = (currentView == VIEWS_FILTER) ? getResultTable() - : tbl_local_pdb; + : (currentView == VIEWS_LOCAL_PDB) ? tbl_local_pdb : null; - if (currentView == VIEWS_FILTER) + if (restable == null) { - - int pdbIdColIndex = restable.getColumn("PDB Id") - .getModelIndex(); - for (int r = 0; r < restable.getRowCount(); r++) + // can't select (enter PDB ID, or load file - need to also select which + // sequence to associate with) + return false; + } + + int pdbIdColIndex = restable.getColumn("PDB Id").getModelIndex(); + for (int r = 0; r < restable.getRowCount(); r++) + { + for (int p = 0; p < pdbids.length; p++) { - for (int p=0;p pdbEntries) @@ -904,7 +949,8 @@ public class StructureChooser extends GStructureChooser return foundEntry; } - private void launchStructureViewer(StructureSelectionManager ssm, + private StructureViewer launchStructureViewer( + StructureSelectionManager ssm, final PDBEntry[] pdbEntriesToView, final AlignmentPanel alignPanel, SequenceI[] sequences) { @@ -978,6 +1024,7 @@ public class StructureChooser extends GStructureChooser sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel); } setProgressBar(null, progressId); + return sViewer; } /** @@ -1208,4 +1255,9 @@ public class StructureChooser extends GStructureChooser { return progressBar.operationInProgress(); } + + public JalviewStructureDisplayI getOpenedStructureViewer() + { + return sViewer == null ? null : sViewer.sview; + } }