X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=5e6f40e6f78ddac28fbc044e2ee73878ccbc3947;hb=refs%2Fheads%2Fbug%2FJAL-4214_system_freeze_when_opening_file_using_gui_in_linux;hp=b901ae416c8311664b4e692863820d7f4862d7dc;hpb=071c3341c69314363376d9af7b5537141a40de54;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index b901ae4..5e6f40e 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -51,6 +51,7 @@ import java.awt.event.WindowEvent; import java.awt.geom.AffineTransform; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.beans.PropertyVetoException; import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -63,6 +64,7 @@ import java.util.Hashtable; import java.util.List; import java.util.ListIterator; import java.util.Locale; +import java.util.Map; import java.util.Vector; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -3629,17 +3631,19 @@ public class Desktop extends jalview.jbgui.GDesktop } /** - * checks if any progress bars are being displayed in any of the windows managed by the desktop + * checks if any progress bars are being displayed in any of the windows + * managed by the desktop + * * @return */ public boolean operationsAreInProgress() { JInternalFrame[] frames = getAllFrames(); - for (JInternalFrame frame:frames) + for (JInternalFrame frame : frames) { if (frame instanceof IProgressIndicator) { - if (((IProgressIndicator)frame).operationInProgress()) + if (((IProgressIndicator) frame).operationInProgress()) { return true; } @@ -3647,4 +3651,37 @@ public class Desktop extends jalview.jbgui.GDesktop } return operationInProgress(); } + + /** + * keep track of modal JvOptionPanes open as modal dialogs for AlignFrames. + * The way the modal JInternalFrame is made means it cannot be a child of an + * AlignFrame, so closing the AlignFrame might leave the modal open :( + */ + private static Map alignFrameModalMap = new HashMap<>(); + + protected static void addModal(AlignFrame af, JInternalFrame jif) + { + alignFrameModalMap.put(af, jif); + } + + protected static void closeModal(AlignFrame af) + { + if (!alignFrameModalMap.containsKey(af)) + { + return; + } + JInternalFrame jif = alignFrameModalMap.get(af); + if (jif != null) + { + try + { + jif.setClosed(true); + } catch (PropertyVetoException e) + { + e.printStackTrace(); + } + } + alignFrameModalMap.remove(af); + } + }