setBounds(xPos, yPos, 900, 650);
}
+ // start dialogue queue for single dialogues
+ startDialogQueue();
+
if (!Platform.isJS())
/**
* Java only
if (Platform.isJS())
{
- // emulate a problem
- String a = null;
- int l = a.length();
-
// used for jalviewjsTest
jalview.bin.Console.info("JALVIEWJS: CREATED DESKTOP");
}
/**
* pause the queue
*/
- private java.util.concurrent.Semaphore block = new Semaphore(0);
+ private Semaphore block = new Semaphore(0);
private static groovy.ui.Console groovyConsole;
{
if (dialogPause)
{
- try
- {
- block.acquire();
- } catch (InterruptedException x)
- {
- }
+ acquireDialogQueue();
}
if (instance == null)
{
});
}
+ 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;
}
/**
{
Desktop.instance.closeAll_actionPerformed(null);
Desktop.instance.setVisible(false);
- Desktop.instance.dispose();
+ Desktop us = Desktop.instance;
Desktop.instance = null;
+ // call dispose in a separate thread - try to avoid indirect deadlocks
+ new Thread(new Runnable() {
+ @Override
+ public void run()
+ {
+ ExecutorService dex = us.dialogExecutor;
+ if (dex!=null) {
+ dex.shutdownNow();
+ us.dialogExecutor=null;
+ us.block.drainPermits();
+ }
+ us.dispose();
+ }
+ }).start();
+ }
+ }
+
+ /**
+ * 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();
}
}