Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » JFace Dialog Opened From Action - Retreive values
JFace Dialog Opened From Action - Retreive values [message #452892] Sat, 26 March 2005 19:49 Go to next message
Dan Sobotincic is currently offline Dan SobotincicFriend
Messages: 7
Registered: July 2009
Junior Member
I have a JFace dialog (extends org.eclipse.jface.dialogs.Dialog) that is
being called from a top level menu created as an Action (implements
IWorkbenchWindowActionDelegate).
I open the dialog in the 'run' method and want to retrieve the values from a
couple fields I created in the dialog inside its createDialogArea method. I
can evaluate if the user hits ok or cancel fine. But when I try to call the
getter methods I created on the dialog to access the screen values I get a
'Text {*Disposed*} message. All the examples I have been able to find say
this should work. Anyone know what I am doing wrong??? I am pasting the
run method code below.

TIA

public void run(IAction action) {
System.out.println("In run");
pdialog = new PolTestParamDialog(window.getShell());
if(pdialog.open() != InputDialog.OK)
return;
System.out.println(pdialog.getPolnumtext());
}
Re: JFace Dialog Opened From Action - Retreive values [message #452895 is a reply to message #452892] Sat, 26 March 2005 21:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lindseygeorge.hotmail.com

This is what I did: Over-rode the okPressed method in the dialog to save
the value to another string variable, and then used a getter method on
this new variable to retrieve the value once the dialog is closed.

Dan Sobotincic wrote:
> I have a JFace dialog (extends org.eclipse.jface.dialogs.Dialog) that is
> being called from a top level menu created as an Action (implements
> IWorkbenchWindowActionDelegate).
> I open the dialog in the 'run' method and want to retrieve the values from a
> couple fields I created in the dialog inside its createDialogArea method. I
> can evaluate if the user hits ok or cancel fine. But when I try to call the
> getter methods I created on the dialog to access the screen values I get a
> 'Text {*Disposed*} message. All the examples I have been able to find say
> this should work. Anyone know what I am doing wrong??? I am pasting the
> run method code below.
>
> TIA
>
> public void run(IAction action) {
> System.out.println("In run");
> pdialog = new PolTestParamDialog(window.getShell());
> if(pdialog.open() != InputDialog.OK)
> return;
> System.out.println(pdialog.getPolnumtext());
> }
>
>
Re: JFace Dialog Opened From Action - Retreive values [message #452907 is a reply to message #452895] Sun, 27 March 2005 18:32 Go to previous messageGo to next message
Dan Sobotincic is currently offline Dan SobotincicFriend
Messages: 7
Registered: July 2009
Junior Member
That worked perfectly. Thanks! I am still curiouis though. Do you know
why the Text object is disposed, but the String variable isn't? Just
curious.
Thanks again for your help.

"Lindsey George" <lindseygeorge@hotmail.com> wrote in message
news:d24no3$cc9$1@news.eclipse.org...
> This is what I did: Over-rode the okPressed method in the dialog to save
> the value to another string variable, and then used a getter method on
> this new variable to retrieve the value once the dialog is closed.
>
> Dan Sobotincic wrote:
> > I have a JFace dialog (extends org.eclipse.jface.dialogs.Dialog) that is
> > being called from a top level menu created as an Action (implements
> > IWorkbenchWindowActionDelegate).
> > I open the dialog in the 'run' method and want to retrieve the values
from a
> > couple fields I created in the dialog inside its createDialogArea
method. I
> > can evaluate if the user hits ok or cancel fine. But when I try to call
the
> > getter methods I created on the dialog to access the screen values I get
a
> > 'Text {*Disposed*} message. All the examples I have been able to find
say
> > this should work. Anyone know what I am doing wrong??? I am pasting
the
> > run method code below.
> >
> > TIA
> >
> > public void run(IAction action) {
> > System.out.println("In run");
> > pdialog = new PolTestParamDialog(window.getShell());
> > if(pdialog.open() != InputDialog.OK)
> > return;
> > System.out.println(pdialog.getPolnumtext());
> > }
> >
> >
Re: JFace Dialog Opened From Action - Retreive values [message #452908 is a reply to message #452907] Sun, 27 March 2005 22:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: doug-list.threepenny.net

The Text object is a control--a little window owned by the operating
system. When the dialog is closed it and all of its children, including
the Text object, are disposed. That is the underlying window created by
the operating system is destroyed. Once the window is gone there's no
way to ask "what did the user type into it", because it's gone.

A String is just a Java object (a sequence of characters). There's no
corresponding operating system object and you never dispose() of a
string. It will remain valid for as long as you have a reference to it
(i.e. some way to access it).

Overriding okPressed lets you copy the contents of the Text object to
the String just before the dialog closes, so from an object that is just
about to be destroyed to one that will last indefinitely.

The names are close enough (String, Text) to be confusing but they're
completely different sorts of objects.

Doug

Dan Sobotincic wrote:
> That worked perfectly. Thanks! I am still curiouis though. Do you know
> why the Text object is disposed, but the String variable isn't? Just
> curious.
> Thanks again for your help.
>
> "Lindsey George" <lindseygeorge@hotmail.com> wrote in message
> news:d24no3$cc9$1@news.eclipse.org...
>
>>This is what I did: Over-rode the okPressed method in the dialog to save
>>the value to another string variable, and then used a getter method on
>>this new variable to retrieve the value once the dialog is closed.
>>
>>Dan Sobotincic wrote:
>>
>>>I have a JFace dialog (extends org.eclipse.jface.dialogs.Dialog) that is
>>>being called from a top level menu created as an Action (implements
>>>IWorkbenchWindowActionDelegate).
>>>I open the dialog in the 'run' method and want to retrieve the values
>
> from a
>
>>>couple fields I created in the dialog inside its createDialogArea
>
> method. I
>
>>>can evaluate if the user hits ok or cancel fine. But when I try to call
>
> the
>
>>>getter methods I created on the dialog to access the screen values I get
>
> a
>
>>>'Text {*Disposed*} message. All the examples I have been able to find
>
> say
>
>>>this should work. Anyone know what I am doing wrong??? I am pasting
>
> the
>
>>>run method code below.
>>>
>>>TIA
>>>
>>> public void run(IAction action) {
>>> System.out.println("In run");
>>> pdialog = new PolTestParamDialog(window.getShell());
>>> if(pdialog.open() != InputDialog.OK)
>>> return;
>>> System.out.println(pdialog.getPolnumtext());
>>> }
>>>
>>>
>
>
>
Re: JFace Dialog Opened From Action - Retreive values [message #452951 is a reply to message #452908] Tue, 29 March 2005 00:57 Go to previous message
Dan Sobotincic is currently offline Dan SobotincicFriend
Messages: 7
Registered: July 2009
Junior Member
Thanks for the detailed explanation! It makes sense now. Thanks again.

"Doug Pearson" <doug-list@threepenny.net> wrote in message
news:d27ia5$874$1@news.eclipse.org...
> The Text object is a control--a little window owned by the operating
> system. When the dialog is closed it and all of its children, including
> the Text object, are disposed. That is the underlying window created by
> the operating system is destroyed. Once the window is gone there's no
> way to ask "what did the user type into it", because it's gone.
>
> A String is just a Java object (a sequence of characters). There's no
> corresponding operating system object and you never dispose() of a
> string. It will remain valid for as long as you have a reference to it
> (i.e. some way to access it).
>
> Overriding okPressed lets you copy the contents of the Text object to
> the String just before the dialog closes, so from an object that is just
> about to be destroyed to one that will last indefinitely.
>
> The names are close enough (String, Text) to be confusing but they're
> completely different sorts of objects.
>
> Doug
>
> Dan Sobotincic wrote:
> > That worked perfectly. Thanks! I am still curiouis though. Do you
know
> > why the Text object is disposed, but the String variable isn't? Just
> > curious.
> > Thanks again for your help.
> >
> > "Lindsey George" <lindseygeorge@hotmail.com> wrote in message
> > news:d24no3$cc9$1@news.eclipse.org...
> >
> >>This is what I did: Over-rode the okPressed method in the dialog to save
> >>the value to another string variable, and then used a getter method on
> >>this new variable to retrieve the value once the dialog is closed.
> >>
> >>Dan Sobotincic wrote:
> >>
> >>>I have a JFace dialog (extends org.eclipse.jface.dialogs.Dialog) that
is
> >>>being called from a top level menu created as an Action (implements
> >>>IWorkbenchWindowActionDelegate).
> >>>I open the dialog in the 'run' method and want to retrieve the values
> >
> > from a
> >
> >>>couple fields I created in the dialog inside its createDialogArea
> >
> > method. I
> >
> >>>can evaluate if the user hits ok or cancel fine. But when I try to
call
> >
> > the
> >
> >>>getter methods I created on the dialog to access the screen values I
get
> >
> > a
> >
> >>>'Text {*Disposed*} message. All the examples I have been able to find
> >
> > say
> >
> >>>this should work. Anyone know what I am doing wrong??? I am pasting
> >
> > the
> >
> >>>run method code below.
> >>>
> >>>TIA
> >>>
> >>> public void run(IAction action) {
> >>> System.out.println("In run");
> >>> pdialog = new PolTestParamDialog(window.getShell());
> >>> if(pdialog.open() != InputDialog.OK)
> >>> return;
> >>> System.out.println(pdialog.getPolnumtext());
> >>> }
> >>>
> >>>
> >
> >
> >
>
Previous Topic:Getting cell editor value
Next Topic:Tooltip for SWT controls
Goto Forum:
  


Current Time: Thu Apr 25 05:02:22 GMT 2024

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

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

Back to the top