Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Managed Forms, SectionPart and some serious confusion on my part...
Managed Forms, SectionPart and some serious confusion on my part... [message #464096] Fri, 23 February 2007 18:56 Go to next message
Eclipse UserFriend
Originally posted by: shawn.mitchell.q1labs.com

I can't seem to find any good examples on using managed forms; all the
ones I find all seem to concentrate on creating controls rather than on
the load/edit/save cycle, hence my confusion.

Here's what I've done:

1. I created a class that inherits FormEditor;
2. I created a class which inherits FormPage; this gets added by the
FormEditor;
3. I created a class that inherits SectionPart which, in its
constructor, creates a bunch of controls which I save as members of my
class.
4. I addPart the section parts to the managed form, with the managed
form's form's body (getManagedForm().getForm().getBody()) as the parent
and its toolkit as the toolkit.

This all seems to work great. The controls show up fine if I just run it
as-is. However...

If I try to access the control members outside of the function they are
created in, they are all null. I hooked up a dispose listener and they
aren't getting disposed (they show up on the form, after all), but all
my member variables mysteriously get set to null after that creation
function returns.

Does this weirdness sound familiar to anyone? Am I missing something
obvious?

Thanks,
mitch
Re: Managed Forms, SectionPart and some serious confusion on my part... [message #464142 is a reply to message #464096] Mon, 26 February 2007 14:41 Go to previous messageGo to next message
Eclipse UserFriend
mitch wrote:
> I can't seem to find any good examples on using managed forms; all the
> ones I find all seem to concentrate on creating controls rather than on
> the load/edit/save cycle, hence my confusion.
>
> Here's what I've done:
>
> 1. I created a class that inherits FormEditor;
> 2. I created a class which inherits FormPage; this gets added by the
> FormEditor;
> 3. I created a class that inherits SectionPart which, in its
> constructor, creates a bunch of controls which I save as members of my
> class.
> 4. I addPart the section parts to the managed form, with the managed
> form's form's body (getManagedForm().getForm().getBody()) as the parent
> and its toolkit as the toolkit.
>
> This all seems to work great. The controls show up fine if I just run it
> as-is. However...
>
> If I try to access the control members outside of the function they are
> created in, they are all null. I hooked up a dispose listener and they
> aren't getting disposed (they show up on the form, after all), but all
> my member variables mysteriously get set to null after that creation
> function returns.
>
> Does this weirdness sound familiar to anyone? Am I missing something
> obvious?
>
> Thanks,
> mitch

Can you post a sample? Are the values null or are the variables
actually not there/visible when you look from outside the function they
are created in. Are your member variables the values in the widgets
themselves or is there a backing model of some sort? Are you trying to
reach across a package or plugin boundary when they come up null? It
could be a matter of setting the visibility in the runtime tab of the
plugin/manifest editor. If you step through the code with the debugger
can you see values getting set and then disappearing?

-
Steve
Re: Managed Forms, SectionPart and some serious confusion on my part... [message #464147 is a reply to message #464142] Mon, 26 February 2007 16:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: shawn.mitchell.q1labs.com

Steve Blass wrote:
> mitch wrote:
>> I can't seem to find any good examples on using managed forms; all the
>> ones I find all seem to concentrate on creating controls rather than
>> on the load/edit/save cycle, hence my confusion.
>>
>> Here's what I've done:
>>
>> 1. I created a class that inherits FormEditor;
>> 2. I created a class which inherits FormPage; this gets added by the
>> FormEditor;
>> 3. I created a class that inherits SectionPart which, in its
>> constructor, creates a bunch of controls which I save as members of my
>> class.
>> 4. I addPart the section parts to the managed form, with the managed
>> form's form's body (getManagedForm().getForm().getBody()) as the
>> parent and its toolkit as the toolkit.
>>
>> This all seems to work great. The controls show up fine if I just run
>> it as-is. However...
>>
>> If I try to access the control members outside of the function they
>> are created in, they are all null. I hooked up a dispose listener and
>> they aren't getting disposed (they show up on the form, after all),
>> but all my member variables mysteriously get set to null after that
>> creation function returns.
>>
>> Does this weirdness sound familiar to anyone? Am I missing something
>> obvious?
>>
>> Thanks,
>> mitch
>
> Can you post a sample? Are the values null or are the variables
> actually not there/visible when you look from outside the function they
> are created in. Are your member variables the values in the widgets
> themselves or is there a backing model of some sort? Are you trying to
> reach across a package or plugin boundary when they come up null? It
> could be a matter of setting the visibility in the runtime tab of the
> plugin/manifest editor. If you step through the code with the debugger
> can you see values getting set and then disappearing?
>
> -
> Steve

Well, everything is null. There are no visibility problems, etc; stuff
just "goes away". If I create my controls like this in my
SectionPart-derived class:

this.textName = toolkit.createText(sectionClient,
getProperty(IDevicePropertyKeys.DEVICE_CONFIG_KEY_NAME), SWT.BORDER);
this.textName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
this.textName.setTextLimit(50);
this.textName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e)
{ setProperty(IDevicePropertyKeys.DEVICE_CONFIG_KEY_NAME,
((Text)(e.widget)).getText());
markDirty();
}
});

This all works fine. But if I leave this function and try to call
another function on the same instance, the value of this.textName is
null. Notice how I had to set up my ModifyListener to use
((Text)(e.widget)).getText() also; if I try to use textName in there it
is also null.

I've worked around this (by casting the handed-in widget, etc) but this
is seriously weird to me. I'm no longer stuck, but I am desperately
puzzled as to this behaviour.

I've also printed out this.toString() at various points to make sure it
is the same instance all the time, and it is.

Thanks,
mitch
Re: Managed Forms, SectionPart and some serious confusion on my part... [message #464185 is a reply to message #464147] Tue, 27 February 2007 01:52 Go to previous message
Eclipse UserFriend
You got me on the nulls, I don't know the answer.
-
Steve


mitch wrote:
> Steve Blass wrote:
>
>> mitch wrote:
>>
>>> I can't seem to find any good examples on using managed forms; all
>>> the ones I find all seem to concentrate on creating controls rather
>>> than on the load/edit/save cycle, hence my confusion.
>>>
>>> Here's what I've done:
>>>
>>> 1. I created a class that inherits FormEditor;
>>> 2. I created a class which inherits FormPage; this gets added by the
>>> FormEditor;
>>> 3. I created a class that inherits SectionPart which, in its
>>> constructor, creates a bunch of controls which I save as members of
>>> my class.
>>> 4. I addPart the section parts to the managed form, with the managed
>>> form's form's body (getManagedForm().getForm().getBody()) as the
>>> parent and its toolkit as the toolkit.
>>>
>>> This all seems to work great. The controls show up fine if I just run
>>> it as-is. However...
>>>
>>> If I try to access the control members outside of the function they
>>> are created in, they are all null. I hooked up a dispose listener and
>>> they aren't getting disposed (they show up on the form, after all),
>>> but all my member variables mysteriously get set to null after that
>>> creation function returns.
>>>
>>> Does this weirdness sound familiar to anyone? Am I missing something
>>> obvious?
>>>
>>> Thanks,
>>> mitch
>>
>>
>> Can you post a sample? Are the values null or are the variables
>> actually not there/visible when you look from outside the function
>> they are created in. Are your member variables the values in the
>> widgets themselves or is there a backing model of some sort? Are you
>> trying to reach across a package or plugin boundary when they come up
>> null? It could be a matter of setting the visibility in the runtime
>> tab of the plugin/manifest editor. If you step through the code with
>> the debugger can you see values getting set and then disappearing?
>>
>> -
>> Steve
>
>
> Well, everything is null. There are no visibility problems, etc; stuff
> just "goes away". If I create my controls like this in my
> SectionPart-derived class:
>
> this.textName = toolkit.createText(sectionClient,
> getProperty(IDevicePropertyKeys.DEVICE_CONFIG_KEY_NAME), SWT.BORDER);
> this.textName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
> this.textName.setTextLimit(50);
> this.textName.addModifyListener(new ModifyListener() {
> public void modifyText(ModifyEvent e)
> {
> setProperty(IDevicePropertyKeys.DEVICE_CONFIG_KEY_NAME,
> ((Text)(e.widget)).getText());
> markDirty();
> }
> });
>
> This all works fine. But if I leave this function and try to call
> another function on the same instance, the value of this.textName is
> null. Notice how I had to set up my ModifyListener to use
> ((Text)(e.widget)).getText() also; if I try to use textName in there it
> is also null.
>
> I've worked around this (by casting the handed-in widget, etc) but this
> is seriously weird to me. I'm no longer stuck, but I am desperately
> puzzled as to this behaviour.
>
> I've also printed out this.toString() at various points to make sure it
> is the same instance all the time, and it is.
>
> Thanks,
> mitch
Previous Topic:Opening multiple instances of a view
Next Topic:Iformattingstrategy
Goto Forum:
  


Current Time: Sat Mar 15 21:07:03 EDT 2025

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

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

Back to the top