提交 e2ebd65c 编写于 作者: S serge-rider

Instance server


Former-commit-id: 17e4606c
上级 a2b20a96
......@@ -65,6 +65,7 @@
<import plugin="org.apache.commons.logging"/>
<import plugin="com.jcraft.jsch"/>
<import plugin="org.objectweb.asm"/>
<import plugin="org.apache.commons.cli"/>
</requires>
<!-- Include org.eclipse.ui.themes because it was added only in 4.4 -->
......
......@@ -57,29 +57,33 @@ public class DBeaverApplication implements IApplication
@Override
public Object start(IApplicationContext context)
{
Display display = PlatformUI.createDisplay();
Display display = null;
Location instanceLoc = Platform.getInstanceLocation();
String defaultHomePath = getDefaultWorkspaceLocation().getAbsolutePath();
try {
URL defaultHomeURL = new File(defaultHomePath).toURI().toURL();
boolean keepTrying = true;
Shell shell = null;
while (keepTrying) {
if (!instanceLoc.set(defaultHomeURL, true)) {
if (handleCommandLine(defaultHomePath)) {
return IApplication.EXIT_OK;
}
// Can't lock specified path
if (shell == null) {
shell = new Shell(display, SWT.ON_TOP);
if (display == null) {
display = PlatformUI.createDisplay();
}
Shell shell = new Shell(display, SWT.ON_TOP);
MessageBox messageBox = new MessageBox(shell, SWT.ICON_WARNING | SWT.IGNORE | SWT.RETRY | SWT.ABORT);
messageBox.setText("DBeaver - Can't lock workspace");
messageBox.setMessage("Can't lock workspace at " + defaultHomePath + ".\n" +
"It seems that you have another DBeaver instance running.\n" +
"You may ignore it and work without lock but it is recommended to shutdown previous instance otherwise you may corrupt workspace data.");
switch (messageBox.open()) {
int msgResult = messageBox.open();
shell.dispose();
switch (msgResult) {
case SWT.ABORT:
return IApplication.EXIT_OK;
case SWT.IGNORE:
......@@ -93,9 +97,6 @@ public class DBeaverApplication implements IApplication
break;
}
}
if (shell != null) {
shell.dispose();
}
} catch (Throwable e) {
// Just skip it
......@@ -103,6 +104,9 @@ public class DBeaverApplication implements IApplication
System.err.println("Can't switch workspace to '" + defaultHomePath + "' - " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}
if (display == null) {
display = PlatformUI.createDisplay();
}
final Runtime runtime = Runtime.getRuntime();
DBeaverCore.setStandalone(true);
......
......@@ -21,6 +21,7 @@ package org.jkiss.dbeaver.core;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchWindow;
......@@ -58,7 +59,8 @@ public class DBeaverInstanceServer implements IInstanceController {
@Override
public void openExternalFiles(final String[] fileNames) {
final IWorkbenchWindow window = DBeaverUI.getActiveWorkbenchWindow();
UIUtils.runInUI(window.getShell(), new Runnable() {
final Shell shell = window.getShell();
UIUtils.runInUI(shell, new Runnable() {
@Override
public void run() {
for (String filePath : fileNames) {
......@@ -74,6 +76,12 @@ public class DBeaverInstanceServer implements IInstanceController {
}
}
}
if (!shell.getMinimized())
{
shell.setMinimized(true);
}
shell.setMinimized(false);
shell.setActive();
}
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册