提交 aa7bcae4 编写于 作者: S Serge Rider

Active shell detection fix (invalid thread access)

上级 2e3ccb10
......@@ -72,16 +72,11 @@ public class DataTransferJob extends AbstractJob {
private void showResult(final long time, final boolean hasErrors)
{
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
UIUtils.showMessageBox(
DBeaverUI.getActiveWorkbenchShell(),
"Data transfer",
"Data transfer completed " + (hasErrors ? "with errors " : "") + "(" + RuntimeUtils.formatExecutionTime(time) + ")",
hasErrors ? SWT.ICON_ERROR : SWT.ICON_INFORMATION);
}
});
UIUtils.showMessageBox(
null,
"Data transfer",
"Data transfer completed " + (hasErrors ? "with errors " : "") + "(" + RuntimeUtils.formatExecutionTime(time) + ")",
hasErrors ? SWT.ICON_ERROR : SWT.ICON_INFORMATION);
}
private boolean transferData(DBRProgressMonitor monitor, DataTransferPipe transferPipe)
......
......@@ -422,7 +422,8 @@ public class UIUtils {
@Override
public void run()
{
MessageBox messageBox = new MessageBox(shell, messageType | SWT.OK);
Shell activeShell = shell != null ? shell : DBeaverUI.getActiveWorkbenchShell();
MessageBox messageBox = new MessageBox(activeShell, messageType | SWT.OK);
messageBox.setMessage(info);
messageBox.setText(title);
messageBox.open();
......
......@@ -23,13 +23,12 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.part.ViewPart;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.model.runtime.AbstractJob;
import org.jkiss.dbeaver.model.runtime.DBRProcessController;
import org.jkiss.dbeaver.model.runtime.DBRProcessDescriptor;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.AbstractJob;
import org.jkiss.dbeaver.ui.IHelpContextIds;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.utils.GeneralUtils;
......@@ -152,10 +151,6 @@ public class ShellProcessView extends ViewPart implements DBRProcessController
if (line.isEmpty()) {
return;
}
final Shell shell = DBeaverUI.getActiveWorkbenchShell();
if (shell == null) {
return;
}
final String logLine = line + GeneralUtils.getDefaultLineSeparator();
DBeaverUI.asyncExec(new Runnable() {
@Override
......
......@@ -55,12 +55,12 @@ import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
import org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCObjectSimpleCache;
import org.jkiss.dbeaver.model.meta.Association;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.RunnableWithResult;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.sql.SQLDialect;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.model.struct.DBSObjectSelector;
import org.jkiss.dbeaver.model.struct.DBSStructureAssistant;
import org.jkiss.dbeaver.ui.UITask;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.utils.CommonUtils;
......@@ -486,28 +486,30 @@ public class DB2DataSource extends JDBCDataSource implements DBSObjectSelector,
// Ask the user in what tablespace to create the Explain tables
try {
List<String> listTablespaces = DB2Utils.getListOfUsableTsForExplain(monitor, (JDBCSession) session);
final List<String> listTablespaces = DB2Utils.getListOfUsableTsForExplain(monitor, (JDBCSession) session);
// NO Usable Tablespace found: End of the game..
if (listTablespaces.isEmpty()) {
UIUtils.showErrorDialog(DBeaverUI.getActiveWorkbenchShell(), DB2Messages.dialog_explain_no_tablespace_found_title,
UIUtils.showErrorDialog(null, DB2Messages.dialog_explain_no_tablespace_found_title,
DB2Messages.dialog_explain_no_tablespace_found_title);
return null;
}
// Build a dialog with the list of usable tablespaces for the user to choose
final DB2TablespaceChooser tsChooserDialog = new DB2TablespaceChooser(DBeaverUI.getActiveWorkbenchShell(),
listTablespaces);
String tablespaceName = DBeaverUI.syncExec(new RunnableWithResult<String>() {
String tablespaceName = new UITask<String>() {
@Override
public String runWithResult() {
protected String runTask() {
final DB2TablespaceChooser tsChooserDialog = new DB2TablespaceChooser(
DBeaverUI.getActiveWorkbenchShell(),
listTablespaces);
if (tsChooserDialog.open() == IDialogConstants.OK_ID) {
return tsChooserDialog.getSelectedTablespace();
} else {
return null;
}
}
});
}.execute();
if (tablespaceName == null) {
return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册