Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

shell.addListener(SWT.Close .. using JFace?  RSS feed

 
Toby Weston
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,

I setup a SWT based window to capture the close event that clicking the X in the top right corner of the window generates using;



where, ConfirmCloseListener's handleEvent looks like this;


all works great and the user gets a chance to change his/her mind if they click the X.

However,

I can't figure out how to do the same thing with JFace's ApplicationWindow.

I setup an Action which offer's the same message dialog and ok/cancel which works fine when I hook it into a menu or toolbar, but I can't seem to capture the X click.

For example, if in my ApplicationWindow I add;



although the event is captured (the flow goes into ConfirmCloseListener.handleEvent), the shell has already been disposed so I can't offer the user a second chance.

Any tips?

Thanks in advance,
Toby
 
Toby Weston
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you've gotta love google...

http://blogs.bytecode.com.au/glen/2005/10/25/1130195969418.html

and glen!
 
Norberto Adinolfi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply override Window's handleShellCloseEvent method. The Window's implementation closes the shell, so if you want to add a confirmation dialog, you can invoke super.handleShellCloseEvent() if the user clicks the OK button or do nothing if the user clicks the Cancel button.
 
Campbell Ritchie
Sheriff
Posts: 53721
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!