From 2cf5d7bb20203f70d6839b579a7a205f49a46f1d Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 7 Feb 2018 12:55:30 +0000 Subject: [PATCH] =?utf8?q?JAL-2780=20JAL-2781=20JAL-2902=20refactor=20=E2=80?= =?utf8?q?=98OK=E2=80=99=20action=20to=20optionally=20blocking=20method=20fo?= =?utf8?q?r=20retrieval/opening=20view=20for=20selected=20structures=20and=20?= =?utf8?q?getter=20for=20retrieving=20the=20handle=20for=20the=20last=20open?= =?utf8?q?ed=20viewer?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/gui/StructureChooser.java | 92 ++++++++++++++++++++++++++------- 1 file changed, 72 insertions(+), 20 deletions(-) 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; + } } -- 1.7.10.2