use of org.vcell.client.logicalwindow.LWTopFrame in project vcell by virtualcell.
the class TopLevelWindowManager method activeManager.
public static TopLevelWindowManager activeManager() {
LWTopFrame activetf = null;
Optional<WeakReference<LWTopFrame>> first = LWTopFrame.liveWindows().findFirst();
if (first.isPresent()) {
activetf = first.get().get();
}
TopLevelWindowManager fallback = null;
Iterator<WeakReference<TopLevelWindowManager>> iter = allManagers.iterator();
while (iter.hasNext()) {
WeakReference<TopLevelWindowManager> wr = iter.next();
TopLevelWindowManager tlwm = wr.get();
if (tlwm == null) {
iter.remove();
continue;
}
if (activetf == null) {
if (lg.isWarnEnabled()) {
lg.warn("no active LWTopFrame in TopLevelWindowManager?");
}
// guess
return tlwm;
}
if (fallback == null) {
// return this if can't find the right window
fallback = tlwm;
}
Component cmpt = tlwm.getComponent();
if (cmpt != null && SwingUtilities.isDescendingFrom(cmpt, activetf)) {
return tlwm;
}
}
return fallback;
}
Aggregations