[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.dsdp.ercp] Re: TextCellEditor does not work in TableViewer
|
Hi,
I've never used eRCP but in JFace you are clearly missing the
setProperties() call which is needed.
Tom
Markus Bach schrieb:
> Hi
>
> I try to create a editable table wit eSWT 1.2 but without success. The
> CellModifier seems to work, because all of its methods get called in the
> proper order but the user does not have the chance to make any changes
> in the table, because no editor or even a cursor is shown. If I double
> click the field, tan modify gets called immediately.
>
> Here is the code creating my table:
>
> Table protocolTable = new Table(table, SWT.BORDER | SWT.H_SCROLL |
> SWT.V_SCROLL | SWT.FULL_SELECTION);
> TableViewer tableViewer = new TableViewer(protocolTable);
>
> tableViewer.getTable().setLayoutData(new
> GridData(GridData.FILL_BOTH));
> tableViewer.getTable().setLinesVisible(true);
> tableViewer.getTable().setHeaderVisible(true);
>
> tableViewer.setContentProvider(new
> ConfigurationProtocolTableContentProvider());
> tableViewer.setLabelProvider(new
> ConfigurationProtocolTableLabelProvider());
> tableViewer.setColumnProperties(new String[] { "DATE",
> "PROFILE_NAME", "INFO" });
> tableViewer.setCellModifier(new
> ConfigurationProtocolTableCellModifier(tableViewer));
>
> TableColumn columnDate = new TableColumn(tableViewer.getTable(),
> SWT.LEFT);
> columnDate.setText(Messages.getString("protocol_table_date"));
> columnDate.setWidth(110);
>
> TableColumn columnProfileName = new
> TableColumn(tableViewer.getTable(), SWT.LEFT);
>
> columnProfileName.setText(Messages.getString("protocol_table_profilename"));
>
> columnProfileName.setWidth(200);
>
> TableColumn columnInfo = new TableColumn(tableViewer.getTable(),
> SWT.LEFT);
> columnInfo.setText(Messages.getString("protocol_table_info"));
> columnInfo.setWidth(400);
>
> tableViewer.setCellEditors(new CellEditor[] { null, null, new
> TextCellEditor(protocolTable) });
>
> tableViewer.setInput("1234567777");
>
>
> And this is teh code of my CellModifier:
>
> public class ConfigurationProtocolTableCellModifier implements
> ICellModifier {
> private TableViewer viewer = null;
>
> public ConfigurationProtocolTableCellModifier(TableViewer viewer) {
> this.viewer = viewer;
> }
>
> public final boolean canModify(final Object element, final String
> property) {
> return true;
> }
>
> public Object getValue(Object element, String property) {
> if (element instanceof DeviceProtocol) {
> DeviceProtocol protocol = (DeviceProtocol) element;
> return protocol.getProtocolInfo();
> }
> return "";
> }
>
> public void modify(Object element, String property, Object value) {
> if (element instanceof DeviceProtocol) {
> DeviceProtocol protocol = (DeviceProtocol) element;
> protocol.setProtocolInfo((String) value);
>
> viewer.refresh(protocol);
> }
> }
> }
>
> Does anybody know what I am doing wrong or is there a problem in the
> eSWT implementation?
>
> Thanks
>
> Markus
>
>
>
--
B e s t S o l u t i o n . at
--------------------------------------------------------------------
Tom Schindl JFace-Committer
--------------------------------------------------------------------