From: James Procter Date: Wed, 21 Jun 2023 11:24:27 +0000 (+0200) Subject: Merge branch 'patch/JAL-4196_structure_viewer_synchronising' into develop X-Git-Tag: Release_2_11_3_0~13^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4a6e033ecbe830a86d77f8910beb90b09522aceb;hp=-c;p=jalview.git Merge branch 'patch/JAL-4196_structure_viewer_synchronising' into develop --- 4a6e033ecbe830a86d77f8910beb90b09522aceb diff --combined src/jalview/gui/Desktop.java index 99c394b,33ba97c..b901ae4 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@@ -536,9 -536,6 +536,9 @@@ public class Desktop extends jalview.jb setBounds(xPos, yPos, 900, 650); } + // start dialogue queue for single dialogues + startDialogQueue(); + if (!Platform.isJS()) /** * Java only @@@ -626,12 -623,6 +626,12 @@@ } }); desktop.addMouseListener(ma); + + if (Platform.isJS()) + { + // used for jalviewjsTest + jalview.bin.Console.info("JALVIEWJS: CREATED DESKTOP"); + } } /** @@@ -3060,7 -3051,7 +3060,7 @@@ /** * pause the queue */ - private java.util.concurrent.Semaphore block = new Semaphore(0); + private Semaphore block = new Semaphore(0); private static groovy.ui.Console groovyConsole; @@@ -3078,7 -3069,12 +3078,7 @@@ { if (dialogPause) { - try - { - block.acquire(); - } catch (InterruptedException x) - { - } + acquireDialogQueue(); } if (instance == null) { @@@ -3096,41 -3092,12 +3096,41 @@@ }); } + private boolean dialogQueueStarted = false; + public void startDialogQueue() { + if (dialogQueueStarted) + { + return; + } // set the flag so we don't pause waiting for another permit and semaphore // the current task to begin - dialogPause = false; + releaseDialogQueue(); + dialogQueueStarted = true; + } + + public void acquireDialogQueue() + { + try + { + block.acquire(); + dialogPause = true; + } catch (InterruptedException e) + { + jalview.bin.Console.debug("Interruption when acquiring DialogueQueue", + e); + } + } + + public void releaseDialogQueue() + { + if (!dialogPause) + { + return; + } block.release(); + dialogPause = false; } /** @@@ -3165,14 -3132,10 +3165,14 @@@ String title = "View of desktop"; ImageExporter exporter = new ImageExporter(writer, null, TYPE.EPS, title); - try { + try + { exporter.doExport(of, this, width, height, title); - } catch (ImageOutputException ioex) { - jalview.bin.Console.error("Unexpected error whilst writing Jalview desktop snapshot as EPS",ioex); + } catch (ImageOutputException ioex) + { + jalview.bin.Console.error( + "Unexpected error whilst writing Jalview desktop snapshot as EPS", + ioex); } } @@@ -3619,12 -3582,31 +3619,32 @@@ */ public static void closeDesktop() { - if (Desktop.instance != null) { + if (Desktop.instance != null) + { Desktop.instance.closeAll_actionPerformed(null); Desktop.instance.setVisible(false); Desktop.instance.dispose(); Desktop.instance = null; } } + + /** + * 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) + { + if (frame instanceof IProgressIndicator) + { + if (((IProgressIndicator)frame).operationInProgress()) + { + return true; + } + } + } + return operationInProgress(); + } }