Skip to content

Commit

Permalink
Display active column mapping in column title
Browse files Browse the repository at this point in the history
  • Loading branch information
buchen committed May 17, 2012
1 parent a9ba6a7 commit 58e73da
Showing 1 changed file with 13 additions and 11 deletions.
Expand Up @@ -261,7 +261,7 @@ public void widgetDefaultSelected(SelectionEvent event)
TableColumnLayout layout = new TableColumnLayout();
compositeTable.setLayout(layout);

tableViewer = new TableViewer(compositeTable, SWT.BORDER);
tableViewer = new TableViewer(compositeTable, SWT.BORDER | SWT.FULL_SELECTION);
final Table table = tableViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
Expand Down Expand Up @@ -414,11 +414,11 @@ private void doProcessFile()
column.dispose();

TableColumnLayout layout = (TableColumnLayout) tableViewer.getTable().getParent().getLayout();
for (final CSVImporter.Column header : importer.getColumns())
for (Column column : importer.getColumns())
{
TableColumn column = new TableColumn(tableViewer.getTable(), SWT.None);
column.setText(header.getLabel());
layout.setColumnData(column, new ColumnPixelData(80, true));
TableColumn tableColumn = new TableColumn(tableViewer.getTable(), SWT.None);
layout.setColumnData(tableColumn, new ColumnPixelData(80, true));
setColumnLabel(tableColumn, column);
}

tableViewer.setInput(importer.getRawValues());
Expand All @@ -427,7 +427,7 @@ private void doProcessFile()
for (TableColumn column : tableViewer.getTable().getColumns())
column.pack();

doUpdateTable();
doUpdateErrorMessages();
}
catch (IOException e)
{
Expand All @@ -442,6 +442,12 @@ private void doProcessFile()
}
}

private void setColumnLabel(TableColumn tableColumn, Column column)
{
tableColumn.setText(column.getField() != null ? column.getLabel() + " -> [" + column.getField().getName() + "]" : column.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
tableColumn.setAlignment(column.getField() instanceof AmountField ? SWT.RIGHT : SWT.LEFT);
}

private void doUpdateTable()
{
Table table = tableViewer.getTable();
Expand All @@ -450,11 +456,7 @@ private void doUpdateTable()
try
{
for (int ii = 0; ii < table.getColumnCount(); ii++)
{
Column column = importer.getColumns()[ii];
boolean isNumber = column.getField() instanceof AmountField;
table.getColumn(ii).setAlignment(isNumber ? SWT.RIGHT : SWT.LEFT);
}
setColumnLabel(table.getColumn(ii), importer.getColumns()[ii]);

tableViewer.refresh();

Expand Down

0 comments on commit 58e73da

Please sign in to comment.