Using getters/setters of composites when nested

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Using getters/setters of composites when nested

Postby pijn_mar » Wed Dec 21, 2005 5:28 am

For the first time I'm using composites to "bundle" several widgets for reusability in my application. I did build a form that consists of 3 composites. CompositeA contains compositeB and that one contains compositeC.

How do I use getters/setters of compositeC in composite A? An option in SWT designer is expose control. What does it exactly do and should I look in that area to solve this?

Can someone give a small example or point out a good tutor on the web ?

Thanks in advance!
pijn_mar
 
Posts: 6
Joined: Thu Jun 02, 2005 10:36 pm

Re: Using getters/setters of composites when nested

Postby Eric Clayberg » Wed Dec 21, 2005 7:15 am

pijn_mar wrote:For the first time I'm using composites to "bundle" several widgets for reusability in my application. I did build a form that consists of 3 composites. CompositeA contains compositeB and that one contains compositeC. How do I use getters/setters of compositeC in composite A? An option in SWT designer is expose control. What does it exactly do and should I look in that area to solve this?

Yes.

1) Create CompositeC and add a Button to it.

2) Select the Button and use the Expose control... command to create a getButton() accessor.

3) Create CompositeB and add a CompositeC to it. Note that you can click on the button in the tree.

4) Select the CompositeC and use the Expose control... command to create a getCompositeC() accessor.

5) Create CompositeA and add a CompositeB to it. Note that you can still click on the button in the tree.

6) Change the text property of the button, and you should see code like this:

Code: Select all
    public CompositeA(Composite parent, int style)
    {
        super(parent, style);
        setLayout(new GridLayout());

        compositeB = new CompositeB(this, SWT.NONE);
        compositeB.getCompositeC().getButton().setText("Hello");
    }

You can also use the Expose property... command in a similar manner to expose individual properties rather than entire widgets.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby scott.klein » Wed Dec 28, 2005 4:40 pm

This gives me hope that my current designer issue may have a way of being resolved.

I have a custom composite (Header.java)

I have an abstract class (Report.java) which contains a field of type Header

I have concrete classes that extend Report and create their instance of the Header field (passing specifics into the constructor -- eg, report name, title, etc)

When I go to designer mode on one of the concrete classes I cannot see the Header component at all (it is in the component tree, but not visible in the designer).

Inside the Header custom composite should I expose all the controls in order to make the "visible" in each concrete class? Right now they are just fields, some are private some public.

I have always used 'nested' custom composites and been able to view them with no problems - I just assumed it had something to do with the abstract class in this case. Finally, not to complicate matters but in this particular case my Reports are using many Form style composites (the kind with twisties and also scrollable). Don't think that should make a difference....

Also, I am on the latest 12.25 release
scott.klein
 
Posts: 10
Joined: Thu Sep 22, 2005 1:38 pm

Postby Eric Clayberg » Wed Dec 28, 2005 8:09 pm

scott.klein wrote:I have always used 'nested' custom composites and been able to view them with no problems - I just assumed it had something to do with the abstract class in this case.

Quite likely. Have you tried making your Report class concrete rather than abstract? It sounds like you are trying to set up some form of visual inheritance based on the Report class. For that to work, Designer needs to be able to instantiate the super class of any concrete class you are editing. It can't do that with an abstract class. Your Eclipse ".log" file might contain some hints, if there is a problem with the abstract class.

Without a test case, I can really only guess at to what the issue might be. If you send us a test case, I can probably tell you exactly what the problem is.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest