onShutdown is no longer available when using JPMS, so it was removed. The developer will now have to implement shutdown hooks for SWT/JavaFX

master
Robinson 2021-04-26 02:35:50 +02:00
parent 7e2190a6dd
commit aac1fef12c
6 changed files with 57 additions and 33 deletions

View File

@ -145,9 +145,4 @@ class JavaFx {
boolean isEventThread() {
return JavaFxAccess.isEventThread();
}
public static
void onShutdown(final Runnable runnable) {
JavaFxAccess.onShutdown(runnable);
}
}

View File

@ -17,8 +17,6 @@ package dorkbox.javaFx;
/**
* Utility methods for JavaFX.
* <p>
* We use reflection for these methods so that we can compile everything under a version of Java that might not have JavaFX.
*/
public
class JavaFxAccess {
@ -32,9 +30,4 @@ class JavaFxAccess {
// JAVA 8
return com.sun.javafx.tk.Toolkit.getToolkit().isFxUserThread();
}
public static
void onShutdown(final Runnable runnable) {
com.sun.javafx.tk.Toolkit.getToolkit().addShutdownHook(runnable);
}
}

View File

@ -79,9 +79,4 @@ class Swt {
boolean isEventThread() {
return SwtAccess.isEventThread();
}
public static
void onShutdown(final Runnable runnable) {
SwtAccess.onShutdown(runnable);
}
}

View File

@ -119,20 +119,4 @@ class SwtAccess {
boolean isEventThread() {
return Thread.currentThread() == currentDisplayThread;
}
static
void onShutdown(final Runnable runnable) {
// currentDisplay.getShells() must only be called inside the event thread!
if (isEventThread()) {
SwtAccess.onShutdown(currentDisplay, runnable);
} else {
dispatch(new Runnable() {
@Override
public
void run() {
SwtAccess.onShutdown(currentDisplay, runnable);
}
});
}
}
}

View File

@ -0,0 +1,33 @@
/*
* Copyright 2016 dorkbox, llc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dorkbox.javaFx;
/**
* Utility methods for JavaFX.
*/
public
class JavaFxAccess {
static
void dispatch(final Runnable runnable) {
javafx.application.Platform.runLater(runnable);
}
static
boolean isEventThread() {
// JAVA 9+
return javafx.application.Platform.isFxApplicationThread();
}
}

View File

@ -0,0 +1,24 @@
/*
* Copyright 2021 dorkbox, llc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dorkbox.swt;
/**
* Required for intellij to not complain regarding `module-info` for a multi-release jar.
* This file is completely ignored by the gradle build process
*/
public
class EmptyClass {}