|
|
Re: Is Combo supported in first column of TableTreeViewer? [message #445571 is a reply to message #445418] |
Mon, 08 November 2004 15:15 |
Veronika Irvine 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
>
|
|
|
Powered by
FUDForum. Page generated in 0.02047 seconds