fixes for javafx, keyword search, and image gallery issue

This commit is contained in:
Greg DiCristofaro 2022-11-14 15:17:56 -05:00
parent 2f5c66c7e5
commit 1d376eab39
3 changed files with 28 additions and 14 deletions

View File

@ -263,6 +263,13 @@ public class Installer extends ModuleInstall {
//initialize java fx if exists //initialize java fx if exists
System.setProperty("javafx.macosx.embedded", "true"); System.setProperty("javafx.macosx.embedded", "true");
try { try {
// Due to a lingering issue https://bugs.openjdk.org/browse/JDK-8223377 where glass.dll from java 8 gets loaded instead of the java 17 one.
String javaLibraryPath = "java.library.path";
String jvmBinPathStr = Paths.get(System.getProperty("java.home"), "bin").toAbsolutePath().toString();
String path = System.getProperty(javaLibraryPath);
System.setProperty(javaLibraryPath, StringUtils.isBlank(path) ? jvmBinPathStr : jvmBinPathStr + File.pathSeparator + path);
// Creating a JFXPanel initializes JavaFX // Creating a JFXPanel initializes JavaFX
new JFXPanel(); new JFXPanel();
Platform.setImplicitExit(false); Platform.setImplicitExit(false);

View File

@ -55,6 +55,11 @@ import org.xml.sax.SAXException;
*/ */
public class XMLUtil { public class XMLUtil {
static {
// this is to ensure using xalan for the transformer factory: https://stackoverflow.com/a/64364531/2375948
System.setProperty("javax.xml.transform.TransformerFactory","com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
}
private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException { private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException {
// See JIRA-6958 for details about class loading and jaxb. // See JIRA-6958 for details about class loading and jaxb.
ClassLoader original = Thread.currentThread().getContextClassLoader(); ClassLoader original = Thread.currentThread().getContextClassLoader();

View File

@ -46,6 +46,7 @@ import javafx.beans.binding.DoubleBinding;
import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
@ -662,24 +663,25 @@ public class GroupPane extends BorderPane {
private final DrawableTile tile = new DrawableTile(GroupPane.this, controller); private final DrawableTile tile = new DrawableTile(GroupPane.this, controller);
DrawableCell() { protected final ChangeListener<Long> changeListener = (ObservableValue<? extends Long> observable, Long oldValue, Long newValue) -> {
itemProperty().addListener((ObservableValue<? extends Long> observable, Long oldValue, Long newValue) -> { if ((oldValue == null && newValue == null) || (oldValue != null && newValue != null && oldValue.equals(newValue))) {
if (oldValue != null) { // if no change, do nothing
cellMap.remove(oldValue, DrawableCell.this); return;
tile.setFile(null);
} }
DrawableCell oldValueCell = oldValue == null ? null : cellMap.remove(oldValue);
if (oldValueCell != null) {
// remove change listener to get garbage collected
oldValueCell.itemProperty().removeListener(oldValueCell.changeListener);
}
if (newValue != null) { if (newValue != null) {
if (cellMap.containsKey(newValue)) {
if (tile != null) {
// Clear out the old value to prevent out-of-date listeners
// from activating.
cellMap.get(newValue).tile.setFile(null);
}
}
cellMap.put(newValue, DrawableCell.this); cellMap.put(newValue, DrawableCell.this);
} }
}); };
DrawableCell() {
itemProperty().addListener(changeListener);
setGraphic(tile); setGraphic(tile);
} }