提交 223e8e3d 编写于 作者: J jurgen

QM refactoring (remove UI interactions from QM).

UI-Core split
上级 e0dde17c
...@@ -54,10 +54,6 @@ public class DBeaverActivator extends AbstractUIPlugin ...@@ -54,10 +54,6 @@ public class DBeaverActivator extends AbstractUIPlugin
return instance; return instance;
} }
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
@Override @Override
public void start(BundleContext context) public void start(BundleContext context)
throws Exception throws Exception
...@@ -65,6 +61,7 @@ public class DBeaverActivator extends AbstractUIPlugin ...@@ -65,6 +61,7 @@ public class DBeaverActivator extends AbstractUIPlugin
super.start(context); super.start(context);
instance = this; instance = this;
DBeaverUI.getInstance();
try { try {
resourceBundle = ResourceBundle.getBundle(CoreMessages.BUNDLE_NAME); resourceBundle = ResourceBundle.getBundle(CoreMessages.BUNDLE_NAME);
...@@ -73,14 +70,11 @@ public class DBeaverActivator extends AbstractUIPlugin ...@@ -73,14 +70,11 @@ public class DBeaverActivator extends AbstractUIPlugin
} }
} }
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
@Override @Override
public void stop(BundleContext context) public void stop(BundleContext context)
throws Exception throws Exception
{ {
this.shutdownUI();
this.shutdownCore(); this.shutdownCore();
if (debugWriter != null) { if (debugWriter != null) {
...@@ -92,6 +86,10 @@ public class DBeaverActivator extends AbstractUIPlugin ...@@ -92,6 +86,10 @@ public class DBeaverActivator extends AbstractUIPlugin
super.stop(context); super.stop(context);
} }
private void shutdownUI() {
DBeaverUI.disposeUI();
}
public synchronized PrintStream getDebugWriter() public synchronized PrintStream getDebugWriter()
{ {
if (debugWriter == null) { if (debugWriter == null) {
...@@ -145,6 +143,7 @@ public class DBeaverActivator extends AbstractUIPlugin ...@@ -145,6 +143,7 @@ public class DBeaverActivator extends AbstractUIPlugin
return key; return key;
} }
} }
/** /**
* Returns the workspace instance. * Returns the workspace instance.
*/ */
...@@ -155,7 +154,7 @@ public class DBeaverActivator extends AbstractUIPlugin ...@@ -155,7 +154,7 @@ public class DBeaverActivator extends AbstractUIPlugin
private void shutdownCore() private void shutdownCore()
{ {
try { try {
// Dispose core // Dispose core
if (DBeaverCore.instance != null) { if (DBeaverCore.instance != null) {
DBeaverCore.instance.dispose(); DBeaverCore.instance.dispose();
} }
......
...@@ -164,8 +164,6 @@ public class DBeaverCore implements DBPApplication { ...@@ -164,8 +164,6 @@ public class DBeaverCore implements DBPApplication {
this.localSystem = new OSDescriptor(Platform.getOS(), Platform.getOSArch()); this.localSystem = new OSDescriptor(Platform.getOS(), Platform.getOSArch());
DBeaverUI.getInstance();
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
this.queryManager = new QMControllerImpl(); this.queryManager = new QMControllerImpl();
...@@ -280,8 +278,6 @@ public class DBeaverCore implements DBPApplication { ...@@ -280,8 +278,6 @@ public class DBeaverCore implements DBPApplication {
} }
} }
DBeaverUI.disposeUI();
DBeaverCore.instance = null; DBeaverCore.instance = null;
DBeaverCore.disposed = true; DBeaverCore.disposed = true;
......
...@@ -29,6 +29,7 @@ import org.eclipse.swt.widgets.Shell; ...@@ -29,6 +29,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.services.IDisposable;
import org.jkiss.dbeaver.DBeaverPreferences; import org.jkiss.dbeaver.DBeaverPreferences;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableContext; import org.jkiss.dbeaver.model.runtime.DBRRunnableContext;
...@@ -42,6 +43,9 @@ import org.jkiss.dbeaver.ui.TrayIconHandler; ...@@ -42,6 +43,9 @@ import org.jkiss.dbeaver.ui.TrayIconHandler;
import org.osgi.framework.Bundle; import org.osgi.framework.Bundle;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* DBeaver UI core * DBeaver UI core
...@@ -54,6 +58,7 @@ public class DBeaverUI { ...@@ -54,6 +58,7 @@ public class DBeaverUI {
private SharedTextColors sharedTextColors; private SharedTextColors sharedTextColors;
private TrayIconHandler trayItem; private TrayIconHandler trayItem;
private final List<IDisposable> globalDisposables = new ArrayList<IDisposable>();
public static DBeaverUI getInstance() public static DBeaverUI getInstance()
{ {
...@@ -84,6 +89,17 @@ public class DBeaverUI { ...@@ -84,6 +89,17 @@ public class DBeaverUI {
if (trayItem != null) { if (trayItem != null) {
trayItem.hide(); trayItem.hide();
} }
List<IDisposable> dispList = new ArrayList<IDisposable>(globalDisposables);
Collections.reverse(dispList);
for (IDisposable disp : dispList) {
try {
disp.dispose();
} catch (Exception e) {
log.error(e);
}
globalDisposables.remove(disp);
}
} }
private void initialize() private void initialize()
...@@ -257,4 +273,7 @@ public class DBeaverUI { ...@@ -257,4 +273,7 @@ public class DBeaverUI {
getInstance().trayItem.notify(message, status); getInstance().trayItem.notify(message, status);
} }
public void addDisposeListener(IDisposable disposable) {
globalDisposables.add(disposable);
}
} }
...@@ -21,15 +21,20 @@ import org.eclipse.core.expressions.PropertyTester; ...@@ -21,15 +21,20 @@ import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.services.IDisposable;
import org.jkiss.code.Nullable; import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.core.DBeaverCore; import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.core.Log; import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.model.DBPContextProvider; import org.jkiss.dbeaver.model.DBPContextProvider;
import org.jkiss.dbeaver.model.DBUtils; import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.exec.*; import org.jkiss.dbeaver.model.exec.*;
import org.jkiss.dbeaver.model.qm.QMUtils; import org.jkiss.dbeaver.model.qm.QMUtils;
import org.jkiss.dbeaver.runtime.qm.DefaultExecutionHandler; import org.jkiss.dbeaver.runtime.qm.DefaultExecutionHandler;
import org.jkiss.dbeaver.runtime.qm.meta.*; import org.jkiss.dbeaver.runtime.qm.meta.QMMSessionInfo;
import org.jkiss.dbeaver.runtime.qm.meta.QMMStatementExecuteInfo;
import org.jkiss.dbeaver.runtime.qm.meta.QMMTransactionInfo;
import org.jkiss.dbeaver.runtime.qm.meta.QMMTransactionSavepointInfo;
import org.jkiss.dbeaver.ui.ActionUtils; import org.jkiss.dbeaver.ui.ActionUtils;
import org.jkiss.dbeaver.ui.ICommandIds; import org.jkiss.dbeaver.ui.ICommandIds;
...@@ -47,7 +52,14 @@ public class DataSourcePropertyTester extends PropertyTester ...@@ -47,7 +52,14 @@ public class DataSourcePropertyTester extends PropertyTester
public DataSourcePropertyTester() { public DataSourcePropertyTester() {
super(); super();
QMUtils.registerHandler(new QMEventsHandler()); final QMEventsHandler qmHandler = new QMEventsHandler();
QMUtils.registerHandler(qmHandler);
DBeaverUI.getInstance().addDisposeListener(new IDisposable() {
@Override
public void dispose() {
QMUtils.unregisterHandler(qmHandler);
}
});
} }
@Override @Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册