grouplayout layouting problem

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

grouplayout layouting problem

Postby mkleint » Fri Jun 11, 2010 4:53 am

Hello,

see screenshot for the layouting problem. it looks ok on the test/preview, but in the running code the layout is wrong then.

here's the layout code snippet:

Code: Select all
       GroupLayout gl_container = new GroupLayout(container);
        gl_container.setHorizontalGroup(
            gl_container.createParallelGroup(GroupLayout.LEADING)
                .add(gl_container.createSequentialGroup()
                    .addContainerGap()
                    .add(gl_container.createParallelGroup(GroupLayout.TRAILING)
                        .add(tree, GroupLayout.DEFAULT_SIZE, 566, Short.MAX_VALUE)
                        .add(gl_container.createSequentialGroup()
                            .add(gl_container.createParallelGroup(GroupLayout.LEADING)
                                .add(gl_container.createParallelGroup(GroupLayout.LEADING, false)
                                    .add(lblSecurityRealm, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .add(lblPassword)
                                    .add(lblUsername))
                                .add(lblClientCertificate)
                                .add(lblPassphrase))
                            .addPreferredGap(LayoutStyle.RELATED)
                            .add(gl_container.createParallelGroup(GroupLayout.LEADING)
                                .add(txtPassword, GroupLayout.DEFAULT_SIZE, 143, GroupLayout.PREFERRED_SIZE)
                                .add(txtSecurityRealm, GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                                .add(gl_container.createSequentialGroup()
                                    .add(gl_container.createParallelGroup(GroupLayout.LEADING)
                                        .add(gl_container.createSequentialGroup()
                                            .add(txtUsername, GroupLayout.PREFERRED_SIZE, 143, GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(LayoutStyle.RELATED)
                                            .add(lblHint))
                                        .add(txtClientCertificate, GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE))
                                    .addPreferredGap(LayoutStyle.RELATED)
                                    .add(btnClientCertificate))
                                .add(txtPassphrase, GroupLayout.PREFERRED_SIZE, 143, GroupLayout.PREFERRED_SIZE)))
                        .add(GroupLayout.LEADING, label))
                    .addContainerGap())
        );
        gl_container.setVerticalGroup(
            gl_container.createParallelGroup(GroupLayout.LEADING)
                .add(gl_container.createSequentialGroup()
                    .addContainerGap()
                    .add(gl_container.createParallelGroup(GroupLayout.BASELINE)
                        .add(lblSecurityRealm)
                        .add(txtSecurityRealm, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.RELATED)
                    .add(gl_container.createParallelGroup(GroupLayout.BASELINE)
                        .add(lblUsername)
                        .add(txtUsername, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .add(lblHint))
                    .addPreferredGap(LayoutStyle.RELATED)
                    .add(gl_container.createParallelGroup(GroupLayout.BASELINE)
                        .add(lblPassword)
                        .add(txtPassword, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.RELATED)
                    .add(gl_container.createParallelGroup(GroupLayout.BASELINE)
                        .add(btnClientCertificate)
                        .add(txtClientCertificate, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .add(lblClientCertificate, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.RELATED)
                    .add(gl_container.createParallelGroup(GroupLayout.BASELINE)
                        .add(lblPassphrase)
                        .add(txtPassphrase, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .add(23)
                    .add(label)
                    .addPreferredGap(LayoutStyle.RELATED)
                    .add(tree, GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
                    .addContainerGap())
        );
        gl_container.linkSize(new Control[] {txtUsername, txtPassword, txtPassphrase}, GroupLayout.HORIZONTAL);
        container.setLayout(gl_container);


Best regards

Milos Kleint
Attachments
instant2.png
instant2.png (70.8 KiB) Viewed 293 times
mkleint
 
Posts: 14
Joined: Wed Mar 31, 2010 12:17 pm

Re: grouplayout layouting problem

Postby mkleint » Fri Jun 11, 2010 5:37 am

please note that this looks similar to the problem described in this thread, but this time with button, not text - viewtopic.php?f=1&t=4871

I'm using the version of grouplayout that fixed the text baseline problem..
mkleint
 
Posts: 14
Joined: Wed Mar 31, 2010 12:17 pm

Re: grouplayout layouting problem

Postby Alexander.Mitin » Fri Jun 11, 2010 8:59 am

Could you please provide a self-contained test case for the problem?
Alexander Mitin
Alexander.Mitin
Moderator
 
Posts: 155
Joined: Fri Jan 19, 2007 3:57 am

Re: grouplayout layouting problem

Postby mkleint » Sun Jun 13, 2010 12:18 pm

attached is the whole workspace with an eclipse plugin that provides an action in main menu.
Attachments
baseline-problem.zip
(133.62 KiB) Downloaded 8 times
mkleint
 
Posts: 14
Joined: Wed Mar 31, 2010 12:17 pm

Re: grouplayout layouting problem

Postby mkleint » Tue Jun 15, 2010 12:44 am

another problem I keep on struggling with is listViewer. No matter what I do, I never see vertical scrollbar when there is more content than current view. The "over-the-top" values are just hidden outside of the visible view bounds.

I haven't seen many threads dealing with grouplayout. Am I the only one using it? I'm used to it from Swing/Netbeans, but the swt variant seems to be more buggy and harder to work with.
mkleint
 
Posts: 14
Joined: Wed Mar 31, 2010 12:17 pm

Re: grouplayout layouting problem

Postby Alexander.Mitin » Tue Jun 15, 2010 9:01 am

For baseline problem we don't think that we have much to do. The problem is that WizardDialog doesn't do page layout after the page is visible -- it does page layout when components are not visible yet. But Cocoa API returns invalid baseline positions for invisible native Cocoa components. The possible workaround is to manually layout the page after it shown, for example by overridden WizardDialog.create() method.

As for ListViewer, why not to just use SWT.V_SCROLL style while creating the ListViewer instance?
Alexander Mitin
Alexander.Mitin
Moderator
 
Posts: 155
Joined: Fri Jan 19, 2007 3:57 am

Re: grouplayout layouting problem

Postby Eric Clayberg » Tue Jun 15, 2010 9:57 am

mkleint wrote:another problem I keep on struggling with is listViewer. No matter what I do, I never see vertical scrollbar when there is more content than current view. The "over-the-top" values are just hidden outside of the visible view bounds.

Issues like that should be posted to the Eclipse SWT newsgroup.

mkleint wrote:I haven't seen many threads dealing with grouplayout. Am I the only one using it? I'm used to it from Swing/Netbeans, but the swt variant seems to be more buggy and harder to work with.

Most SWT developers would tend to use the native SWT GridLayout by default as it is generally the best layout available for doing almost anything form based. Second to GridLayout would be the native SWT FormLayout which is a generic constraint-based layout. It provides more freedom than GridLayout at the expense of considerable more complexity. GroupLayout is more complex that either GridLayout or FormLayout and generates (IMO) very difficult to understand code. The main reason we even support GroupLayout under SWT is to support porting existing GroupLayout-based Swing code to SWT. I suppose it is also there as an option for people familiar and happy with it under Swing who want to use it under SWT. For a new SWT users with no prior Swing experience with it, it would be my last choice. The end result is that I am only aware of a handful of people who are actually using it (out of many tens of thousands of users).
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: grouplayout layouting problem

Postby mkleint » Tue Jun 15, 2010 11:56 pm

Eric Clayberg wrote:
mkleint wrote:I haven't seen many threads dealing with grouplayout. Am I the only one using it? I'm used to it from Swing/Netbeans, but the swt variant seems to be more buggy and harder to work with.

Most SWT developers would tend to use the native SWT GridLayout by default as it is generally the best layout available for doing almost anything form based. Second to GridLayout would be the native SWT FormLayout which is a generic constraint-based layout. It provides more freedom than GridLayout at the expense of considerable more complexity. GroupLayout is more complex that either GridLayout or FormLayout and generates (IMO) very difficult to understand code. The main reason we even support GroupLayout under SWT is to support porting existing GroupLayout-based Swing code to SWT. I suppose it is also there as an option for people familiar and happy with it under Swing who want to use it under SWT. For a new SWT users with no prior Swing experience with it, it would be my last choice. The end result is that I am only aware of a handful of people who are actually using it (out of many tens of thousands of users).


Unfortunately at least on Mac the GridLayout doesn't do baseline alignment. It's ok when you have just label and text on one line, but when you throw in a button or checkbox, the text is misaligned with both the label and checkbox by about 1 or 2 pixels. I haven't tried formlayout yet.
Additionally grouplayout's symbolic margins and indents shall translate to different values on each platform (AFAIK). Does gridlayout do the same?
mkleint
 
Posts: 14
Joined: Wed Mar 31, 2010 12:17 pm

Re: grouplayout layouting problem

Postby mkleint » Wed Jun 16, 2010 12:00 am

Alexander.Mitin wrote:For baseline problem we don't think that we have much to do. The problem is that WizardDialog doesn't do page layout after the page is visible -- it does page layout when components are not visible yet. But Cocoa API returns invalid baseline positions for invisible native Cocoa components. The possible workaround is to manually layout the page after it shown, for example by overridden WizardDialog.create() method.


It's a bit of a hassle to use then, but I guess I can live with that. That's for taking time and explaining the problem.

Alexander.Mitin wrote:As for ListViewer, why not to just use SWT.V_SCROLL style while creating the ListViewer instance?

Thanks, that did it. I'm wondering if that shall not be the default for newly generated listviewers. I don't see much use in non scrolbared list. If it's already the default and I was stupid enough to remove it, I apologize.
mkleint
 
Posts: 14
Joined: Wed Mar 31, 2010 12:17 pm

Re: grouplayout layouting problem

Postby Eric Clayberg » Fri Jun 18, 2010 2:07 pm

In the latest build, we have added SWT.V_SCROLL to the default code gen for ListViewers.
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 2 guests