Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Listening to Shell closing before dispose
Listening to Shell closing before dispose [message #440690] Fri, 06 August 2004 11:38 Go to next message
Eclipse UserFriend
Originally posted by: manu.mopot.de

Hi,

i am searching for a way to be notified when the users closes the shell, but
before any widgets have been disposed in response to that. using a
DisposeListener or a ShellListener both results in a SWTError: widget is
disposed.

any suggestions?

thanks

manu
Re: Listening to Shell closing before dispose [message #440691 is a reply to message #440690] Fri, 06 August 2004 12:25 Go to previous messageGo to next message
william is currently offline williamFriend
Messages: 15
Registered: July 2009
Junior Member
hi

i think that what you want :
shell.addListener(SWT.Close, new Listener(){
public void handleEvent(Event event) {
event.doit=false;
//your code here

}
});
the listener allow to prevent the shell to close
so if you pass througth the listener you'll be notified when the users
attempt to close it


Manu Robledo wrote:

> Hi,

> i am searching for a way to be notified when the users closes the shell, but
> before any widgets have been disposed in response to that. using a
> DisposeListener or a ShellListener both results in a SWTError: widget is
> disposed.

> any suggestions?

> thanks

> manu
Re: Listening to Shell closing before dispose [message #440693 is a reply to message #440691] Fri, 06 August 2004 12:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: manu.mopot.de

hi,

yes that was what i had expected before, but when i do it like this and try
to access any of the Shell?s widgets inside the handleEvent method, i get
the SWTError saying that the widget has been disposed. thats strange...

manu

"william" <william.ferreira@laposte.net> schrieb im Newsbeitrag
news:cevtc8$e8b$1@eclipse.org...
> hi
>
> i think that what you want :
> shell.addListener(SWT.Close, new Listener(){
> public void handleEvent(Event event) {
> event.doit=false;
> //your code here
>
> }
> });
> the listener allow to prevent the shell to close
> so if you pass througth the listener you'll be notified when the users
> attempt to close it
>
>
> Manu Robledo wrote:
>
> > Hi,
>
> > i am searching for a way to be notified when the users closes the shell,
but
> > before any widgets have been disposed in response to that. using a
> > DisposeListener or a ShellListener both results in a SWTError: widget is
> > disposed.
>
> > any suggestions?
>
> > thanks
>
> > manu
>
>
Re: Listening to Shell closing before dispose [message #440695 is a reply to message #440693] Fri, 06 August 2004 13:09 Go to previous messageGo to next message
william is currently offline williamFriend
Messages: 15
Registered: July 2009
Junior Member
yes, that's very strange because i use this code, and after
event.doit=false, i open a messagebox on the shell of the widget...
i don't understand, maybe you can try to clean your project (sometimes it
works) or post a part of your code....

Manu Robledo wrote:

> hi,

> yes that was what i had expected before, but when i do it like this and try
> to access any of the Shell?s widgets inside the handleEvent method, i get
> the SWTError saying that the widget has been disposed. thats strange...

> manu

> "william" <william.ferreira@laposte.net> schrieb im Newsbeitrag
> news:cevtc8$e8b$1@eclipse.org...
> > hi
> >
> > i think that what you want :
> > shell.addListener(SWT.Close, new Listener(){
> > public void handleEvent(Event event) {
> > event.doit=false;
> > //your code here
> >
> > }
> > });
> > the listener allow to prevent the shell to close
> > so if you pass througth the listener you'll be notified when the users
> > attempt to close it
> >
> >
> > Manu Robledo wrote:
> >
> > > Hi,
> >
> > > i am searching for a way to be notified when the users closes the shell,
> but
> > > before any widgets have been disposed in response to that. using a
> > > DisposeListener or a ShellListener both results in a SWTError: widget is
> > > disposed.
> >
> > > any suggestions?
> >
> > > thanks
> >
> > > manu
> >
> >
Re: Listening to Shell closing before dispose [message #440697 is a reply to message #440695] Fri, 06 August 2004 13:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: manu.mopot.de

ok, this is what i am doing:
getShell().addListener(SWT.Close, new Listener() {
public void handleEvent(Event e){
e.doit = false;
System.out.println(e.widget);
}
});

and this is what i get when closing the shell:

Shell {*Disposed*}

this means that
a) the shell is already disposed, when handleEvent() is called and
b) the e.doit doen't have any effect.

could this depend on the OS or the SWT version? i am using win xp and swt
3.0...
hm... no more ideas.

manu


"william" <william.ferreira@laposte.net> schrieb im Newsbeitrag
news:cevvu3$j5v$1@eclipse.org...
> yes, that's very strange because i use this code, and after
> event.doit=false, i open a messagebox on the shell of the widget...
> i don't understand, maybe you can try to clean your project (sometimes it
> works) or post a part of your code....
>
> Manu Robledo wrote:
>
> > hi,
>
> > yes that was what i had expected before, but when i do it like this and
try
> > to access any of the Shell?s widgets inside the handleEvent method, i
get
> > the SWTError saying that the widget has been disposed. thats strange...
>
> > manu
>
> > "william" <william.ferreira@laposte.net> schrieb im Newsbeitrag
> > news:cevtc8$e8b$1@eclipse.org...
> > > hi
> > >
> > > i think that what you want :
> > > shell.addListener(SWT.Close, new Listener(){
> > > public void handleEvent(Event event) {
> > > event.doit=false;
> > > //your code here
> > >
> > > }
> > > });
> > > the listener allow to prevent the shell to close
> > > so if you pass througth the listener you'll be notified when the users
> > > attempt to close it
> > >
> > >
> > > Manu Robledo wrote:
> > >
> > > > Hi,
> > >
> > > > i am searching for a way to be notified when the users closes the
shell,
> > but
> > > > before any widgets have been disposed in response to that. using a
> > > > DisposeListener or a ShellListener both results in a SWTError:
widget is
> > > > disposed.
> > >
> > > > any suggestions?
> > >
> > > > thanks
> > >
> > > > manu
> > >
> > >
>
>
Re: Listening to Shell closing before dispose [message #440699 is a reply to message #440697] Fri, 06 August 2004 13:55 Go to previous messageGo to next message
william is currently offline williamFriend
Messages: 15
Registered: July 2009
Junior Member
i did the same thing in my code and it works...
my code :
progressShell.addListener(SWT.Close, new Listener(){
public void handleEvent(Event event) {
if (v.isAlive()){ //v is a runnable and while he's running, the window
can't be close
//disable close
event.doit=false;
//pop up error
MessageBox msg = new...
}
}
});
the only difference is that i add the listener directly on the shell (not
by using getShell()), so maybe the error come from this call..

(and it's totaly independant of the platform, i'm developping an
application with linux and she works fine with win xp (using SWT3.0))


Manu Robledo wrote:

> ok, this is what i am doing:
> getShell().addListener(SWT.Close, new Listener() {
> public void handleEvent(Event e){
> e.doit = false;
> System.out.println(e.widget);
> }
> });

> and this is what i get when closing the shell:

> Shell {*Disposed*}

> this means that
> a) the shell is already disposed, when handleEvent() is called and
> b) the e.doit doen't have any effect.

> could this depend on the OS or the SWT version? i am using win xp and swt
> 3.0...
> hm... no more ideas.

> manu


> "william" <william.ferreira@laposte.net> schrieb im Newsbeitrag
> news:cevvu3$j5v$1@eclipse.org...
> > yes, that's very strange because i use this code, and after
> > event.doit=false, i open a messagebox on the shell of the widget...
> > i don't understand, maybe you can try to clean your project (sometimes it
> > works) or post a part of your code....
> >
> > Manu Robledo wrote:
> >
> > > hi,
> >
> > > yes that was what i had expected before, but when i do it like this and
> try
> > > to access any of the Shell?s widgets inside the handleEvent method, i
> get
> > > the SWTError saying that the widget has been disposed. thats strange...
> >
> > > manu
> >
> > > "william" <william.ferreira@laposte.net> schrieb im Newsbeitrag
> > > news:cevtc8$e8b$1@eclipse.org...
> > > > hi
> > > >
> > > > i think that what you want :
> > > > shell.addListener(SWT.Close, new Listener(){
> > > > public void handleEvent(Event event) {
> > > > event.doit=false;
> > > > //your code here
> > > >
> > > > }
> > > > });
> > > > the listener allow to prevent the shell to close
> > > > so if you pass througth the listener you'll be notified when the users
> > > > attempt to close it
> > > >
> > > >
> > > > Manu Robledo wrote:
> > > >
> > > > > Hi,
> > > >
> > > > > i am searching for a way to be notified when the users closes the
> shell,
> > > but
> > > > > before any widgets have been disposed in response to that. using a
> > > > > DisposeListener or a ShellListener both results in a SWTError:
> widget is
> > > > > disposed.
> > > >
> > > > > any suggestions?
> > > >
> > > > > thanks
> > > >
> > > > > manu
> > > >
> > > >
> >
> >
Re: Listening to Shell closing before dispose [message #440707 is a reply to message #440690] Fri, 06 August 2004 15:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: amondel1.hotmail.com

I had this same problem a while back and I eventually solved the problem
by creating a component called disposecomment create that as my first
component and have a dispose listener for that...and then it will cause
the listener to be called before any of your components get destroyed

later,
whatsgoingon
Re: Listening to Shell closing before dispose [message #440809 is a reply to message #440707] Fri, 06 August 2004 18:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: manu.mopot.de

thanks, that could be a workaround, but still i won?t be able to prevent the
shell from being disposed and that was what i also have to do...


manu


"whatsgoingon" <amondel1@hotmail.com> schrieb im Newsbeitrag
news:cf07aq$pr$1@eclipse.org...
> I had this same problem a while back and I eventually solved the problem
> by creating a component called disposecomment create that as my first
> component and have a dispose listener for that...and then it will cause
> the listener to be called before any of your components get destroyed
>
> later,
> whatsgoingon
>
Re: Listening to Shell closing before dispose [message #440811 is a reply to message #440809] Fri, 06 August 2004 18:50 Go to previous messageGo to next message
Aaron Mondelblatt is currently offline Aaron MondelblattFriend
Messages: 14
Registered: July 2009
Junior Member
You can't run e.doit= false; then I haven't tried it but that might seem
like a logical next step I would be instrested to see if this works.

Manu Robledo wrote:

> thanks, that could be a workaround, but still i won?t be able to prevent the
> shell from being disposed and that was what i also have to do...


> manu


> "whatsgoingon" <amondel1@hotmail.com> schrieb im Newsbeitrag
> news:cf07aq$pr$1@eclipse.org...
> > I had this same problem a while back and I eventually solved the problem
> > by creating a component called disposecomment create that as my first
> > component and have a dispose listener for that...and then it will cause
> > the listener to be called before any of your components get destroyed
> >
> > later,
> > whatsgoingon
> >
Re: Listening to Shell closing before dispose [message #440888 is a reply to message #440699] Mon, 09 August 2004 14:00 Go to previous message
Eclipse UserFriend
Originally posted by: bram.eresmas.net

Great! I needed this option: preventing from shell closing! And it really
works! Thanks!! :)

bramez


william wrote:

> i did the same thing in my code and it works...
> my code :
> progressShell.addListener(SWT.Close, new Listener(){
> public void handleEvent(Event event) {
> if (v.isAlive()){ //v is a runnable and while he's running, the window
> can't be close
> //disable close
> event.doit=false;
> //pop up error
> MessageBox msg = new...
> }
> }
> });
> the only difference is that i add the listener directly on the shell (not
> by using getShell()), so maybe the error come from this call..

> (and it's totaly independant of the platform, i'm developping an
> application with linux and she works fine with win xp (using SWT3.0))


> Manu Robledo wrote:

> > ok, this is what i am doing:
> > getShell().addListener(SWT.Close, new Listener() {
> > public void handleEvent(Event e){
> > e.doit = false;
> > System.out.println(e.widget);
> > }
> > });

> > and this is what i get when closing the shell:

> > Shell {*Disposed*}

> > this means that
> > a) the shell is already disposed, when handleEvent() is called and
> > b) the e.doit doen't have any effect.

> > could this depend on the OS or the SWT version? i am using win xp and swt
> > 3.0...
> > hm... no more ideas.

> > manu


> > "william" <william.ferreira@laposte.net> schrieb im Newsbeitrag
> > news:cevvu3$j5v$1@eclipse.org...
> > > yes, that's very strange because i use this code, and after
> > > event.doit=false, i open a messagebox on the shell of the widget...
> > > i don't understand, maybe you can try to clean your project (sometimes it
> > > works) or post a part of your code....
> > >
> > > Manu Robledo wrote:
> > >
> > > > hi,
> > >
> > > > yes that was what i had expected before, but when i do it like this and
> > try
> > > > to access any of the Shell?s widgets inside the handleEvent method, i
> > get
> > > > the SWTError saying that the widget has been disposed. thats strange...
> > >
> > > > manu
> > >
> > > > "william" <william.ferreira@laposte.net> schrieb im Newsbeitrag
> > > > news:cevtc8$e8b$1@eclipse.org...
> > > > > hi
> > > > >
> > > > > i think that what you want :
> > > > > shell.addListener(SWT.Close, new Listener(){
> > > > > public void handleEvent(Event event) {
> > > > > event.doit=false;
> > > > > //your code here
> > > > >
> > > > > }
> > > > > });
> > > > > the listener allow to prevent the shell to close
> > > > > so if you pass througth the listener you'll be notified when the
users
> > > > > attempt to close it
> > > > >
> > > > >
> > > > > Manu Robledo wrote:
> > > > >
> > > > > > Hi,
> > > > >
> > > > > > i am searching for a way to be notified when the users closes the
> > shell,
> > > > but
> > > > > > before any widgets have been disposed in response to that. using a
> > > > > > DisposeListener or a ShellListener both results in a SWTError:
> > widget is
> > > > > > disposed.
> > > > >
> > > > > > any suggestions?
> > > > >
> > > > > > thanks
> > > > >
> > > > > > manu
> > > > >
> > > > >
> > >
> > >
Previous Topic:plug-in problem
Next Topic:Vertical Scrolling on an Unknown Height
Goto Forum:
  


Current Time: Sat May 11 00:07:56 GMT 2024

Powered by FUDForum. Page generated in 0.04739 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top