pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clint <clint_gilb...@hms.harvard.edu>
Subject Blocking while a dialog/prompt/alert/sheet is open, like Javascript's alert() ?
Date Tue, 26 Jan 2010 02:49:01 GMT

First of all, thank you to the Pivot creators.  The API is a joy to use
next to the other Java widget toolkits.

Now, my question: Is it possible to achieve behavior like the
Javascript's alert() function with Pivot?  That is, I'd like to put up a
simple yes/no "do something"/"please don't" popup on the screen, and
have the app block - the alert doesn't just block input to other
elements - until the user chooses an option, or closes the popup.  This
is possible in SWT, I don't know about Swing.

This would let me write code like without getting into callback hell:


final boolean shouldDoStuff = shouldWeStuff();



boolean shouldWeStuff()
  final MyBlockingPrompt prompt = new MyBlockingPrompt(
                                       "Should I do XYZ thing",
                                       "Yes, go ahead",
                                       "Please don't");


  return prompt.getSelectedOption() == 0;

I wouldn't mind callback hell so much, but Java's syntax for anonymous
classes is so verbose as to be unreadable, or at least very unpleasant.
 Lots of propagated callback params also make reasoning about an app's
logic harder - for me anyway.

I've tried a few approaches, mostly involving using a
java.util.concurrent.CountdownLatch where countDown() is called using a
DialogCloseHandler, and await() is called after the dialog is opened.
All this does is freeze the UI - I imagine I'm blocking the EDT.
Making the call to Dialog.open() from another thread doesn't have any effect.

I realize what I'm looking for probably goes against all sorts of UI
orthodoxy, but it would make my app about 1000 times easier to
implement, which is most important to me in this specific case.

View raw message