Home » Eclipse Projects » Eclipse Platform » simple nested layout question
simple nested layout question [message #317508] |
Thu, 05 July 2007 10:51  |
Eclipse User |
|
|
|
Originally posted by: marc_e.ye.olde.spam.buster.cablespeed.com
All,
fair warning: Very much new with plugin development here.
I want to create a single-line of columnar text that fills horizontally.
What I'm getting with the code below, though, is that the columns are OK but
it doesn't fill out horizontally. i just get the 6 columns and that's it.
how do I get this thing to stretch?
thanks a lot.
Marc
private void createCounterPanel(Composite parent){
Composite counterPanel = new Composite(parent, SWT.BORDER);
GridLayout layout= new GridLayout();
layout.numColumns = 6;
layout.horizontalSpacing = 5;
layout.verticalSpacing = 0;
counterPanel.setLayout(layout);
Label runlabel = new Label(counterPanel, SWT.NONE);
runlabel.setText("Col 1:");
runs = new Text(counterPanel, SWT.READ_ONLY);
runs.setText("Col 2");
runs.setLayoutData(new GridData(GridData.BEGINNING));
Label errorlabel = new Label(counterPanel, SWT.NONE);
errorlabel.setText("Col 3:");
errors = new Text(counterPanel, SWT.READ_ONLY);
errors.setText("Col 4");
errors.setLayoutData(new GridData(GridData.CENTER));
Label faillabel = new Label(counterPanel, SWT.NONE);
faillabel.setText("Col 5:");
fails = new Text(counterPanel, SWT.READ_ONLY);
fails.setText("Col 6");
fails.setLayoutData(new GridData(GridData.END));
}
|
|
|
Re: simple nested layout question [message #317516 is a reply to message #317508] |
Thu, 05 July 2007 13:19   |
Eclipse User |
|
|
|
Originally posted by: eclipse.ahoegger.ch
Hi Marc,
I did not get exactly what you are trying to do, but probably the
following snippet helps:
Composite counterPanel = new Composite(parent, SWT.BORDER);
GridLayout layout = new GridLayout(6, true);
layout.horizontalSpacing = 5;
layout.verticalSpacing = 0;
counterPanel.setLayout(layout);
Label runlabel = new Label(counterPanel, SWT.NONE);
runlabel.setText("Col 1:");
runlabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Text runs = new Text(counterPanel, SWT.READ_ONLY);
runs.setText("Col 2");
runs.setLayoutData(new GridData(GridData.BEGINNING
| GridData.FILL_HORIZONTAL));
Label errorlabel = new Label(counterPanel, SWT.NONE);
errorlabel.setText("Col 3:");
errorlabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Text errors = new Text(counterPanel, SWT.READ_ONLY);
errors.setText("Col 4");
errors.setLayoutData(new GridData(GridData.CENTER
| GridData.FILL_HORIZONTAL));
Label faillabel = new Label(counterPanel, SWT.NONE);
faillabel.setText("Col 5:");
faillabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Text fails = new Text(counterPanel, SWT.READ_ONLY);
fails.setText("Col 6");
fails.setLayoutData(new GridData(GridData.END |
GridData.FILL_HORIZONTAL));
BR Andreas Hoegger
Marc E wrote:
> All,
> fair warning: Very much new with plugin development here.
>
> I want to create a single-line of columnar text that fills horizontally.
> What I'm getting with the code below, though, is that the columns are OK but
> it doesn't fill out horizontally. i just get the 6 columns and that's it.
>
> how do I get this thing to stretch?
>
> thanks a lot.
>
> Marc
>
> private void createCounterPanel(Composite parent){
>
>
> Composite counterPanel = new Composite(parent, SWT.BORDER);
>
>
> GridLayout layout= new GridLayout();
>
> layout.numColumns = 6;
>
> layout.horizontalSpacing = 5;
>
> layout.verticalSpacing = 0;
>
> counterPanel.setLayout(layout);
>
>
>
> Label runlabel = new Label(counterPanel, SWT.NONE);
>
> runlabel.setText("Col 1:");
>
> runs = new Text(counterPanel, SWT.READ_ONLY);
>
> runs.setText("Col 2");
>
> runs.setLayoutData(new GridData(GridData.BEGINNING));
>
>
> Label errorlabel = new Label(counterPanel, SWT.NONE);
>
> errorlabel.setText("Col 3:");
>
> errors = new Text(counterPanel, SWT.READ_ONLY);
>
> errors.setText("Col 4");
>
> errors.setLayoutData(new GridData(GridData.CENTER));
>
>
> Label faillabel = new Label(counterPanel, SWT.NONE);
>
> faillabel.setText("Col 5:");
>
> fails = new Text(counterPanel, SWT.READ_ONLY);
>
> fails.setText("Col 6");
>
> fails.setLayoutData(new GridData(GridData.END));
>
>
>
> }
>
>
|
|
|
Re: simple nested layout question [message #317517 is a reply to message #317516] |
Thu, 05 July 2007 13:41   |
Eclipse User |
|
|
|
Originally posted by: marc_e.ye.olde.spam.buster.cablespeed.com
Thanks for responding Andreas. the best way to describe what i'm trying to
do is to look at the junit view, wiht the runs/failures/errors stuff. when
you stretch the view, that "row" stretches with it. but in my snippet there,
the columns always stay fixed; i.e. they do not expand to fill the space.
I did indeed try your suggestion, but it results in the same behavior. any
other ideas?
thanks so much.
Marc
"Andreas Michael Hoegger" <eclipse@ahoegger.ch> wrote in message
news:f6j96j$9e5$1@build.eclipse.org...
> Hi Marc,
> I did not get exactly what you are trying to do, but probably the
> following snippet helps:
>
> Composite counterPanel = new Composite(parent, SWT.BORDER);
> GridLayout layout = new GridLayout(6, true);
> layout.horizontalSpacing = 5;
> layout.verticalSpacing = 0;
> counterPanel.setLayout(layout);
>
> Label runlabel = new Label(counterPanel, SWT.NONE);
> runlabel.setText("Col 1:");
> runlabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
>
> Text runs = new Text(counterPanel, SWT.READ_ONLY);
> runs.setText("Col 2");
> runs.setLayoutData(new GridData(GridData.BEGINNING
> | GridData.FILL_HORIZONTAL));
>
> Label errorlabel = new Label(counterPanel, SWT.NONE);
> errorlabel.setText("Col 3:");
> errorlabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
>
> Text errors = new Text(counterPanel, SWT.READ_ONLY);
> errors.setText("Col 4");
> errors.setLayoutData(new GridData(GridData.CENTER
> | GridData.FILL_HORIZONTAL));
>
> Label faillabel = new Label(counterPanel, SWT.NONE);
> faillabel.setText("Col 5:");
> faillabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
>
> Text fails = new Text(counterPanel, SWT.READ_ONLY);
> fails.setText("Col 6");
> fails.setLayoutData(new GridData(GridData.END |
> GridData.FILL_HORIZONTAL));
>
> BR Andreas Hoegger
>
> Marc E wrote:
>> All,
>> fair warning: Very much new with plugin development here.
>>
>> I want to create a single-line of columnar text that fills horizontally.
>> What I'm getting with the code below, though, is that the columns are OK
>> but it doesn't fill out horizontally. i just get the 6 columns and that's
>> it.
>>
>> how do I get this thing to stretch?
>>
>> thanks a lot.
>>
>> Marc
>>
>> private void createCounterPanel(Composite parent){
>>
>>
>> Composite counterPanel = new Composite(parent, SWT.BORDER);
>>
>>
>> GridLayout layout= new GridLayout();
>>
>> layout.numColumns = 6;
>>
>> layout.horizontalSpacing = 5;
>>
>> layout.verticalSpacing = 0;
>>
>> counterPanel.setLayout(layout);
>>
>>
>>
>> Label runlabel = new Label(counterPanel, SWT.NONE);
>>
>> runlabel.setText("Col 1:");
>>
>> runs = new Text(counterPanel, SWT.READ_ONLY);
>>
>> runs.setText("Col 2");
>>
>> runs.setLayoutData(new GridData(GridData.BEGINNING));
>>
>>
>> Label errorlabel = new Label(counterPanel, SWT.NONE);
>>
>> errorlabel.setText("Col 3:");
>>
>> errors = new Text(counterPanel, SWT.READ_ONLY);
>>
>> errors.setText("Col 4");
>>
>> errors.setLayoutData(new GridData(GridData.CENTER));
>>
>>
>> Label faillabel = new Label(counterPanel, SWT.NONE);
>>
>> faillabel.setText("Col 5:");
>>
>> fails = new Text(counterPanel, SWT.READ_ONLY);
>>
>> fails.setText("Col 6");
>>
>> fails.setLayoutData(new GridData(GridData.END));
>>
>>
>>
>> }
>>
|
|
|
Re: simple nested layout question [message #317537 is a reply to message #317517] |
Fri, 06 July 2007 08:17   |
Eclipse User |
|
|
|
Originally posted by: eclipse.ahoegger.ch
Hi Marc,
in my example the Grid is spanned over the whole Composite. I assume
your parent (Composite) is not spanned in it's parent Composite.
Try the whole snippet:
----------------------------
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class GridLayoutSnippet
{
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Composite counterPanel = new Composite(shell, SWT.BORDER);
GridLayout layout = new GridLayout(6, true);
layout.horizontalSpacing = 5;
layout.verticalSpacing = 0;
counterPanel.setLayout(layout);
Label runlabel = new Label(counterPanel, SWT.NONE);
runlabel.setText("Col 1:");
runlabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Text runs = new Text(counterPanel, SWT.READ_ONLY);
runs.setText("Col 2");
runs.setLayoutData(new GridData(GridData.BEGINNING
| GridData.FILL_HORIZONTAL));
Label errorlabel = new Label(counterPanel, SWT.NONE);
errorlabel.setText("Col 3:");
errorlabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Text errors = new Text(counterPanel, SWT.READ_ONLY);
errors.setText("Col 4");
errors.setLayoutData(new GridData(GridData.CENTER
| GridData.FILL_HORIZONTAL));
Label faillabel = new Label(counterPanel, SWT.NONE);
faillabel.setText("Col 5:");
faillabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Text fails = new Text(counterPanel, SWT.READ_ONLY);
fails.setText("Col 6");
fails.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
------------------------------
BR Andreas Hoegger
Marc E wrote:
> Thanks for responding Andreas. the best way to describe what i'm trying to
> do is to look at the junit view, wiht the runs/failures/errors stuff. when
> you stretch the view, that "row" stretches with it. but in my snippet there,
> the columns always stay fixed; i.e. they do not expand to fill the space.
>
> I did indeed try your suggestion, but it results in the same behavior. any
> other ideas?
>
> thanks so much.
>
> Marc
>
> "Andreas Michael Hoegger" <eclipse@ahoegger.ch> wrote in message
> news:f6j96j$9e5$1@build.eclipse.org...
>> Hi Marc,
>> I did not get exactly what you are trying to do, but probably the
>> following snippet helps:
>>
>> Composite counterPanel = new Composite(parent, SWT.BORDER);
>> GridLayout layout = new GridLayout(6, true);
>> layout.horizontalSpacing = 5;
>> layout.verticalSpacing = 0;
>> counterPanel.setLayout(layout);
>>
>> Label runlabel = new Label(counterPanel, SWT.NONE);
>> runlabel.setText("Col 1:");
>> runlabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
>>
>> Text runs = new Text(counterPanel, SWT.READ_ONLY);
>> runs.setText("Col 2");
>> runs.setLayoutData(new GridData(GridData.BEGINNING
>> | GridData.FILL_HORIZONTAL));
>>
>> Label errorlabel = new Label(counterPanel, SWT.NONE);
>> errorlabel.setText("Col 3:");
>> errorlabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
>>
>> Text errors = new Text(counterPanel, SWT.READ_ONLY);
>> errors.setText("Col 4");
>> errors.setLayoutData(new GridData(GridData.CENTER
>> | GridData.FILL_HORIZONTAL));
>>
>> Label faillabel = new Label(counterPanel, SWT.NONE);
>> faillabel.setText("Col 5:");
>> faillabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
>>
>> Text fails = new Text(counterPanel, SWT.READ_ONLY);
>> fails.setText("Col 6");
>> fails.setLayoutData(new GridData(GridData.END |
>> GridData.FILL_HORIZONTAL));
>>
>> BR Andreas Hoegger
>>
>> Marc E wrote:
>>> All,
>>> fair warning: Very much new with plugin development here.
>>>
>>> I want to create a single-line of columnar text that fills horizontally.
>>> What I'm getting with the code below, though, is that the columns are OK
>>> but it doesn't fill out horizontally. i just get the 6 columns and that's
>>> it.
>>>
>>> how do I get this thing to stretch?
>>>
>>> thanks a lot.
>>>
>>> Marc
>>>
>>> private void createCounterPanel(Composite parent){
>>>
>>>
>>> Composite counterPanel = new Composite(parent, SWT.BORDER);
>>>
>>>
>>> GridLayout layout= new GridLayout();
>>>
>>> layout.numColumns = 6;
>>>
>>> layout.horizontalSpacing = 5;
>>>
>>> layout.verticalSpacing = 0;
>>>
>>> counterPanel.setLayout(layout);
>>>
>>>
>>>
>>> Label runlabel = new Label(counterPanel, SWT.NONE);
>>>
>>> runlabel.setText("Col 1:");
>>>
>>> runs = new Text(counterPanel, SWT.READ_ONLY);
>>>
>>> runs.setText("Col 2");
>>>
>>> runs.setLayoutData(new GridData(GridData.BEGINNING));
>>>
>>>
>>> Label errorlabel = new Label(counterPanel, SWT.NONE);
>>>
>>> errorlabel.setText("Col 3:");
>>>
>>> errors = new Text(counterPanel, SWT.READ_ONLY);
>>>
>>> errors.setText("Col 4");
>>>
>>> errors.setLayoutData(new GridData(GridData.CENTER));
>>>
>>>
>>> Label faillabel = new Label(counterPanel, SWT.NONE);
>>>
>>> faillabel.setText("Col 5:");
>>>
>>> fails = new Text(counterPanel, SWT.READ_ONLY);
>>>
>>> fails.setText("Col 6");
>>>
>>> fails.setLayoutData(new GridData(GridData.END));
>>>
>>>
>>>
>>> }
>>>
>
|
|
|
Re: simple nested layout question [message #317554 is a reply to message #317508] |
Fri, 06 July 2007 14:16  |
Eclipse User |
|
|
|
Originally posted by: eclipse5.rizzoweb.com
Marc E wrote:
> All,
> fair warning: Very much new with plugin development here.
>
> I want to create a single-line of columnar text that fills horizontally.
> What I'm getting with the code below, though, is that the columns are OK but
> it doesn't fill out horizontally. i just get the 6 columns and that's it.
>
The GridLayout of your Composite controls the controls within it, but,
the overall size of the Composite is controlled by the layout of its
parent (and whatever layout data you assign to the Composite).
For example, if you put your composite in another whose layout is
GridLayout, and set a GridData on your Composite to fill horizontally.
This article may help:
http://www.eclipse.org/articles/Article-Understanding-Layout s/Understanding-Layouts.htm
Hope this helps,
Eric
|
|
|
Goto Forum:
Current Time: Fri Jul 18 02:08:11 EDT 2025
Powered by FUDForum. Page generated in 0.07177 seconds
|