Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Setting variable column width in Tree
Setting variable column width in Tree [message #453929] Wed, 13 April 2005 23:26 Go to next message
Eclipse UserFriend
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 09:19 Go to previous messageGo to next message
Eclipse UserFriend
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 17:24 Go to previous messageGo to next message
Eclipse UserFriend
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 17:26 Go to previous message
Eclipse UserFriend
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: Sun Jul 13 18:34:57 EDT 2025

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

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

Back to the top