pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clint Gilbert <clint_gilb...@hms.harvard.edu>
Subject Re: Rough equivalent of Swing JOptionPane.showConfirmDialog
Date Tue, 16 Aug 2011 06:11:29 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I don't have any terribly bright ideas, I'm afraid.  I wanted something
like:

user initiates some process
some stuff happens, including:
ask user a yes/no question
if(answer == yes)
  do one thing
otherwise
  do some other thing

- - basically like Javascript alert()s, but this isn't possible.

So I went with callbacks all over.  In the above example, I'd use two
callbacks for each branch of the conditional.  My app is mostly written
in Scala, and I was able to use some of Scala's features to make the
syntactic burden of callbacks for flow control less onerous.  I'm no
guru, but I made some progress in this regard.

I did run into a bunch of situations where sibling widgets needed to
"communicate" with each other, but I didn't want them to have to know
about each other.  In these cases, an event bus (a pub/sub pattern,
basically) was helpful.  This nicely decoupled important parts of the
app, but this was not without cost:  Chaining callbacks to allow
operations to happen in sequence made the app's logic harder to reason
about, but using the event bus made this even more difficult, as it
required holding a lot more state in my head about what was emitting
what events and what was listening for them.

There are clever techniques like Functional Reactive Programming (
http://lamp.epfl.ch/~imaier/pub/DeprecatingObserversTR2010.pdf ) that
are potentially appealing, but I don't understand them well enough to
implement them yet.


On 08/16/2011 01:24 AM, Chris Bartlett wrote:
> Clint,
> 
> Would you mind sharing how you worked around the lack of a blocking
> Dialog?  Perhaps *something* could be included in Pivot to make it
> easier to work this way given there are equivalents in Swing & SWT,
> and the issue has come up on the mailing lists a few times.
> 
> This might be a use for a Glass Pane type Component within Pivot
> (which came up on the mailing list recently IIRC)
> http://download.oracle.com/javase/tutorial/uiswing/components/rootpane.html#glasspane
> 
> Combined with some host frame, window & focus management and a
> simplified/streamlined/hidden way of creating the listeners, this
> might not be particularly difficult to implement.  I have code that
> does a similar thing in a Pivot app with multiple host frames to show
> an ' app-wide modal' Dialog.
> 
> Chris
> 
> On 16 August 2011 07:21, Clint Gilbert <clint_gilbert@hms.harvard.edu> wrote:
> I asked more or less this question a ways back:
> 
> https://mail-archives.apache.org/mod_mbox/pivot-user/201001.mbox/%3C4B5E581D.2080604@hms.harvard.edu%3E
> 
> The answer, sadly, is no.
> 
> My app - a game with a well-defined workflow - would have been much
> simpler to implement with blocking, synchronous dialogs, but I get the
> feeling apps like that are the minority.
> 
> On 08/12/2011 08:34 PM, Roger L. Whitcomb wrote:
>>>> Im trying to ask a simple Yes or No question of the user (in
>>>> response to trying to close a window), but I need to know the answer
>>>> synchronously in order to know whether to close the window or not.  So,
>>>> in Windows and Swing there is a synchronous dialog that itself does the
>>>> message pump and so it can return when the user clicks the button.  Now,
>>>> I dont see anything like that in Pivot, so Im wondering how one would
>>>> implement such a thing?  Thanks.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *Roger Whitcomb*
>>>>
>>>> Architect, Engineering
>>>>
>>>> *Ingres Corporation***
>>>>
>>>> roger.whitcomb@ingres.com <mailto:roger.whitcomb@ingres.com>
>>>>
>>>>
>>>>
>>>> *PHONE*+1 650.587.5596
>>>>
>>>> *FAX*+1 650.587.5550
>>>>
>>>>
>>>>
>>>> *www.ingres.com* <http://www.ingres.com/>
>>>>
>>>>
>>>>
>>>> This transmission is confidential and intended solely for the use of the
>>>> recipient named above. It may contain confidential, proprietary, or
>>>> legally privileged information. If you are not the intended recipient,
>>>> you are hereby notified that any unauthorized review, use, disclosure or
>>>> distribution is strictly prohibited. If you have received this
>>>> transmission in error, please contact the sender by reply e-mail and
>>>> delete the original transmission and all copies from your system.
>>>>
>>>>
>>>>
> 
>>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk5KChAACgkQ0GFaTS4nYxudZgCgpUZy134A9FTlX9itWjap08gC
b9IAnjd5CymAxhSXLHtC+Cp9wrNGUM/k
=tzuo
-----END PGP SIGNATURE-----

Mime
View raw message