From a538d8efe6eabdb91f99c2fdf5cbad720aa66adf Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Tue, 18 Sep 2018 09:56:09 +0200 Subject: [PATCH] Fix freezes in entry editor Fixes https://github.com/JabRef/jabref/issues/4323 and probably fixes https://github.com/JabRef/jabref/issues/4294 as well. The reason for the freezes were the pull-request https://bitbucket.org/controlsfx/controlsfx/pull-requests/710. These changes mess up the layout for some reason. The fix is to inject a DecorationPane ourselves directly from the beginning. Although this fix started as a workaround for this bug in controlsfx, I think, we should keep it permanently for performance reasons. --- src/main/java/org/jabref/JabRefGUI.java | 8 +++++++- .../java/org/jabref/gui/fieldeditors/PersonsEditor.java | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index b8669181f8e..ac996a79899 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -29,6 +29,7 @@ import org.jabref.model.database.shared.DatabaseNotSupportedException; import org.jabref.preferences.JabRefPreferences; +import impl.org.controlsfx.skin.DecorationPane; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -143,7 +144,12 @@ private void openWindow(Stage mainStage) { mainStage.setHeight(Globals.prefs.getDouble(JabRefPreferences.SIZE_Y)); } - Scene scene = new Scene(JabRefGUI.mainFrame, 800, 800); + // We create a decoration pane ourselves for performance reasons + // (otherwise it has to be injected later, leading to a complete redraw/relayout of the complete scene) + DecorationPane root = new DecorationPane(); + root.getChildren().add(JabRefGUI.mainFrame); + + Scene scene = new Scene(root, 800, 800); Globals.getThemeLoader().installBaseCss(scene, Globals.prefs); mainStage.setTitle(JabRefFrame.FRAME_TITLE); mainStage.getIcons().addAll(IconTheme.getLogoSetFX()); diff --git a/src/main/java/org/jabref/gui/fieldeditors/PersonsEditor.java b/src/main/java/org/jabref/gui/fieldeditors/PersonsEditor.java index 44f3cebc292..684d5a85dec 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/PersonsEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/PersonsEditor.java @@ -3,7 +3,6 @@ import javafx.scene.Parent; import javafx.scene.control.TextInputControl; import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; import org.jabref.gui.autocompleter.AutoCompleteSuggestionProvider; import org.jabref.gui.autocompleter.AutoCompletionTextInputBinding; @@ -27,7 +26,7 @@ public PersonsEditor(final String fieldName, textInput = isSingleLine ? new EditorTextField() : new EditorTextArea(); - HBox.setHgrow(textInput, Priority.ALWAYS); + textInput.textProperty().bindBidirectional(viewModel.textProperty()); ((ContextMenuAddable) textInput).addToContextMenu(EditorMenus.getNameMenu(textInput)); this.getChildren().add(textInput);