diff --git a/src/dorkbox/util/swt/Swt.java b/src/dorkbox/util/swt/Swt.java index d398e69..eb087ba 100644 --- a/src/dorkbox/util/swt/Swt.java +++ b/src/dorkbox/util/swt/Swt.java @@ -43,6 +43,8 @@ class Swt { // Since this class is the place other code interacts with, we can use SWT stuff if necessary without loading/linking // the SWT classes by accident + + boolean isSwtLoadable_ = isLoadable(); version = SWT.getVersion(); @@ -76,7 +78,7 @@ class Swt { } }); - if (null != swtErrorClass) { + if (swtErrorClass != null) { try { return org.eclipse.swt.SWT.isLoadable(); } catch (Exception ignored) { @@ -96,6 +98,7 @@ class Swt { return false; } + // required to use reflection, because this is an internal class final String SWT_INTERNAL_CLASS = "org.eclipse.swt.internal.gtk.OS"; Class osClass = AccessController.doPrivileged(new PrivilegedAction>() { @Override @@ -148,24 +151,6 @@ class Swt { } - public static - class SwtOverride { - static - void onShutdown(final Display currentDisplay, final Runnable runnable) { - // currentDisplay.getShells() must only be called inside the event thread! - - org.eclipse.swt.widgets.Shell shell = currentDisplay.getShells()[0]; - shell.addListener(org.eclipse.swt.SWT.Close, new org.eclipse.swt.widgets.Listener() { - @Override - public - void handleEvent(final org.eclipse.swt.widgets.Event event) { - runnable.run(); - } - }); - } - } - - public static int getVersion() { return version; @@ -185,13 +170,13 @@ class Swt { void onShutdown(final Runnable runnable) { // currentDisplay.getShells() must only be called inside the event thread! if (isEventThread()) { - SwtOverride.onShutdown(currentDisplay, runnable); + SwtAccess.onShutdown(currentDisplay, runnable); } else { dispatch(new Runnable() { @Override public void run() { - SwtOverride.onShutdown(currentDisplay, runnable); + SwtAccess.onShutdown(currentDisplay, runnable); } }); } diff --git a/src/dorkbox/util/swt/SwtAccess.java b/src/dorkbox/util/swt/SwtAccess.java new file mode 100644 index 0000000..5186627 --- /dev/null +++ b/src/dorkbox/util/swt/SwtAccess.java @@ -0,0 +1,18 @@ +package dorkbox.util.swt; + +public +class SwtAccess { + static + void onShutdown(final org.eclipse.swt.widgets.Display currentDisplay, final Runnable runnable) { + // currentDisplay.getShells() must only be called inside the event thread! + + org.eclipse.swt.widgets.Shell shell = currentDisplay.getShells()[0]; + shell.addListener(org.eclipse.swt.SWT.Close, new org.eclipse.swt.widgets.Listener() { + @Override + public + void handleEvent(final org.eclipse.swt.widgets.Event event) { + runnable.run(); + } + }); + } +}