Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Quit menu notification with SWT on Mac OS X ?

Reply
Thread Tools

Quit menu notification with SWT on Mac OS X ?

 
 
Patrick Stadelmann
Guest
Posts: n/a
 
      05-16-2008
Hi,

I have a GUI java application built with SWT that has a single shell. On
Mac OS X, it is packaged as an application bundle, using the Eclipse
export module "Mac OS X application bundle".

I need to perform some actions before the shell is disposed. I found how
to install a handler for the "close" event, sent when the user's click
on the window's close box. However, if he use the Quit menu in the
standard Mac OS X application menu, I don't get notified.

How can I get notified either when the shell is about to be disposed
(whether is due to the Quit menu or to the window's close box), or when
the Quit menu is invoked ?

Thanks,

Patrick
--
Patrick Stadelmann <>
 
Reply With Quote
 
 
 
 
John B. Matthews
Guest
Posts: n/a
 
      05-16-2008
In article <Patrick.Stadelmann->,
Patrick Stadelmann <> wrote:

> Hi,
>
> I have a GUI java application built with SWT that has a single shell. On
> Mac OS X, it is packaged as an application bundle, using the Eclipse
> export module "Mac OS X application bundle".
>
> I need to perform some actions before the shell is disposed. I found how
> to install a handler for the "close" event, sent when the user's click
> on the window's close box. However, if he use the Quit menu in the
> standard Mac OS X application menu, I don't get notified.
>
> How can I get notified either when the shell is about to be disposed
> (whether is due to the Quit menu or to the window's close box), or when
> the Quit menu is invoked ?
>
> Thanks,
>
> Patrick


What version of Eclipse?

You'll need to implement java.awt.event.WindowListener and possibly
com.apple.eawt.ApplicationListener.

The platform will handle Preferences flush().

John
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
 
Reply With Quote
 
 
 
 
Patrick Stadelmann
Guest
Posts: n/a
 
      05-16-2008
In article <nospam->,
"John B. Matthews" <> wrote:

> What version of Eclipse?


I'm using version 3.1.2 / J2SE 1.4.2.

> You'll need to implement java.awt.event.WindowListener and possibly
> com.apple.eawt.ApplicationListener.


Isn't this for use with AWT ? I didn't find equivalents for SWT...

Thanks for your reply,

Patrick
--
Patrick Stadelmann <>
 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      05-16-2008
In article <Patrick.Stadelmann->,
Patrick Stadelmann <> wrote:

> In article <nospam->,
> "John B. Matthews" <> wrote:
>
> > What version of Eclipse?

>
> I'm using version 3.1.2 / J2SE 1.4.2.
>
> > You'll need to implement java.awt.event.WindowListener and possibly
> > com.apple.eawt.ApplicationListener.

>
> Isn't this for use with AWT ? I didn't find equivalents for SWT...
>
> Thanks for your reply,
>
> Patrick


Oops, misread the question! My principal contribution to an SWT project
was the command-line interface I was intrigued to hear that there's
support for building Mac application bundles; I'm still using make...

John
--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews
 
Reply With Quote
 
Patrick Stadelmann
Guest
Posts: n/a
 
      05-17-2008
In article <>,
"Peter Duniho" <> wrote:

> Or put
> another way, if you have something in your Shell that's still useful when
> the application is exiting, that may suggest that whatever that
> "something" is, it belongs elsewhere and/or ought not to be interacting
> with the Shell.


Thanks for your reply. In my case, it holds controls providing status
from a device. Before the application exits, some commands are sent to
the device, and I'd like the Shell to stay around to show the device
status in case an error occurs at this time.

But the Shell could simply be e.g. a text editor window. If the user
quits before saving the modifications, he needs to be notified before
the Shell disappears...

Patric
--
Patrick Stadelmann <>
 
Reply With Quote
 
Patrick Stadelmann
Guest
Posts: n/a
 
      05-17-2008
In article <Patrick.Stadelmann->,
Patrick Stadelmann <> wrote:

> But the Shell could simply be e.g. a text editor window. If the user
> quits before saving the modifications, he needs to be notified before
> the Shell disappears...


BTW, on Windows the listener the for SWT.Close is called when the user
quits the application using Alt-F4.

Patrick
--
Patrick Stadelmann <>
 
Reply With Quote
 
Philipp
Guest
Posts: n/a
 
      05-18-2008
Peter Duniho wrote:
> An alternative would be to revisit the question of whether you really
> need to perform these actions before the Shell instance has been
> disposed.


Note that eclipse itself does it that way (saving workspace on exit). So
it's probably not a blatant antipattern.

Phil
 
Reply With Quote
 
Patrick Stadelmann
Guest
Posts: n/a
 
      05-19-2008
In article <>,
"Peter Duniho" <> wrote:

> However, it's possible that reviewing the Eclipse code would be a way for
> the OP to find some direction with respect to his specific goals.


Indeed, the answer is in the Eclipse source code.

> At the
> very least, it should provide better insight into what exactly happens
> when a user on the Mac chooses "Quit" from the application menu, and what
> sorts of things one can have their code safely do.


Native applications receive a "quit" handler, before any action is
taken, whatever the cause is (system shutting down, quit menu item
selected in the menu bar or in the Dock, AppleEvent received from
another application or from an AppleScript, etc...

Thank you all for your help,

Patrick
--
Patrick Stadelmann <>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where can I download SWT? (SWT homepage) Ramon F Herrera Java 11 12-06-2007 03:18 AM
how to make "quit" at the end of "menu" Gpy Good Ruby 2 05-06-2007 07:24 AM
Tkinter on mac - Binding command-q to quit application Brandon Python 0 11-26-2005 07:34 PM
Swt Programmer SWT Java 0 07-15-2003 03:54 PM
swt action event? soni29 Java 0 07-10-2003 05:55 PM



Advertisments