|
Re: JFace Dialog Opened From Action - Retreive values [message #452895 is a reply to message #452892] |
Sat, 26 March 2005 21:02 |
Eclipse User |
|
|
|
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 #452908 is a reply to message #452907] |
Sun, 27 March 2005 22:52 |
Eclipse User |
|
|
|
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());
>>> }
>>>
>>>
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03085 seconds