final URL dialogImageRef = dialogImage;
final AtomicReference<PropertiesDialog> dialogRef = new AtomicReference<PropertiesDialog>();
final Stack<Runnable> mainThreadTasks = new Stack<Runnable>();
try {
if (EventQueue.isDispatchThread()) {
dialogRef.set(new PropertiesDialog(settings, dialogImageRef, mainThreadTasks));
} else {
EventQueue.invokeLater(new Runnable() {
public void run() {
dialogRef.set(new PropertiesDialog(settings, dialogImageRef, mainThreadTasks));
}
});
}
} catch (final Exception e) {
logger.logp(Level.SEVERE, ExampleBase.class.getClass().toString(), "ExampleBase.getAttributes(settings)",
"Exception", e);
return null;
}
PropertiesDialog dialogCheck = dialogRef.get();
while (dialogCheck == null || dialogCheck.isVisible()) {
try {
// check worker queue for work
while (!mainThreadTasks.isEmpty()) {
mainThreadTasks.pop().run();
}
// go back to sleep for a while
Thread.sleep(50);
} catch (final InterruptedException e) {
logger.warning("Error waiting for dialog system, using defaults.");
}
dialogCheck = dialogRef.get();
}
if (dialogCheck.isCancelled()) {
System.exit(0);
}
return settings;
}