From: Jim Procter Date: Thu, 5 Apr 2018 13:31:56 +0000 (+0100) Subject: JAL-2944 open selected structures in existing or a new view, and by default offer... X-Git-Tag: Release_2_10_4~32^2~12 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5a3e8375831cd87fb3668e0945f907ddce0ab82a;p=jalview.git JAL-2944 open selected structures in existing or a new view, and by default offer last opened/selected structure view as target view --- diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 198aa62..1c99f02 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -125,6 +125,7 @@ public class StructureChooser extends GStructureChooser fetchStructuresMetaData(); // revise filter options if no results were found populateFilterComboBox(isStructuresDiscovered(), cachedPDBExists); + discoverStructureViews(); updateProgressIndicator(null, startTime); mainFrame.setVisible(true); updateCurrentView(); @@ -133,6 +134,47 @@ public class StructureChooser extends GStructureChooser discoverPDBStructuresThread.start(); } + private void discoverStructureViews() + { + if (Desktop.instance != null) + { + targetView.removeAllItems(); + targetView.addItem( + new StructureViewer(ap.getStructureSelectionManager())); + if (lastTargetedView != null && !lastTargetedView.isVisible()) + { + lastTargetedView = null; + } + int linkedViewsAt = 1; + for (StructureViewerBase view : Desktop.instance + .getStructureViewers(null, null)) + { + StructureViewer viewHandler = (lastTargetedView != null + && lastTargetedView.sview == view) ? lastTargetedView + : StructureViewer.reconfigure(view); + + if (view.isLinkedWith(ap)) + { + targetView.insertItemAt(viewHandler, + linkedViewsAt++); + } + else + { + targetView.addItem(viewHandler); + } + } + targetView.setVisible(targetView.getItemCount() > 1); + + // finally, restore last targeted view by default. + if (lastTargetedView != null) + { + targetView.setSelectedItem(lastTargetedView); + } + } + } + + private static StructureViewer lastTargetedView = null; + /** * Updates the progress indicator with the specified message * @@ -957,6 +999,18 @@ public class StructureChooser extends GStructureChooser return foundEntry; } + public StructureViewer getTargetedStructureViewer( + StructureSelectionManager ssm) + { + Object _sv = targetView.getSelectedItem(); + + if (_sv == null) + { + return new StructureViewer(ssm); + } else { + return (StructureViewer) _sv; + } + } private StructureViewer launchStructureViewer( StructureSelectionManager ssm, final PDBEntry[] pdbEntriesToView, @@ -965,9 +1019,9 @@ public class StructureChooser extends GStructureChooser long progressId = sequences.hashCode(); setProgressBar(MessageManager .getString("status.launching_3d_structure_viewer"), progressId); - final StructureViewer sViewer = new StructureViewer(ssm); - setProgressBar(null, progressId); + final StructureViewer sViewer = getTargetedStructureViewer(ssm); + setProgressBar(null, progressId); if (SiftsSettings.isMapWithSifts()) { List seqsWithoutSourceDBRef = new ArrayList<>(); @@ -1032,6 +1086,8 @@ public class StructureChooser extends GStructureChooser sViewer.viewStructures(pdbEntriesToView[0], sequences, alignPanel); } setProgressBar(null, progressId); + // remember the last viewer we used... + lastTargetedView = sViewer; return sViewer; }