Skip to content

Commit 4b40cce

Browse files
authored
Change EasyBind dependency (#6480)
* Change EasyBind dependency * Fix tests
1 parent 6327e8a commit 4b40cce

File tree

56 files changed

+153
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+153
-154
lines changed

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ sourceSets {
8181
}
8282

8383
repositories {
84+
mavenLocal()
8485
jcenter()
8586
maven { url 'https://oss.sonatype.org/content/groups/public' }
8687
maven { url 'https://repository.apache.org/snapshots' }
@@ -158,7 +159,7 @@ dependencies {
158159
implementation 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-11'
159160
implementation 'de.saxsys:mvvmfx-validation:1.9.0-SNAPSHOT'
160161
implementation 'de.saxsys:mvvmfx:1.8.0'
161-
implementation 'org.fxmisc.easybind:easybind:1.0.3'
162+
implementation 'com.tobiasdiez:easybind:2.0.0-SNAPSHOT'
162163
implementation 'org.fxmisc.flowless:flowless:0.6.1'
163164
implementation 'org.fxmisc.richtext:richtextfx:0.10.5'
164165
implementation group: 'org.glassfish.hk2.external', name: 'jakarta.inject', version: '2.6.1'

src/main/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
requires de.jensd.fx.fontawesomefx.materialdesignicons;
2020
requires org.controlsfx.controls;
2121
requires org.fxmisc.richtext;
22+
requires com.tobiasdiez.easybind;
2223

2324
provides com.airhacks.afterburner.views.ResourceLocator
2425
with org.jabref.gui.util.JabRefResourceLocator;
@@ -51,7 +52,6 @@
5152
// Other modules
5253
requires commons.logging;
5354
requires com.google.common;
54-
requires easybind;
5555
requires jakarta.inject;
5656
requires org.apache.pdfbox;
5757
requires reactfx;

src/main/java/org/jabref/gui/BasePanel.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
import org.jabref.preferences.JabRefPreferences;
5151

5252
import com.google.common.eventbus.Subscribe;
53-
import org.fxmisc.easybind.EasyBind;
54-
import org.fxmisc.easybind.Subscription;
53+
import com.tobiasdiez.easybind.EasyBind;
54+
import com.tobiasdiez.easybind.Subscription;
5555
import org.slf4j.Logger;
5656
import org.slf4j.LoggerFactory;
5757

@@ -372,9 +372,9 @@ public void setupMainPanel() {
372372

373373
// Saves the divider position as soon as it changes
374374
// We need to keep a reference to the subscription, otherwise the binding gets garbage collected
375-
dividerPositionSubscription = EasyBind.monadic(Bindings.valueAt(splitPane.getDividers(), 0))
376-
.flatMap(SplitPane.Divider::positionProperty)
377-
.subscribe((observable, oldValue, newValue) -> saveDividerLocation(newValue));
375+
dividerPositionSubscription = EasyBind.wrapNullable(Bindings.valueAt(splitPane.getDividers(), 0))
376+
.mapObservable(SplitPane.Divider::positionProperty)
377+
.subscribeToValues(this::saveDividerLocation);
378378

379379
// Add changePane in case a file is present - otherwise just add the splitPane to the panel
380380
Optional<Path> file = bibDatabaseContext.getDatabasePath();
@@ -575,10 +575,6 @@ private boolean showDeleteConfirmationDialog(int numberOfEntries) {
575575
* preference setting.
576576
*/
577577
private void saveDividerLocation(Number position) {
578-
if (position == null) {
579-
return;
580-
}
581-
582578
if (mode == BasePanelMode.SHOWING_EDITOR) {
583579
preferences.setEntryEditorDividerPosition(position.doubleValue());
584580
}

src/main/java/org/jabref/gui/BasePanelPreferences.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
import org.jabref.preferences.JabRefPreferences;
1212
import org.jabref.preferences.PreviewPreferences;
1313

14-
import org.fxmisc.easybind.EasyBind;
14+
import com.tobiasdiez.easybind.EasyBind;
1515

1616
public class BasePanelPreferences {
17-
private MainTablePreferences tablePreferences;
17+
private final MainTablePreferences tablePreferences;
1818
private AutoCompletePreferences autoCompletePreferences;
19-
private EntryEditorPreferences entryEditorPreferences;
20-
private KeyBindingRepository keyBindings;
21-
private PreviewPreferences previewPreferences;
22-
private DoubleProperty entryEditorDividerPosition = new SimpleDoubleProperty();
19+
private final EntryEditorPreferences entryEditorPreferences;
20+
private final KeyBindingRepository keyBindings;
21+
private final PreviewPreferences previewPreferences;
22+
private final DoubleProperty entryEditorDividerPosition = new SimpleDoubleProperty();
2323

2424
public BasePanelPreferences(MainTablePreferences tablePreferences, AutoCompletePreferences autoCompletePreferences, EntryEditorPreferences entryEditorPreferences, KeyBindingRepository keyBindings, PreviewPreferences previewPreferences, Double entryEditorDividerPosition) {
2525
this.tablePreferences = tablePreferences;

src/main/java/org/jabref/gui/EntryTypeView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
import org.jabref.preferences.JabRefPreferences;
3535

3636
import com.airhacks.afterburner.views.ViewLoader;
37+
import com.tobiasdiez.easybind.EasyBind;
3738
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
38-
import org.fxmisc.easybind.EasyBind;
3939

4040
/**
4141
* Dialog that prompts the user to choose a type for an entry.

src/main/java/org/jabref/gui/JabRefDialogService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@
4646
import com.jfoenix.controls.JFXSnackbar;
4747
import com.jfoenix.controls.JFXSnackbar.SnackbarEvent;
4848
import com.jfoenix.controls.JFXSnackbarLayout;
49+
import com.tobiasdiez.easybind.EasyBind;
4950
import org.controlsfx.control.TaskProgressView;
5051
import org.controlsfx.dialog.ExceptionDialog;
5152
import org.controlsfx.dialog.ProgressDialog;
52-
import org.fxmisc.easybind.EasyBind;
5353
import org.slf4j.Logger;
5454
import org.slf4j.LoggerFactory;
5555

@@ -77,8 +77,8 @@ public class JabRefDialogService implements DialogService {
7777
public JabRefDialogService(Window mainWindow, Pane mainPane, JabRefPreferences preferences, ThemeLoader themeLoader) {
7878
this.mainWindow = mainWindow;
7979
this.statusLine = new JFXSnackbar(mainPane);
80-
this.preferences = preferences;
81-
this.themeLoader = themeLoader;
80+
JabRefDialogService.preferences = preferences;
81+
JabRefDialogService.themeLoader = themeLoader;
8282
}
8383

8484
private static FXDialog createDialog(AlertType type, String title, String content) {
@@ -293,7 +293,7 @@ public <V> void showProgressDialog(String title, String content, Task<V> task) {
293293

294294
@Override
295295
public <V> Optional<ButtonType> showBackgroundProgressDialogAndWait(String title, String content, StateManager stateManager) {
296-
TaskProgressView taskProgressView = new TaskProgressView<>();
296+
TaskProgressView<Task<?>> taskProgressView = new TaskProgressView<>();
297297
EasyBind.listBind(taskProgressView.getTasks(), stateManager.getBackgroundTasks());
298298
taskProgressView.setRetainTasks(false);
299299
taskProgressView.setGraphicFactory(BackgroundTask::getIcon);

src/main/java/org/jabref/gui/JabRefFrame.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import javafx.application.Platform;
1515
import javafx.beans.value.ChangeListener;
1616
import javafx.beans.value.ObservableValue;
17+
import javafx.concurrent.Task;
1718
import javafx.geometry.Orientation;
1819
import javafx.scene.Group;
1920
import javafx.scene.Node;
@@ -138,9 +139,9 @@
138139
import org.jabref.preferences.LastFocusedTabPreferences;
139140

140141
import com.google.common.eventbus.Subscribe;
142+
import com.tobiasdiez.easybind.EasyBind;
141143
import org.controlsfx.control.PopOver;
142144
import org.controlsfx.control.TaskProgressView;
143-
import org.fxmisc.easybind.EasyBind;
144145
import org.slf4j.Logger;
145146
import org.slf4j.LoggerFactory;
146147

@@ -982,7 +983,7 @@ hide it and clip it to a square of (width x width) each time width is updated.
982983
});
983984

984985
indicator.setOnMouseClicked(event -> {
985-
TaskProgressView taskProgressView = new TaskProgressView();
986+
TaskProgressView<Task<?>> taskProgressView = new TaskProgressView<>();
986987
EasyBind.listBind(taskProgressView.getTasks(), stateManager.getBackgroundTasks());
987988
taskProgressView.setRetainTasks(true);
988989
taskProgressView.setGraphicFactory(BackgroundTask::getIcon);

src/main/java/org/jabref/gui/actions/ActionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
import org.jabref.model.strings.StringUtil;
1717

1818
import com.sun.javafx.scene.control.ContextMenuContent;
19+
import com.tobiasdiez.easybind.EasyBind;
1920
import de.saxsys.mvvmfx.utils.commands.Command;
2021
import org.controlsfx.control.action.ActionUtils;
21-
import org.fxmisc.easybind.EasyBind;
2222
import org.slf4j.Logger;
2323
import org.slf4j.LoggerFactory;
2424

src/main/java/org/jabref/gui/actions/ActionHelper.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.List;
66
import java.util.Optional;
77

8+
import javafx.beans.binding.Binding;
89
import javafx.beans.binding.Bindings;
910
import javafx.beans.binding.BooleanExpression;
1011
import javafx.collections.ObservableList;
@@ -16,9 +17,7 @@
1617
import org.jabref.model.util.FileHelper;
1718
import org.jabref.preferences.PreferencesService;
1819

19-
import org.fxmisc.easybind.EasyBind;
20-
import org.fxmisc.easybind.monadic.MonadicBinding;
21-
import org.fxmisc.easybind.monadic.MonadicObservableValue;
20+
import com.tobiasdiez.easybind.EasyBind;
2221

2322
public class ActionHelper {
2423

@@ -41,18 +40,18 @@ public static BooleanExpression isFieldSetForSelectedEntry(Field field, StateMan
4140

4241
public static BooleanExpression isAnyFieldSetForSelectedEntry(List<Field> fields, StateManager stateManager) {
4342
ObservableList<BibEntry> selectedEntries = stateManager.getSelectedEntries();
44-
MonadicBinding<Boolean> fieldsAreSet = EasyBind.monadic(Bindings.valueAt(selectedEntries, 0))
45-
.flatMap(entry -> Bindings.createBooleanBinding(() -> {
43+
Binding<Boolean> fieldsAreSet = EasyBind.wrapNullable(Bindings.valueAt(selectedEntries, 0))
44+
.mapObservable(entry -> Bindings.createBooleanBinding(() -> {
4645
return entry.getFields().stream().anyMatch(fields::contains);
4746
}, entry.getFieldsObservable()))
48-
.orElse(false);
47+
.orElse(false);
4948
return BooleanExpression.booleanExpression(fieldsAreSet);
5049
}
5150

5251
public static BooleanExpression isFilePresentForSelectedEntry(StateManager stateManager, PreferencesService preferencesService) {
5352

5453
ObservableList<BibEntry> selectedEntries = stateManager.getSelectedEntries();
55-
MonadicObservableValue<Boolean> fileIsPresent = EasyBind.monadic(Bindings.valueAt(selectedEntries, 0)).map(entry -> {
54+
Binding<Boolean> fileIsPresent = EasyBind.wrapNullable(Bindings.valueAt(selectedEntries, 0)).map(entry -> {
5655
List<LinkedFile> files = entry.getFiles();
5756

5857
if ((entry.getFiles().size() > 0) && stateManager.getActiveDatabase().isPresent()) {

src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.jabref.logic.l10n.Localization;
2222
import org.jabref.model.database.BibDatabaseContext;
2323

24-
import org.fxmisc.easybind.EasyBind;
24+
import com.tobiasdiez.easybind.EasyBind;
2525

2626
class ChangeDisplayDialog extends BaseDialog<Boolean> {
2727

@@ -63,7 +63,7 @@ public ChangeDisplayDialog(BibDatabaseContext database, List<DatabaseChangeViewM
6363
leftScroll.setFitToWidth(true);
6464

6565
pane.getItems().addAll(leftScroll, infoPanel);
66-
pane.setResizableWithParent(leftScroll, false);
66+
SplitPane.setResizableWithParent(leftScroll, false);
6767

6868
getDialogPane().setContent(pane);
6969

0 commit comments

Comments
 (0)