Code Block formatting

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

Code Block formatting

Postby diltonm » Mon Oct 26, 2009 2:39 pm

I recently switched from 6.9 to 7.2 and after creating a new window realized that the formatting was off from the normal Java formatting where the brace starts at the end of a line. Then I checked the following to see why:

Window Builder | SWT | Code Generation Statement generation

So, I like the idea of using blocks to isolate the component/widget/control but the braces starting at the start of a line looks mismatched. Is it possible some comment could be inserted, and not an advertisement but some inert comment like:

Code: Select all
// code block {
    Composite c = new Composite(parent, SWT.NONE);
    c.setLayout(null);
    // dependent component code block {
        Button b = new Button(c, SWT.NONE);
        b.setText("button");
    }
}


Thanks,
Dilton
diltonm
 
Posts: 12
Joined: Sat Apr 04, 2009 7:13 pm

Re: Code Block formatting

Postby Eric Clayberg » Mon Oct 26, 2009 4:53 pm

SWT Designer supports a number of different code formatting options including flat mode and block mode. Those are the same options that were in v6.9 and have been in the product since v1.x more than six years ago.

Image Image

Block mode is meant to visually identify the nesting of components so having the braces line up is very useful. While it would be easy enough to add a single-line comment (/* some comment */), and end-of-line comment (// some comment) as you have shown would not work. I am also not sure what those comments should say (keep in mind that nesting can be to an arbitrary depth), and they would also seem to be a visual distraction.
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

Re: Code Block formatting

Postby diltonm » Tue Oct 27, 2009 7:17 am

Looking at it from my perspective, the code ended up looking different, like something from Windows. So the default must have changed from Flat to Block, I guess, between 6.x and 7.x.

It looks like our only option is to remind each developer to change the setting to Flat when upgrading to 7.2.

Thanks.
diltonm
 
Posts: 12
Joined: Sat Apr 04, 2009 7:13 pm

Re: Code Block formatting

Postby Eric Clayberg » Wed Oct 28, 2009 7:49 am

diltonm wrote:It looks like our only option is to remind each developer to change the setting to Flat when upgrading to 7.2.

In the latest build, we have made Flat mode the default.
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

Re: Code Block formatting

Postby diltonm » Wed Oct 28, 2009 12:04 pm

Eric Clayberg wrote:In the latest build, we have made Flat mode the default.


Thanks Eric!
diltonm
 
Posts: 12
Joined: Sat Apr 04, 2009 7:13 pm

Re: Code Block formatting

Postby Eric Clayberg » Wed Oct 28, 2009 12:35 pm

You're welcome.
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: Google [Bot] and 2 guests