Added Swt.getVersion()
This commit is contained in:
parent
ee2509c014
commit
df8cf79014
@ -42,13 +42,13 @@ class Swt {
|
|||||||
|
|
||||||
// Methods are cached for performance
|
// Methods are cached for performance
|
||||||
private static final Method syncExecMethod;
|
private static final Method syncExecMethod;
|
||||||
|
private static final int version;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
boolean isSwtLoaded_ = false;
|
boolean isSwtLoaded_ = false;
|
||||||
boolean isSwtGtk3_ = false;
|
boolean isSwtGtk3_ = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// this is important to use reflection, because if JavaFX is not being used, calling getToolkit() will initialize it...
|
|
||||||
java.lang.reflect.Method m = ClassLoader.class.getDeclaredMethod("findLoadedClass", String.class);
|
java.lang.reflect.Method m = ClassLoader.class.getDeclaredMethod("findLoadedClass", String.class);
|
||||||
m.setAccessible(true);
|
m.setAccessible(true);
|
||||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||||
@ -82,14 +82,23 @@ class Swt {
|
|||||||
// currentDisplay = org.eclipse.swt.widgets.Display.getCurrent();
|
// currentDisplay = org.eclipse.swt.widgets.Display.getCurrent();
|
||||||
// currentDisplayThread = currentDisplay.getThread();
|
// currentDisplayThread = currentDisplay.getThread();
|
||||||
|
|
||||||
|
// also save the SWT version
|
||||||
|
|
||||||
Object _currentDisplay = null;
|
Object _currentDisplay = null;
|
||||||
Thread _currentDisplayThread = null;
|
Thread _currentDisplayThread = null;
|
||||||
|
|
||||||
Method _syncExecMethod = null;
|
Method _syncExecMethod = null;
|
||||||
|
int _version = 0;
|
||||||
|
|
||||||
if (isSwtLoaded_) {
|
if (isSwtLoaded_) {
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = Class.forName("org.eclipse.swt.widgets.Display");
|
// SWT.getVersion()
|
||||||
|
Class<?> clazz = Class.forName("org.eclipse.swt.SWT");
|
||||||
|
Method getVersionMethod = clazz.getMethod("getVersion");
|
||||||
|
_version = (Integer) getVersionMethod.invoke(null);
|
||||||
|
|
||||||
|
|
||||||
|
clazz = Class.forName("org.eclipse.swt.widgets.Display");
|
||||||
Method getCurrentMethod = clazz.getMethod("getCurrent");
|
Method getCurrentMethod = clazz.getMethod("getCurrent");
|
||||||
Method getThreadMethod = clazz.getMethod("getThread");
|
Method getThreadMethod = clazz.getMethod("getThread");
|
||||||
_syncExecMethod = clazz.getDeclaredMethod("syncExec", Runnable.class);
|
_syncExecMethod = clazz.getDeclaredMethod("syncExec", Runnable.class);
|
||||||
@ -150,6 +159,7 @@ class Swt {
|
|||||||
currentDisplay = _currentDisplay;
|
currentDisplay = _currentDisplay;
|
||||||
currentDisplayThread = _currentDisplayThread;
|
currentDisplayThread = _currentDisplayThread;
|
||||||
syncExecMethod = _syncExecMethod;
|
syncExecMethod = _syncExecMethod;
|
||||||
|
version = _version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -205,4 +215,9 @@ class Swt {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static
|
||||||
|
int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user