Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » extra column in TableViewer/Table in EditorPart
extra column in TableViewer/Table in EditorPart [message #459150] Tue, 02 August 2005 17:00 Go to next message
Eclipse UserFriend
Originally posted by: sgollery.cadrc.calpoly.edu

I have a class derived from EditorPart which displays a multi-column
table. When the table first opens, I see the number of columns that I
created, but if I manually resize the window, making it wider, I see an
empty column that fills the remaining space.

The code I'm using is pretty close to the sample from the book "Java
Developers Guide to Eclipse" and looks like this:

public void createPartControl(Composite parent) {
Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL |
SWT.MULTI | SWT.FULL_SELECTION);
TableLayout layout = new TableLayout();
table.setLayout(layout);
table.setLinesVisible(true);
table.setHeaderVisible(true);

String[] STD_HEADINGS = { "Name", "Type", "Restrictions" };

layout.addColumnData(new ColumnWeightData(20, 100, true));
TableColumn nameCol = new TableColumn(table, SWT.NONE, 0);
nameCol.setText(STD_HEADINGS[0]);
nameCol.setAlignment(SWT.LEFT);
nameCol.setResizable(true);

layout.addColumnData(new ColumnWeightData(20, 100, true));
TableColumn typeCol = new TableColumn(table, SWT.NONE, 1);
typeCol.setText(STD_HEADINGS[1]);
typeCol.setAlignment(SWT.LEFT);
typeCol.setResizable(true);

layout.addColumnData(new ColumnWeightData(60,100, true));
TableColumn restCol = new TableColumn(table, SWT.NONE, 2);
restCol.setText(STD_HEADINGS[2]);
restCol.setAlignment(SWT.LEFT);
restCol.setResizable(true);

viewer = new TableViewer(table);
viewer.setContentProvider(new DescriptionProvider());
viewer.setLabelProvider(new DescriptionLabelProvider());
viewer.setInput(input);

}


I've tried all sorts of different settings for the ColumnWeightData but
couldn't come up with anything that would fix the problem.

I've looked at all the example code I can find about creating TableViewers
and can't see what I'm doing that would cause an extra column to appear.
Many of the examples don't include anything about using TableLayout --
when I do that I get only one column.

Can anybody help me to understand what's going on here?

Steve Gollery
Re: extra column in TableViewer/Table in EditorPart [message #459152 is a reply to message #459150] Tue, 02 August 2005 17:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: friederich.kupzog.de

Just a guess because I saw that in an other thread (there the extra
column was intended): take out SWT.FULL_SELECTION and see what happens.

Hope that helped,
Friederich


Steven Gollery wrote:
> I have a class derived from EditorPart which displays a multi-column
> table. When the table first opens, I see the number of columns that I
> created, but if I manually resize the window, making it wider, I see an
> empty column that fills the remaining space.
> The code I'm using is pretty close to the sample from the book "Java
> Developers Guide to Eclipse" and looks like this:
>
> public void createPartControl(Composite parent) {
> Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL |
> SWT.MULTI | SWT.FULL_SELECTION);
> TableLayout layout = new TableLayout();
> table.setLayout(layout);
> table.setLinesVisible(true);
> table.setHeaderVisible(true);
> String[] STD_HEADINGS = { "Name", "Type", "Restrictions" };
> layout.addColumnData(new ColumnWeightData(20, 100, true));
> TableColumn nameCol = new TableColumn(table, SWT.NONE, 0);
> nameCol.setText(STD_HEADINGS[0]);
> nameCol.setAlignment(SWT.LEFT);
> nameCol.setResizable(true);
> layout.addColumnData(new ColumnWeightData(20, 100, true));
> TableColumn typeCol = new TableColumn(table, SWT.NONE, 1);
> typeCol.setText(STD_HEADINGS[1]);
> typeCol.setAlignment(SWT.LEFT);
> typeCol.setResizable(true);
> layout.addColumnData(new ColumnWeightData(60,100, true));
> TableColumn restCol = new TableColumn(table, SWT.NONE, 2);
> restCol.setText(STD_HEADINGS[2]);
> restCol.setAlignment(SWT.LEFT);
> restCol.setResizable(true);
> viewer = new TableViewer(table);
> viewer.setContentProvider(new DescriptionProvider());
> viewer.setLabelProvider(new DescriptionLabelProvider());
> viewer.setInput(input);
>
> }
>
>
> I've tried all sorts of different settings for the ColumnWeightData but
> couldn't come up with anything that would fix the problem.
>
> I've looked at all the example code I can find about creating
> TableViewers and can't see what I'm doing that would cause an extra
> column to appear. Many of the examples don't include anything about
> using TableLayout -- when I do that I get only one column.
>
> Can anybody help me to understand what's going on here?
>
> Steve Gollery
>


--
Friederich Kupzog
Elektronik & Software
Neusser Str. 5-7
50670 Köln
Tel 0241 160696-1
Fax 0221 726670
www.kupzog.de/fkmk
Re: extra column in TableViewer/Table in EditorPart [message #459169 is a reply to message #459150] Tue, 02 August 2005 19:59 Go to previous message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Steven Gollery" <sgollery@cadrc.calpoly.edu> wrote in message
news:44cf3530ea3ef16c025c96ebe7f89961$1@www.eclipse.org...
>I have a class derived from EditorPart which displays a multi-column table.
>When the table first opens, I see the number of columns that I created, but
>if I manually resize the window, making it wider, I see an empty column
>that fills the remaining space.
Add a ControlAdapter to the table and listen for SWT.Resize.
Then readjust the column widths.
---
Sunil
Previous Topic:Throw away certain key events for Table?
Next Topic:How can I add Table widgets into J9 ?
Goto Forum:
  


Current Time: Thu Oct 22 15:52:02 GMT 2020

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

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

Back to the top