Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Table grab all area
Table grab all area [message #455637] Wed, 18 May 2005 18:26 Go to next message
Amir Bukhari is currently offline Amir BukhariFriend
Messages: 8
Registered: July 2009
Junior Member
I have a dialog which has the following layout:
TOP:composite1--> (GridLayout)
---> group (GridLayout)
-----> Composite3 (GridLayout 2 colomn)
----> Table (with 100 rows as example)
-----> Composite4 (GridLayout 2 colomn)
----> button 1
----> button 2

most of GridData have the following execpt (button 1,2):
verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
grabExcessVerticalSpace = true;
grabExcessHorizontalSpace = true;
horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;

when opening the dialog with a specific width and height (500,400). and the
table has 100 rows.
the table eat all space inside the group that mean button 1,2 doesn't
appear. another thing the scrollbar also appear parialy (I don't see the end
of it)

please take a look to the file I attached.

PS: I am a new programmer to SWT.


Re: Table grab all area [message #455643 is a reply to message #455637] Wed, 18 May 2005 21:11 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
1) You say that Composite3 (GridLayout 2 column) has two columns but in your
code this composite has only one column:

GridLayout layout = new GridLayout();
layout.numColumns = 1;
comp2.setLayout(layout);

2) Because Composite3/comp2 has only one column, the table is above the
composite with the buttons (Composite4). Because both the table and
Composite4 are FILL, FILL, grab, grab, the layout needs to share the space
between the table and the composite. The algorithm it uses to this is based
on two things a) the minimum size of each guy (which by default is 0) and
the preferred size of each guy (the size required to show everything). The
layout tries to make each widget as close to its preferred size as possible.
Because the table is very big, it ends up taking all the space and the
composite with the buttons gets none. This is the side effect of a mouse
trying to share space with an elephant :-) What can you do to change this?

Option A) do not make the composite with the buttons grab vertical space.
i.e.:

private void createRest() {
comp1 = new Composite(comp2, SWT.NONE);
GridData gridData2 = new GridData();
gridData2.grabExcessHorizontalSpace = true;
//gridData2.grabExcessVerticalSpace = true; // don't do this
gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
comp1.setLayoutData(gridData2);

Option B) set a heightHint on the Table so that its preferred size won't be
so big. i.e.

private void createTable() {
GridData gridData2 = new GridData();
table = new Table(comp2, SWT.FULL_SELECTION);
gridData2.grabExcessHorizontalSpace = true;
gridData2.grabExcessVerticalSpace = true;
gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
gridData2.heightHint = 100; // !!!!!!!!!!!!!!!!!!
table.setLayoutData(gridData2);

Option C) give the composite with the Buttons a minimum size (SWT.DEFAULT
makes the minimum size be the preferred size of the widget, alternately you
can set a pixel value like 100) i.e.:

private void createRest() {
comp1 = new Composite(comp2, SWT.NONE);
GridData gridData2 = new GridData();
gridData2.grabExcessHorizontalSpace = true;
gridData2.grabExcessVerticalSpace = true;
gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
gridData2.minimumHeight = SWT.DEFAULT; //
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
comp1.setLayoutData(gridData2);

Personally, I would go for Option A but it all depends on what effect you
are trying to achieve.


"Amir Bukhari" <ufz6@rz.uni-karlsruhe.de> wrote in message
news:d6g15s$i8s$1@news.eclipse.org...
>I have a dialog which has the following layout:
> TOP:composite1--> (GridLayout)
> ---> group (GridLayout)
> -----> Composite3 (GridLayout 2 colomn)
> ----> Table (with 100 rows as example)
> -----> Composite4 (GridLayout 2 colomn)
> ----> button 1
> ----> button 2
>
> most of GridData have the following execpt (button 1,2):
> verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
> grabExcessVerticalSpace = true;
> grabExcessHorizontalSpace = true;
> horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
>
> when opening the dialog with a specific width and height (500,400). and
> the table has 100 rows.
> the table eat all space inside the group that mean button 1,2 doesn't
> appear. another thing the scrollbar also appear parialy (I don't see the
> end of it)
>
> please take a look to the file I attached.
>
> PS: I am a new programmer to SWT.
>
>
Re: Table grab all area [message #455670 is a reply to message #455643] Thu, 19 May 2005 14:36 Go to previous message
Amir Bukhari is currently offline Amir BukhariFriend
Messages: 8
Registered: July 2009
Junior Member
your are correct. I have used option A) and now it work as I need.

GridLayout is great but also complex, after some experience with it, one
will notice with it we can build
a complex GUI.

thanks,
-Amir
"Veronika Irvine" <veronika_irvine@oti.com> schrieb im Newsbeitrag
news:d6gb2p$vhg$1@news.eclipse.org...
> 1) You say that Composite3 (GridLayout 2 column) has two columns but in
> your code this composite has only one column:
>
Oops that was tip failure.

> GridLayout layout = new GridLayout();
> layout.numColumns = 1;
> comp2.setLayout(layout);
>
> 2) Because Composite3/comp2 has only one column, the table is above the
> composite with the buttons (Composite4). Because both the table and
> Composite4 are FILL, FILL, grab, grab, the layout needs to share the space
> between the table and the composite. The algorithm it uses to this is
> based on two things a) the minimum size of each guy (which by default is
> 0) and the preferred size of each guy (the size required to show
> everything). The layout tries to make each widget as close to its
> preferred size as possible. Because the table is very big, it ends up
> taking all the space and the composite with the buttons gets none. This
> is the side effect of a mouse trying to share space with an elephant :-)
> What can you do to change this?
>
> Option A) do not make the composite with the buttons grab vertical space.
> i.e.:
>
> private void createRest() {
> comp1 = new Composite(comp2, SWT.NONE);
> GridData gridData2 = new GridData();
> gridData2.grabExcessHorizontalSpace = true;
> //gridData2.grabExcessVerticalSpace = true; // don't do this
> gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
> gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
> comp1.setLayoutData(gridData2);
>
> Option B) set a heightHint on the Table so that its preferred size won't
> be so big. i.e.
>
> private void createTable() {
> GridData gridData2 = new GridData();
> table = new Table(comp2, SWT.FULL_SELECTION);
> gridData2.grabExcessHorizontalSpace = true;
> gridData2.grabExcessVerticalSpace = true;
> gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
> gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
> gridData2.heightHint = 100; // !!!!!!!!!!!!!!!!!!
> table.setLayoutData(gridData2);
>
> Option C) give the composite with the Buttons a minimum size (SWT.DEFAULT
> makes the minimum size be the preferred size of the widget, alternately
> you can set a pixel value like 100) i.e.:
>
> private void createRest() {
> comp1 = new Composite(comp2, SWT.NONE);
> GridData gridData2 = new GridData();
> gridData2.grabExcessHorizontalSpace = true;
> gridData2.grabExcessVerticalSpace = true;
> gridData2.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
> gridData2.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
> gridData2.minimumHeight = SWT.DEFAULT; //
> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> comp1.setLayoutData(gridData2);
>
> Personally, I would go for Option A but it all depends on what effect you
> are trying to achieve.
>
>
> "Amir Bukhari" <ufz6@rz.uni-karlsruhe.de> wrote in message
> news:d6g15s$i8s$1@news.eclipse.org...
>>I have a dialog which has the following layout:
>> TOP:composite1--> (GridLayout)
>> ---> group (GridLayout)
>> -----> Composite3 (GridLayout 2 colomn)
>> ----> Table (with 100 rows as
>> example)
>> -----> Composite4 (GridLayout 2
>> colomn)
>> ----> button 1
>> ----> button 2
>>
>> most of GridData have the following execpt (button 1,2):
>> verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
>> grabExcessVerticalSpace = true;
>> grabExcessHorizontalSpace = true;
>> horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
>>
>> when opening the dialog with a specific width and height (500,400). and
>> the table has 100 rows.
>> the table eat all space inside the group that mean button 1,2 doesn't
>> appear. another thing the scrollbar also appear parialy (I don't see the
>> end of it)
>>
>> please take a look to the file I attached.
>>
>> PS: I am a new programmer to SWT.
>>
>>
>
>
Previous Topic:really need help with this one: treeviewer (swt/jface)
Next Topic:Synchronize Scrolling Question
Goto Forum:
  


Current Time: Fri Apr 26 13:55:55 GMT 2024

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

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

Back to the top