Search code examples
javaeclipseswtrcp

Select cells instead of a row in a swt table


I have a SWT table. When I click, I don't want to select a full row, but certain cells. Is that possible?

My current code is:

tableViewer = new TableViewer(parent, SWT.NONE);
    Table table = tableViewer.getTable();
    this.tableViewer.getTable().setLayoutData(
            new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(20, 20, true));
    layout.addColumnData(new ColumnWeightData(20, 20, true));
    this.tableViewer.getTable().setLayout(layout);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setLabelProvider(new ITableLabelProvider() {
               ...

Solution

  • Go to the JFace Snippets, and search for "cell". There several useful snippets to pick from...