Home » Eclipse Projects » JFace » TableLayout and resize column
TableLayout and resize column [message #2873] |
Mon, 11 May 2009 10:54  |
Eclipse User |
|
|
|
Originally posted by: gaston.tonietti.teracode.com
Hi all,
I'm using TableLayout in my table views to manage columns width. It is
working grate when the view is opened, I get nice column widths.
But when I start resizing the first column the last one start getting bigger
as well and all columns in the middle get really small. It
makes columns resizing unusable for me.
The weird thing is that it is working fine in Mac but really bad just for
linux (gtk).
Do you know why it can be happening?
Let me know if you need any piece of code to check it better.
Thanks you a lot!
Gaston.
|
|
| |
Re: TableLayout and resize column [message #2977 is a reply to message #2927] |
Mon, 11 May 2009 11:49   |
Eclipse User |
|
|
|
Originally posted by: gaston.tonietti.teracode.com
Hi Tom,
Sorry, you're right, I'm using org.eclipse.jface.layout.TableColumnLayout.
I guess it may be related to using ColumnWeightData instead of ColumnPixelData, one column resize recalculates size for the other columns too.
But I don't like hardcoding widths in pixels, I think in this app being used in machines with different screen resolutions. Besides that, it is working great for Mac OS X, and horrible for Linux.
Here you have a snippet (If you prefer I can reduce it a lot):
private static final ColumnLayoutData HIDDEN_LAYOUT_DATA = new ColumnPixelData(0, false);
// I initialize it in the constructor
private ColumnDescriptor[] columnDescriptors;
private Table createTable(Composite parent) {
Table table = new Table(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
table.setLinesVisible (true);
table.setHeaderVisible (true);
this.tableLayout = new TableColumnLayout();
table.getParent().setLayout(this.tableLayout);
for (ColumnDescriptor cd : this.columnDescriptors) {
TableColumn column = new TableColumn(table, cd.getAlign());
column.setText(cd.getTitle());
if(cd.getTooltip() != null) {
column.setToolTipText(cd.getTooltip());
}
column.setData(DATA_KEY_COLUMN_DESCRIPTOR, cd);
// TODO HARDCODED! This should be taken from preferences
boolean hidden = HIDDEN_BY_DEFAULT_COLUMNS.contains(cd);
column.setData(DATA_KEY_COLUMN_HIDDEN, hidden);
if(!hidden) {
this.showColumn(column);
} else {
this.hideColumn(column);
}
}
return table;
}
public void hideColumn(TableColumn column) {
this.tableLayout.setColumnData(column, HIDDEN_LAYOUT_DATA);
column.setData(DATA_KEY_COLUMN_HIDDEN, true);
}
public void showColumn(TableColumn column) {
ColumnDescriptor cd = (ColumnDescriptor) column.getData(DATA_KEY_COLUMN_DESCRIPTOR);
this.tableLayout.setColumnData(column, cd.getLayoutData());
column.setData(DATA_KEY_COLUMN_HIDDEN, false);
}
public abstract interface ColumnDescriptor {
String getTitle();
String getTooltip();
int getAlign();
ColumnLayoutData getLayoutData();
}
public enum MyTableColumn implements ColumnDescriptor {
COLUMN_1("Column 1", "This is Column 1", SWT.LEAD, 60),
...
COLUMN_N("Column n", SWT.LEAD, 30),
final String title;
final String tooltip;
final int align;
final ColumnLayoutData layoutData;
private CampaignColumn(String title, int align, int weight) {
this(title, null, align, weight);
}
private CampaignColumn(String title, String tooltip, int align, int weight) {
this.title = title;
this.tooltip = tooltip;
this.align = align;
this.layoutData = new ColumnWeightData(weight);
}
public String getTitle() {
return title;
}
public String getTooltip() {
return tooltip;
}
public int getAlign() {
return align;
}
public ColumnLayoutData getLayoutData() {
return layoutData;
}
}
Tom Schindl wrote:
> Do we talk about:
> * org.eclipse.jface.viewers.TableLayout
> * org.eclipse.jface.layout.TableColumnLayout
>
> Could you provide us a snippet to see the problem and also give
> TableColumnLayout a try because it is the successor of TableLayout.
>
> Tom
>
> Gaston M. Tonietti schrieb:
>> Hi all,
>>
>> I'm using TableLayout in my table views to manage columns width. It is
>> working grate when the view is opened, I get nice column widths.
>>
>> But when I start resizing the first column the last one start getting
>> bigger as well and all columns in the middle get really small. It
>> makes columns resizing unusable for me.
>>
>> The weird thing is that it is working fine in Mac but really bad just for
>> linux (gtk).
>>
>> Do you know why it can be happening?
>> Let me know if you need any piece of code to check it better.
>>
>> Thanks you a lot!
>> Gaston.
>>
>>
|
|
|
Re: TableLayout and resize column [message #6079 is a reply to message #2977] |
Fri, 15 May 2009 13:26  |
Eclipse User |
|
|
|
Hi Gaston,
Can you attach your snippet as a complete Java file that we can just copy
into Eclipse and run?
Anyway, your questions are probably best answered by Tom who is on vacation
for a few days.
Boris
"Gaston M. Tonietti" <gaston.tonietti@teracode.com> wrote in message
news:gu9hdi$klj$1@build.eclipse.org...
> Hi Tom,
>
> Sorry, you're right, I'm using org.eclipse.jface.layout.TableColumnLayout.
>
> I guess it may be related to using ColumnWeightData instead of
> ColumnPixelData, one column resize recalculates size for the other columns
> too.
> But I don't like hardcoding widths in pixels, I think in this app being
> used in machines with different screen resolutions. Besides that, it is
> working great for Mac OS X, and horrible for Linux.
>
> Here you have a snippet (If you prefer I can reduce it a lot):
>
> private static final ColumnLayoutData HIDDEN_LAYOUT_DATA = new
> ColumnPixelData(0, false);
>
> // I initialize it in the constructor
> private ColumnDescriptor[] columnDescriptors;
>
> private Table createTable(Composite parent) {
>
> Table table = new Table(parent, SWT.BORDER | SWT.MULTI |
> SWT.FULL_SELECTION);
> table.setLinesVisible (true);
> table.setHeaderVisible (true);
>
> this.tableLayout = new TableColumnLayout();
> table.getParent().setLayout(this.tableLayout);
>
> for (ColumnDescriptor cd : this.columnDescriptors) {
> TableColumn column = new TableColumn(table, cd.getAlign());
> column.setText(cd.getTitle());
> if(cd.getTooltip() != null) {
> column.setToolTipText(cd.getTooltip());
> }
> column.setData(DATA_KEY_COLUMN_DESCRIPTOR, cd);
> // TODO HARDCODED! This should be taken from preferences
> boolean hidden = HIDDEN_BY_DEFAULT_COLUMNS.contains(cd);
> column.setData(DATA_KEY_COLUMN_HIDDEN, hidden);
> if(!hidden) {
> this.showColumn(column);
> } else {
> this.hideColumn(column);
> }
> }
>
> return table;
> }
>
> public void hideColumn(TableColumn column) {
> this.tableLayout.setColumnData(column, HIDDEN_LAYOUT_DATA);
> column.setData(DATA_KEY_COLUMN_HIDDEN, true);
> }
>
> public void showColumn(TableColumn column) {
> ColumnDescriptor cd = (ColumnDescriptor)
> column.getData(DATA_KEY_COLUMN_DESCRIPTOR);
> this.tableLayout.setColumnData(column, cd.getLayoutData());
> column.setData(DATA_KEY_COLUMN_HIDDEN, false);
> }
>
> public abstract interface ColumnDescriptor {
> String getTitle();
> String getTooltip();
> int getAlign();
> ColumnLayoutData getLayoutData();
> }
>
>
> public enum MyTableColumn implements ColumnDescriptor {
> COLUMN_1("Column 1", "This is Column 1", SWT.LEAD, 60),
> ...
> COLUMN_N("Column n", SWT.LEAD, 30),
>
> final String title;
> final String tooltip;
> final int align;
> final ColumnLayoutData layoutData;
>
> private CampaignColumn(String title, int align, int weight) {
> this(title, null, align, weight);
> }
>
> private CampaignColumn(String title, String tooltip, int align, int
> weight) {
> this.title = title;
> this.tooltip = tooltip;
> this.align = align;
> this.layoutData = new ColumnWeightData(weight);
> }
>
> public String getTitle() {
> return title;
> }
>
> public String getTooltip() {
> return tooltip;
> }
>
> public int getAlign() {
> return align;
> }
>
> public ColumnLayoutData getLayoutData() {
> return layoutData;
> }
> }
>
>
>
> Tom Schindl wrote:
>
>> Do we talk about:
>> * org.eclipse.jface.viewers.TableLayout
>> * org.eclipse.jface.layout.TableColumnLayout
>>
>> Could you provide us a snippet to see the problem and also give
>> TableColumnLayout a try because it is the successor of TableLayout.
>>
>> Tom
>>
>> Gaston M. Tonietti schrieb:
>>> Hi all,
>>>
>>> I'm using TableLayout in my table views to manage columns width. It is
>>> working grate when the view is opened, I get nice column widths.
>>>
>>> But when I start resizing the first column the last one start getting
>>> bigger as well and all columns in the middle get really small. It
>>> makes columns resizing unusable for me.
>>>
>>> The weird thing is that it is working fine in Mac but really bad just
>>> for
>>> linux (gtk).
>>>
>>> Do you know why it can be happening?
>>> Let me know if you need any piece of code to check it better.
>>>
>>> Thanks you a lot!
>>> Gaston.
>>>
>>>
>
>
|
|
|
Goto Forum:
Current Time: Fri Apr 25 21:30:45 EDT 2025
Powered by FUDForum. Page generated in 0.03226 seconds
|