private void createColumns() { List<Column> modelColumns = project.getTextTable().getColumns(); for (int i = 0; i < modelColumns.size(); i++) { final int columnIndex = i; TableViewerColumn col = new TableViewerColumn(tableViewer, SWT.NONE); col.getColumn().setWidth(50); col.getColumn().setText(project.getTextTable().getColumns().get(i).getName()); col.setLabelProvider( new ColumnLabelProvider() { @Override public String getText(Object element) { Line line = (Line) element; return line.getFragmentAt(columnIndex).getText(); } }); col.getColumn().setMoveable(true); col.getColumn() .addListener( SWT.Move, new Listener() { public void handleEvent(Event event) { int[] columnsOrder = table.getColumnOrder(); boolean moved = previewsColumnOrder.move(columnsOrder); if (moved) { moveDataColumn( previewsColumnOrder.getMovedFrom(), previewsColumnOrder.getMovedTo()); } } }); } }
public Composite createControl(CTabFolder folder, Project project) { this.parent = parent; this.project = project; Composite container = new Composite(folder, SWT.NONE); container.setLayout(new FillLayout()); tableViewer = new TableViewer(container, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER); table = tableViewer.getTable(); table.setLinesVisible(true); table.setHeaderVisible(true); createColumns(); previewsColumnOrder = new IntSuite(table.getColumnOrder()); ObservableListContentProvider observableList = new ObservableListContentProvider(); tableViewer.setContentProvider(observableList); tableViewer.setInput(new WritableList(project.getTextTable().getLines(), Line.class)); return container; }