Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Setting variable column width in Tree
Setting variable column width in Tree [message #453929] Thu, 14 April 2005 03:26 Go to next message
Hugo A. Garcia is currently offline Hugo A. GarciaFriend
Messages: 258
Registered: July 2009
Senior Member
Hi

I am converting a table to be a tree. I used the code below to set the
widths dynamically. Is there an equivalent way in Tree?

thanks

-H

============================================================ =========

....

Table testTableView = testTableEditorViewer.getTable();
testTableView.clearAll();

int columnCount = testTableView.getColumnCount();
for (int tableColumnIndex = columnCount - 1; tableColumnIndex
>= 0; tableColumnIndex--) {
testTableView.getColumn(tableColumnIndex).dispose();
}

----> TableLayout tableLayout = new TableLayout();
----> int columWeight = 100 / testCaseTableColumnCount;
String[] columProperties = new String[testCaseTableColumnCount];
for (int columnIndex = 0; columnIndex <
testCaseTableColumnCount; columnIndex++) {
new TableColumn(testTableView, SWT.LEFT).setText(Integer
.toString(columnIndex));
----> tableLayout.addColumnData(new ColumnWeightData(columWeight,
true));
columProperties[columnIndex] = String.valueOf(columnIndex);
}

testTableEditorViewer.setColumnProperties(columProperties);

TestTableViewCellModifier testTableViewCellModifier = new
TestTableViewCellModifier(
this);
testTableEditorViewer.setCellModifier(testTableViewCellModif ier);
CellEditor[] celleditors = new
CellEditor[testCaseTableColumnCount];
for (int cellEditorIndex = 0; cellEditorIndex <
testCaseTableColumnCount; cellEditorIndex++) {
TextCellEditor textCellEditor = new
TextCellEditor(testTableView);;
celleditors[cellEditorIndex] = textCellEditor;
}

----> testTableView.setLayout(tableLayout);

....

============================================================ =========
Re: Setting variable column width in Tree [message #454080 is a reply to message #453929] Fri, 15 April 2005 13:19 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Hugo,

There isn't an equivalent TreeLayout class in jface, and since eclipse is
now api frozen for 3.1, there won't be one appearing. However I did a quick
experiment and found that I could create an equivalent TreeLayout class
simply by making a copy of TableLayout and changing "Table" to "Tree"
throughout. You should give this a try.

Grant


"Hugo A. Garcia" <hugo.a.garcia@gmail.com> wrote in message
news:d3ko9a$1k8$1@news.eclipse.org...
> Hi
>
> I am converting a table to be a tree. I used the code below to set the
> widths dynamically. Is there an equivalent way in Tree?
>
> thanks
>
> -H
>
> ============================================================ =========
>
> ...
>
> Table testTableView = testTableEditorViewer.getTable();
> testTableView.clearAll();
>
> int columnCount = testTableView.getColumnCount();
> for (int tableColumnIndex = columnCount - 1; tableColumnIndex
> >= 0; tableColumnIndex--) {
> testTableView.getColumn(tableColumnIndex).dispose();
> }
>
> ----> TableLayout tableLayout = new TableLayout();
> ----> int columWeight = 100 / testCaseTableColumnCount;
> String[] columProperties = new String[testCaseTableColumnCount];
> for (int columnIndex = 0; columnIndex <
> testCaseTableColumnCount; columnIndex++) {
> new TableColumn(testTableView, SWT.LEFT).setText(Integer
> .toString(columnIndex));
> ----> tableLayout.addColumnData(new ColumnWeightData(columWeight,
> true));
> columProperties[columnIndex] = String.valueOf(columnIndex);
> }
>
> testTableEditorViewer.setColumnProperties(columProperties);
>
> TestTableViewCellModifier testTableViewCellModifier = new
> TestTableViewCellModifier(
> this);
> testTableEditorViewer.setCellModifier(testTableViewCellModif ier);
> CellEditor[] celleditors = new
> CellEditor[testCaseTableColumnCount];
> for (int cellEditorIndex = 0; cellEditorIndex <
> testCaseTableColumnCount; cellEditorIndex++) {
> TextCellEditor textCellEditor = new
> TextCellEditor(testTableView);;
> celleditors[cellEditorIndex] = textCellEditor;
> }
>
> ----> testTableView.setLayout(tableLayout);
>
> ...
>
> ============================================================ =========
Re: Setting variable column width in Tree [message #454092 is a reply to message #454080] Sat, 16 April 2005 21:24 Go to previous messageGo to next message
Hugo A. Garcia is currently offline Hugo A. GarciaFriend
Messages: 258
Registered: July 2009
Senior Member
Hi Grant

I followed your suggestion and it works. I opened a bug with the code
for TreeLayout attached.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=91662

thanks

-H

Grant Gayed wrote:
> Hi Hugo,
>
> There isn't an equivalent TreeLayout class in jface, and since eclipse is
> now api frozen for 3.1, there won't be one appearing. However I did a quick
> experiment and found that I could create an equivalent TreeLayout class
> simply by making a copy of TableLayout and changing "Table" to "Tree"
> throughout. You should give this a try.
>
> Grant
>
>
> "Hugo A. Garcia" <hugo.a.garcia@gmail.com> wrote in message
> news:d3ko9a$1k8$1@news.eclipse.org...
>
>>Hi
>>
>>I am converting a table to be a tree. I used the code below to set the
>>widths dynamically. Is there an equivalent way in Tree?
>>
>>thanks
>>
>>-H
>>
>> ============================================================ =========
>>
>>...
>>
>> Table testTableView = testTableEditorViewer.getTable();
>> testTableView.clearAll();
>>
>> int columnCount = testTableView.getColumnCount();
>> for (int tableColumnIndex = columnCount - 1; tableColumnIndex
>> >= 0; tableColumnIndex--) {
>> testTableView.getColumn(tableColumnIndex).dispose();
>> }
>>
>>----> TableLayout tableLayout = new TableLayout();
>>----> int columWeight = 100 / testCaseTableColumnCount;
>> String[] columProperties = new String[testCaseTableColumnCount];
>> for (int columnIndex = 0; columnIndex <
>>testCaseTableColumnCount; columnIndex++) {
>> new TableColumn(testTableView, SWT.LEFT).setText(Integer
>> .toString(columnIndex));
>>----> tableLayout.addColumnData(new ColumnWeightData(columWeight,
>>true));
>> columProperties[columnIndex] = String.valueOf(columnIndex);
>> }
>>
>>testTableEditorViewer.setColumnProperties(columProperties);
>>
>> TestTableViewCellModifier testTableViewCellModifier = new
>>TestTableViewCellModifier(
>> this);
>> testTableEditorViewer.setCellModifier(testTableViewCellModif ier);
>> CellEditor[] celleditors = new
>>CellEditor[testCaseTableColumnCount];
>> for (int cellEditorIndex = 0; cellEditorIndex <
>>testCaseTableColumnCount; cellEditorIndex++) {
>> TextCellEditor textCellEditor = new
>>TextCellEditor(testTableView);;
>> celleditors[cellEditorIndex] = textCellEditor;
>> }
>>
>>----> testTableView.setLayout(tableLayout);
>>
>>...
>>
>> ============================================================ =========
>
>
>
Re: Setting variable column width in Tree [message #454093 is a reply to message #454080] Sat, 16 April 2005 21:26 Go to previous message
Hugo A. Garcia is currently offline Hugo A. GarciaFriend
Messages: 258
Registered: July 2009
Senior Member
Hi Grant

I followed your suggestion and it works. I opened a bug with the code
for TreeLayout attached.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=91662

thanks

-H

Grant Gayed wrote:
> Hi Hugo,
>
> There isn't an equivalent TreeLayout class in jface, and since eclipse is
> now api frozen for 3.1, there won't be one appearing. However I did a quick
> experiment and found that I could create an equivalent TreeLayout class
> simply by making a copy of TableLayout and changing "Table" to "Tree"
> throughout. You should give this a try.
>
> Grant
>
>
> "Hugo A. Garcia" <hugo.a.garcia@gmail.com> wrote in message
> news:d3ko9a$1k8$1@news.eclipse.org...
>
>>Hi
>>
>>I am converting a table to be a tree. I used the code below to set the
>>widths dynamically. Is there an equivalent way in Tree?
>>
>>thanks
>>
>>-H
>>
>> ============================================================ =========
>>
>>...
>>
>> Table testTableView = testTableEditorViewer.getTable();
>> testTableView.clearAll();
>>
>> int columnCount = testTableView.getColumnCount();
>> for (int tableColumnIndex = columnCount - 1; tableColumnIndex
>> >= 0; tableColumnIndex--) {
>> testTableView.getColumn(tableColumnIndex).dispose();
>> }
>>
>>----> TableLayout tableLayout = new TableLayout();
>>----> int columWeight = 100 / testCaseTableColumnCount;
>> String[] columProperties = new String[testCaseTableColumnCount];
>> for (int columnIndex = 0; columnIndex <
>>testCaseTableColumnCount; columnIndex++) {
>> new TableColumn(testTableView, SWT.LEFT).setText(Integer
>> .toString(columnIndex));
>>----> tableLayout.addColumnData(new ColumnWeightData(columWeight,
>>true));
>> columProperties[columnIndex] = String.valueOf(columnIndex);
>> }
>>
>>testTableEditorViewer.setColumnProperties(columProperties);
>>
>> TestTableViewCellModifier testTableViewCellModifier = new
>>TestTableViewCellModifier(
>> this);
>> testTableEditorViewer.setCellModifier(testTableViewCellModif ier);
>> CellEditor[] celleditors = new
>>CellEditor[testCaseTableColumnCount];
>> for (int cellEditorIndex = 0; cellEditorIndex <
>>testCaseTableColumnCount; cellEditorIndex++) {
>> TextCellEditor textCellEditor = new
>>TextCellEditor(testTableView);;
>> celleditors[cellEditorIndex] = textCellEditor;
>> }
>>
>>----> testTableView.setLayout(tableLayout);
>>
>>...
>>
>> ============================================================ =========
>
>
>
Previous Topic:Changing the size of a Tables rows
Next Topic:Is there the way of removing focus border?
Goto Forum:
  


Current Time: Sat Mar 06 06:35:04 GMT 2021

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

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

Back to the top