From 329abf57c756ac530604dce9136045b0bd5ffaca Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 18 Feb 2011 17:29:50 +0000 Subject: [PATCH] convenience method to discover all Jmols --- src/jalview/gui/Desktop.java | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index c58de43..dbb6955 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1986,6 +1986,42 @@ public class Desktop extends jalview.jbgui.GDesktop implements avp.clear(); return afs; } + public AppJmol[] getJmols() + { + JInternalFrame[] frames = Desktop.desktop.getAllFrames(); + + if (frames == null) + { + return null; + } + Vector avp = new Vector(); + try + { + // REVERSE ORDER + for (int i = frames.length - 1; i > -1; i--) + { + if (frames[i] instanceof AppJmol) + { + AppJmol af = (AppJmol) frames[i]; + avp.addElement(af); + } + } + } catch (Exception ex) + { + ex.printStackTrace(); + } + if (avp.size() == 0) + { + return null; + } + AppJmol afs[] = new AppJmol[avp.size()]; + for (int i = 0, j = avp.size(); i < j; i++) + { + afs[i] = (AppJmol) avp.elementAt(i); + } + avp.clear(); + return afs; + } /** * Add Groovy Support to Jalview @@ -2326,4 +2362,5 @@ public class Desktop extends jalview.jbgui.GDesktop implements return wsparamManager; } + } -- 1.7.10.2