Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Is Combo supported in first column of TableTreeViewer?
Is Combo supported in first column of TableTreeViewer? [message #445418] Fri, 05 November 2004 12:15 Go to next message
Rajeev Sudra is currently offline Rajeev SudraFriend
Messages: 30
Registered: July 2009
Member
I have a TableTreeViewer which only contains a single column, containing some tree data. I have tried adding a Combo drop down editor using a CellEditor but the Combo does not get rendered correctly. When I select the TableTree entry which should have the Combo, it does not draw the dropdown. If in use the cursor keys to move up or down, I am able to select another option but it just won't draw the combo.


Is it down to a limitation in the TableTree widget such as not supported combo's in the first column? What should the parent we for a ComboBoxCellEditor? tableTreeViewer.getTable()?

TIA,
Raj
Re: Is Combo supported in first column of TableTreeViewer? [message #445442 is a reply to message #445418] Fri, 05 November 2004 19:26 Go to previous messageGo to next message
Chris Laffra is currently offline Chris LaffraFriend
Messages: 253
Registered: July 2009
Senior Member
Why don't you look at the source? TableTreeViewer is a custom widget in
jface.
It does not use a tree widget at all. It renders the tree using icons and
indentation.
You would have to subclass the viewer to get enhanced behavior

Chris

"Rajeev Sudra" <rsudra@hotmail.com> wrote in message
news:cmfqts$l0s$1@eclipse.org...
> I have a TableTreeViewer which only contains a single column, containing
some tree data. I have tried adding a Combo drop down editor using a
CellEditor but the Combo does not get rendered correctly. When I select the
TableTree entry which should have the Combo, it does not draw the dropdown.
If in use the cursor keys to move up or down, I am able to select another
option but it just won't draw the combo.
>
>
> Is it down to a limitation in the TableTree widget such as not supported
combo's in the first column? What should the parent we for a
ComboBoxCellEditor? tableTreeViewer.getTable()?
>
> TIA,
> Raj
>
Re: Is Combo supported in first column of TableTreeViewer? [message #445571 is a reply to message #445418] Mon, 08 November 2004 15:15 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
There is a bug in TableTreeEditor.

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

If you add the line "editor.grabHorizontal = true" you should be able to see
the drop button of your combo box. The example below works for me (except
that when the editor is open, it covers up the +/- of the TableTree -
another bug):

public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout (new FillLayout ());
TableTree tree = new TableTree (shell, SWT.BORDER);
final Table table = tree.getTable();
table.setHeaderVisible(true);
TableColumn c1 = new TableColumn(table, SWT.NONE);
TableColumn c2 = new TableColumn(table, SWT.NONE);
for (int i = 0; i < 3; i++) {
TableTreeItem item = new TableTreeItem (tree, SWT.NONE);
item.setText ("item " + i);
item.setText(1, "adasdas");
for (int j = 0; j < 3; j++) {
TableTreeItem subItem = new TableTreeItem (item,
SWT.NONE);
subItem.setText ("item " + j);
subItem.setText(1, "qweqweqweqweq");
for (int k = 0; k < 3; k++) {
TableTreeItem subsubItem = new TableTreeItem
(subItem, SWT.NONE);
subsubItem.setText ("item " + k);
subsubItem.setText(1, "adsasdasdadqweqwe");
}
}
}
c1.setWidth(100);
c2.setWidth(100);

final TableTreeEditor editor = new TableTreeEditor(tree);
editor.horizontalAlignment = SWT.RIGHT;
editor.grabHorizontal = true;
final int EDITABLECOLUMN = 0;

tree.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
// Clean up any previous editor control
Control oldEditor = editor.getEditor();
if (oldEditor != null) oldEditor.dispose();

// Identify the selected row
TableTreeItem item = (TableTreeItem)e.item;
if (item == null) return;

// The control that will be the editor must be a
child of the Table
CCombo newEditor = new CCombo(table, SWT.NONE);
newEditor.setText(item.getText(EDITABLECOLUMN));
newEditor.add("asd asd as dasd");
newEditor.add("qweqeqweqe qwee");
newEditor.add("dfgdgert ert");
newEditor.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
CCombo text =
(CCombo)editor.getEditor();
editor.getItem().setText(EDITABLECOLUMN,
text.getText());
}
});
newEditor.setFocus();
editor.setEditor(newEditor, item, EDITABLECOLUMN);
}
});

shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}



"Rajeev Sudra" <rsudra@hotmail.com> wrote in message
news:cmfqts$l0s$1@eclipse.org...
>I have a TableTreeViewer which only contains a single column, containing
>some tree data. I have tried adding a Combo drop down editor using a
>CellEditor but the Combo does not get rendered correctly. When I select the
>TableTree entry which should have the Combo, it does not draw the dropdown.
>If in use the cursor keys to move up or down, I am able to select another
>option but it just won't draw the combo.
>
>
> Is it down to a limitation in the TableTree widget such as not supported
> combo's in the first column? What should the parent we for a
> ComboBoxCellEditor? tableTreeViewer.getTable()?
>
> TIA,
> Raj
>
Previous Topic:Cannot drag from SWT, drop on Swing/AWT in certain linux configurations
Next Topic:sorry, I ask this question again.
Goto Forum:
  


Current Time: Fri Apr 19 02:12:46 GMT 2024

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

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

Back to the top