Commit 70fa3e10 authored by Matija Obreza's avatar Matija Obreza
Browse files

Repaint SheetView after Automap/Unmap

parent 2a386272
...@@ -645,15 +645,15 @@ public class AppWindow { ...@@ -645,15 +645,15 @@ public class AppWindow {
tltmAutomap.setText("Automap"); tltmAutomap.setText("Automap");
tltmAutomap.setImage(automapColumnsIcon); tltmAutomap.setImage(automapColumnsIcon);
ToolItem tltmResetMapping = new ToolItem(toolBar, SWT.NONE); ToolItem tltmResetMapping = new ToolItem(toolBar, SWT.NONE);
tltmResetMapping.addSelectionListener(new SelectionAdapter() { tltmResetMapping.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
doUnmap(); doUnmap();
} }
}); });
tltmResetMapping.setText("Reset Mapping"); tltmResetMapping.setText("Reset Mapping");
tltmResetMapping.setImage(unmapColumnsIcon); tltmResetMapping.setImage(unmapColumnsIcon);
ToolItem tltmPush = new ToolItem(toolBar, SWT.NONE); ToolItem tltmPush = new ToolItem(toolBar, SWT.NONE);
tltmPush.addSelectionListener(new SelectionAdapter() { tltmPush.addSelectionListener(new SelectionAdapter() {
...@@ -762,8 +762,9 @@ public class AppWindow { ...@@ -762,8 +762,9 @@ public class AppWindow {
} }
protected void doAutomap() { protected void doAutomap() {
final SheetDisplay sheetDisplay = getCurrentSheetDisplay();
final IDataSourceSheet dss = getCurrentDataSourceSheet(); final IDataSourceSheet dss = getCurrentDataSourceSheet();
if (dss == null) { if (sheetDisplay == null || dss == null) {
return; return;
} }
...@@ -773,44 +774,54 @@ public class AppWindow { ...@@ -773,44 +774,54 @@ public class AppWindow {
@Override @Override
public void run() { public void run() {
dss.automap(columnDefs); dss.automap(columnDefs);
sheetDisplay.refreshTableView();
} }
}); });
} }
protected void doUnmap() { protected void doUnmap() {
final IDataSourceSheet dss = getCurrentDataSourceSheet(); final SheetDisplay sheetDisplay = getCurrentSheetDisplay();
if (dss == null) { final IDataSourceSheet dss = getCurrentDataSourceSheet();
return; if (dss == null) {
} return;
}
_log.info("Got data source sheet " + dss); _log.info("Got data source sheet " + dss);
threadPool.execute(new Runnable() { threadPool.execute(new Runnable() {
@Override @Override
public void run() { public void run() {
dss.unmap(); dss.unmap();
} sheetDisplay.refreshTableView();
}); }
});
} }
public IDataSourceSheet getCurrentDataSourceSheet() { public SheetDisplay getCurrentSheetDisplay() {
CTabItem currentTab = tabFolder.getSelection(); CTabItem currentTab = tabFolder.getSelection();
if (currentTab == null) { if (currentTab == null) {
_log.info("No tab selected"); _log.info("No tab selected");
return null; return null;
} }
final IDataSourceSheet dss = ((SheetDisplay) currentTab.getControl()).getDataSourceSheet(); return ((SheetDisplay) currentTab.getControl());
}
public IDataSourceSheet getCurrentDataSourceSheet() {
final SheetDisplay sheetDisplay = getCurrentSheetDisplay();
if (sheetDisplay == null) {
return null;
}
final IDataSourceSheet dss = sheetDisplay.getDataSourceSheet();
return dss; return dss;
} }
public IDataSource getCurrentDataSource() { public IDataSource getCurrentDataSource() {
CTabItem currentTab = tabFolder.getSelection(); final SheetDisplay sheetDisplay = getCurrentSheetDisplay();
if (currentTab == null) { if (sheetDisplay == null) {
_log.info("No tab selected");
return null; return null;
} }
final IDataSource ds = ((SheetDisplay) currentTab.getControl()).getDataSource(); final IDataSource ds = sheetDisplay.getDataSource();
return ds; return ds;
} }
......
...@@ -132,7 +132,7 @@ public class SheetDisplay extends Composite { ...@@ -132,7 +132,7 @@ public class SheetDisplay extends Composite {
@Override @Override
public void update(final ViewerCell cell) { public void update(final ViewerCell cell) {
final int columnIndex = cell.getColumnIndex(); final int columnIndex = cell.getColumnIndex();
System.err.println("Update col " + columnIndex); // System.err.println("Update col " + columnIndex);
final Object element = cell.getElement(); final Object element = cell.getElement();
if (element instanceof Object[]) { if (element instanceof Object[]) {
Object[] elArr = (Object[]) element; Object[] elArr = (Object[]) element;
...@@ -616,6 +616,18 @@ public class SheetDisplay extends Composite { ...@@ -616,6 +616,18 @@ public class SheetDisplay extends Composite {
return tableViewer; return tableViewer;
} }
/**
* Repaint table view
*/
protected void refreshTableView() {
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
tableViewer.refresh();
}
});
}
private void updateTable() { private void updateTable() {
_log.debug("Rebuilding table..."); _log.debug("Rebuilding table...");
table.clearAll(); table.clearAll();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment