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

Repaint SheetView after Automap/Unmap

parent 2a386272
......@@ -645,15 +645,15 @@ public class AppWindow {
tltmAutomap.setText("Automap");
tltmAutomap.setImage(automapColumnsIcon);
ToolItem tltmResetMapping = new ToolItem(toolBar, SWT.NONE);
tltmResetMapping.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doUnmap();
}
});
tltmResetMapping.setText("Reset Mapping");
tltmResetMapping.setImage(unmapColumnsIcon);
ToolItem tltmResetMapping = new ToolItem(toolBar, SWT.NONE);
tltmResetMapping.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doUnmap();
}
});
tltmResetMapping.setText("Reset Mapping");
tltmResetMapping.setImage(unmapColumnsIcon);
ToolItem tltmPush = new ToolItem(toolBar, SWT.NONE);
tltmPush.addSelectionListener(new SelectionAdapter() {
......@@ -762,8 +762,9 @@ public class AppWindow {
}
protected void doAutomap() {
final SheetDisplay sheetDisplay = getCurrentSheetDisplay();
final IDataSourceSheet dss = getCurrentDataSourceSheet();
if (dss == null) {
if (sheetDisplay == null || dss == null) {
return;
}
......@@ -773,44 +774,54 @@ public class AppWindow {
@Override
public void run() {
dss.automap(columnDefs);
sheetDisplay.refreshTableView();
}
});
}
protected void doUnmap() {
final IDataSourceSheet dss = getCurrentDataSourceSheet();
if (dss == null) {
return;
}
final SheetDisplay sheetDisplay = getCurrentSheetDisplay();
final IDataSourceSheet dss = getCurrentDataSourceSheet();
if (dss == null) {
return;
}
_log.info("Got data source sheet " + dss);
_log.info("Got data source sheet " + dss);
threadPool.execute(new Runnable() {
@Override
public void run() {
dss.unmap();
}
});
threadPool.execute(new Runnable() {
@Override
public void run() {
dss.unmap();
sheetDisplay.refreshTableView();
}
});
}
}
public IDataSourceSheet getCurrentDataSourceSheet() {
public SheetDisplay getCurrentSheetDisplay() {
CTabItem currentTab = tabFolder.getSelection();
if (currentTab == null) {
_log.info("No tab selected");
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;
}
public IDataSource getCurrentDataSource() {
CTabItem currentTab = tabFolder.getSelection();
if (currentTab == null) {
_log.info("No tab selected");
final SheetDisplay sheetDisplay = getCurrentSheetDisplay();
if (sheetDisplay == null) {
return null;
}
final IDataSource ds = ((SheetDisplay) currentTab.getControl()).getDataSource();
final IDataSource ds = sheetDisplay.getDataSource();
return ds;
}
......
......@@ -132,7 +132,7 @@ public class SheetDisplay extends Composite {
@Override
public void update(final ViewerCell cell) {
final int columnIndex = cell.getColumnIndex();
System.err.println("Update col " + columnIndex);
// System.err.println("Update col " + columnIndex);
final Object element = cell.getElement();
if (element instanceof Object[]) {
Object[] elArr = (Object[]) element;
......@@ -616,6 +616,18 @@ public class SheetDisplay extends Composite {
return tableViewer;
}
/**
* Repaint table view
*/
protected void refreshTableView() {
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
tableViewer.refresh();
}
});
}
private void updateTable() {
_log.debug("Rebuilding table...");
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