1.2.4b : New Code Gen Options Don't Work

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

1.2.4b : New Code Gen Options Don't Work

Postby cebarne2 » Fri Mar 12, 2004 11:04 am

Eclipse: 2.1.2
SWT-Designer: 1.2.4 Beta (March 11th)

In my Designer preferences, I clearly have checked:

"Create every component in its own block"

But, after I laid-out my controls, here's my code:

Code: Select all
public void createPartControl(Composite parent)  {
   Composite thisComposite = new Composite(parent, SWT.NONE);
   thisComposite.setLayout(new GridLayout());
   final Group grpMath = new Group(thisComposite, SWT.NONE);
   grpMath.setText("Math");
   grpMath.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
   final GridLayout gridLayout = new GridLayout();
   gridLayout.numColumns = 6;
   grpMath.setLayout(gridLayout);
   new Text(grpMath, SWT.BORDER);
   final Label lblPlus = new Label(grpMath, SWT.NONE);
   lblPlus.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
   lblPlus.setText("+");
   new Text(grpMath, SWT.BORDER);
   final Label lblEquals = new Label(grpMath, SWT.NONE);
   lblEquals.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
   lblEquals.setText("=");
   final Label lblSum = new Label(grpMath, SWT.RIGHT);
   lblSum.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
   lblSum.setText("0.0");
   final Button cmdSum = new Button(grpMath, SWT.NONE);
   cmdSum.setText("Get Sum");
}


Is this just another bug with Designer and Eclipse 2.1.2?

Thanks
cebarne2
 
Posts: 67
Joined: Tue Sep 23, 2003 10:11 am
Location: Cedar Rapids, IA

Postby raphael » Fri Mar 12, 2004 11:45 am

I think that this has to do with the "Use the existing block style when it can be deduced" setting in the preferences just before the setting you mentioned.

Here is what I believe is happening.

If you have the use existing block style... setting checked:
When you open a file, Designer will look at the file to see which style was used.
If just flat (not block) or just block is used in the file, it will always use that style. Changing the style in the preferences won't matter.
If both styles are used, it will use the style you choose. You can change the style in the middle of editing and it will change any new controls you place.
If neither styles are used (eg. new class), it will use the style you choose. You can change the style in the middle of editing and it will change any new controls you place.

If you want new controls to be a different style, you have to disable the use exisint block style... setting.

I figured out the above from my own testing so I could be wrong on some parts, but it seemed to stay consistent for me.
raphael
 
Posts: 22
Joined: Thu Jan 29, 2004 3:41 pm

Postby Eric Clayberg » Fri Mar 12, 2004 11:56 am

raphael wrote:If you have the use existing block style... setting checked:
When you open a file, Designer will look at the file to see which style was used.
If just flat (not block) or just block is used in the file, it will always use that style. Changing the style in the preferences won't matter.
If both styles are used, it will use the style you choose. You can change the style in the middle of editing and it will change any new controls you place.
If neither styles are used (eg. new class), it will use the style you choose. You can change the style in the middle of editing and it will change any new controls you place.

If you want new controls to be a different style, you have to disable the use exisint block style... setting.

I figured out the above from my own testing so I could be wrong on some parts, but it seemed to stay consistent for me.

Your analysis is exactly correct. The Use existing block style option takes precendence over the Create every component in its own block option. The intent is to keep the code gene style consistent within a window (primarily for aesthic reasons). It looks weird to have a window that uses a mix of the two modes. We figured that folks might wnat to use the new flat mode, but have that only apply to new windows and not effectexisting windows.
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 cebarne2 » Fri Mar 12, 2004 12:04 pm

This was a brand niew view class with no existing SWT code. Only the single "Composite = new Composite" statement. The rest was all generated by SWT from the beginning.

So, how do I have to declare that first Composite to get SWT-Designer to code in blocks?

Thanks,
Chad
cebarne2
 
Posts: 67
Joined: Tue Sep 23, 2003 10:11 am
Location: Cedar Rapids, IA

Postby raphael » Fri Mar 12, 2004 12:30 pm

I found out the following:

In a new ViewPart:

If workbench.jar has been added to your build path:
Designer thinks that a new file is in flat style

If workbench.jar has not been added to your build path:
Designer thinks it is neither block nor flat and you can set it to what you will.

I don't know why changing the build path would make a difference, but it seems to. Maybe because without the jar file you have errors and Designer might read it in differently.

If you want the first control to be block mode, uncheck the top item in the Code Generation page and check the second item. Then place your first control. You can check the top item in the Code Generation page after this and it will now see that the controls are in both styles.
Designer always sees that there is some flat style code in a ViewPart. Maybe this will have to be changed in the future.
raphael
 
Posts: 22
Joined: Thu Jan 29, 2004 3:41 pm

Postby Eric Clayberg » Fri Mar 12, 2004 1:10 pm

cebarne2 wrote:This was a brand niew view class with no existing SWT code. Only the single "Composite = new Composite" statement. The rest was all generated by SWT from the beginning.

Yes...and the template that wizard uses creates the initial Composite in flat mode.

cebarne2 wrote:So, how do I have to declare that first Composite to get SWT-Designer to code in blocks?

Very easy...just turn off the Use existing block style option. If you have Create every component in its own block turned on, it will use blick style no matter what.
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 cebarne2 » Mon Mar 15, 2004 5:35 am

Thanks.

I'm curious. From your studies/feedback/etc, what style do you find most users prefer. I had never worked in the block-style, but warmed-up to it since it helped me organize the code better. So now, as soon as the plug-in seemed to default to the flat style, I found myself scrambling to get back to block style.

What does the overall userbase prefer?
cebarne2
 
Posts: 67
Joined: Tue Sep 23, 2003 10:11 am
Location: Cedar Rapids, IA

Postby Eric Clayberg » Mon Mar 15, 2004 6:02 am

cebarne2 wrote:I'm curious. From your studies/feedback/etc, what style do you find most users prefer. I had never worked in the block-style, but warmed-up to it since it helped me organize the code better. So now, as soon as the plug-in seemed to default to the flat style, I found myself scrambling to get back to block style.

What does the overall userbase prefer?

I don't think there is an overall preference. When we only supported block mode, we got many, many requests for flat mode. I would say that most hand-written code out there is in flat mode (especially anything you find in the Eclipse base), so it was important for us to support that mode. As you suggest, however, block mode does have certain advantages, and many people like that fact that it makes the parent/child relationships much more clear. Ultimately, we want the tool to work equally well in both modes.
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