use of org.jkiss.dbeaver.model.runtime.BaseProgressMonitor in project dbeaver by serge-rider.
the class DBeaverSettingsImporter method migrateWorkspace.
private void migrateWorkspace(final File oldDir, final File newDir) {
progressLabel.setText("Counting workspace files...");
final int totalFiles = countWorkspaceFiles(oldDir);
progressBar.setMinimum(0);
progressBar.setMaximum(totalFiles);
final DBRProgressMonitor monitor = new BaseProgressMonitor() {
int filesProcessed = 0;
@Override
public void subTask(final String name) {
display.syncExec(new Runnable() {
@Override
public void run() {
progressLabel.setText(name);
}
});
}
@Override
public void worked(final int work) {
display.syncExec(new Runnable() {
@Override
public void run() {
filesProcessed += work;
progressBar.setSelection(filesProcessed);
}
});
}
};
new Thread() {
@Override
public void run() {
try {
if (!newDir.exists()) {
if (!newDir.mkdirs()) {
System.err.println("Can't create target workspace directory '" + newDir.getAbsolutePath() + "'");
return;
}
}
copyWorkspaceFiles(monitor, DIR_TYPE.WORKSPACE, oldDir, newDir);
} finally {
DBeaverApplication.WORKSPACE_MIGRATED = true;
display.syncExec(new Runnable() {
@Override
public void run() {
showMessageBox("Import completed", "Configuration was imported to '" + newDir.getAbsolutePath() + "'", SWT.ICON_INFORMATION | SWT.OK);
shellResult = SWT.OK;
windowShell.dispose();
}
});
}
}
}.start();
}
Aggregations