Skip to content

Commit

Permalink
Change EasyBind dependency (#6480)
Browse files Browse the repository at this point in the history
* Change EasyBind dependency

* Fix tests
  • Loading branch information
tobiasdiez committed May 15, 2020
1 parent 6327e8a commit 4b40cce
Show file tree
Hide file tree
Showing 56 changed files with 153 additions and 154 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ sourceSets {
}

repositories {
mavenLocal()
jcenter()
maven { url 'https://oss.sonatype.org/content/groups/public' }
maven { url 'https://repository.apache.org/snapshots' }
Expand Down Expand Up @@ -158,7 +159,7 @@ dependencies {
implementation 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-11'
implementation 'de.saxsys:mvvmfx-validation:1.9.0-SNAPSHOT'
implementation 'de.saxsys:mvvmfx:1.8.0'
implementation 'org.fxmisc.easybind:easybind:1.0.3'
implementation 'com.tobiasdiez:easybind:2.0.0-SNAPSHOT'
implementation 'org.fxmisc.flowless:flowless:0.6.1'
implementation 'org.fxmisc.richtext:richtextfx:0.10.5'
implementation group: 'org.glassfish.hk2.external', name: 'jakarta.inject', version: '2.6.1'
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
requires de.jensd.fx.fontawesomefx.materialdesignicons;
requires org.controlsfx.controls;
requires org.fxmisc.richtext;
requires com.tobiasdiez.easybind;

provides com.airhacks.afterburner.views.ResourceLocator
with org.jabref.gui.util.JabRefResourceLocator;
Expand Down Expand Up @@ -51,7 +52,6 @@
// Other modules
requires commons.logging;
requires com.google.common;
requires easybind;
requires jakarta.inject;
requires org.apache.pdfbox;
requires reactfx;
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
import org.jabref.preferences.JabRefPreferences;

import com.google.common.eventbus.Subscribe;
import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.Subscription;
import com.tobiasdiez.easybind.EasyBind;
import com.tobiasdiez.easybind.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -372,9 +372,9 @@ public void setupMainPanel() {

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

// Add changePane in case a file is present - otherwise just add the splitPane to the panel
Optional<Path> file = bibDatabaseContext.getDatabasePath();
Expand Down Expand Up @@ -575,10 +575,6 @@ private boolean showDeleteConfirmationDialog(int numberOfEntries) {
* preference setting.
*/
private void saveDividerLocation(Number position) {
if (position == null) {
return;
}

if (mode == BasePanelMode.SHOWING_EDITOR) {
preferences.setEntryEditorDividerPosition(position.doubleValue());
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/jabref/gui/BasePanelPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
import org.jabref.preferences.JabRefPreferences;
import org.jabref.preferences.PreviewPreferences;

import org.fxmisc.easybind.EasyBind;
import com.tobiasdiez.easybind.EasyBind;

public class BasePanelPreferences {
private MainTablePreferences tablePreferences;
private final MainTablePreferences tablePreferences;
private AutoCompletePreferences autoCompletePreferences;
private EntryEditorPreferences entryEditorPreferences;
private KeyBindingRepository keyBindings;
private PreviewPreferences previewPreferences;
private DoubleProperty entryEditorDividerPosition = new SimpleDoubleProperty();
private final EntryEditorPreferences entryEditorPreferences;
private final KeyBindingRepository keyBindings;
private final PreviewPreferences previewPreferences;
private final DoubleProperty entryEditorDividerPosition = new SimpleDoubleProperty();

public BasePanelPreferences(MainTablePreferences tablePreferences, AutoCompletePreferences autoCompletePreferences, EntryEditorPreferences entryEditorPreferences, KeyBindingRepository keyBindings, PreviewPreferences previewPreferences, Double entryEditorDividerPosition) {
this.tablePreferences = tablePreferences;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/EntryTypeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import org.jabref.preferences.JabRefPreferences;

import com.airhacks.afterburner.views.ViewLoader;
import com.tobiasdiez.easybind.EasyBind;
import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer;
import org.fxmisc.easybind.EasyBind;

/**
* Dialog that prompts the user to choose a type for an entry.
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/jabref/gui/JabRefDialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
import com.jfoenix.controls.JFXSnackbar;
import com.jfoenix.controls.JFXSnackbar.SnackbarEvent;
import com.jfoenix.controls.JFXSnackbarLayout;
import com.tobiasdiez.easybind.EasyBind;
import org.controlsfx.control.TaskProgressView;
import org.controlsfx.dialog.ExceptionDialog;
import org.controlsfx.dialog.ProgressDialog;
import org.fxmisc.easybind.EasyBind;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -77,8 +77,8 @@ public class JabRefDialogService implements DialogService {
public JabRefDialogService(Window mainWindow, Pane mainPane, JabRefPreferences preferences, ThemeLoader themeLoader) {
this.mainWindow = mainWindow;
this.statusLine = new JFXSnackbar(mainPane);
this.preferences = preferences;
this.themeLoader = themeLoader;
JabRefDialogService.preferences = preferences;
JabRefDialogService.themeLoader = themeLoader;
}

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

@Override
public <V> Optional<ButtonType> showBackgroundProgressDialogAndWait(String title, String content, StateManager stateManager) {
TaskProgressView taskProgressView = new TaskProgressView<>();
TaskProgressView<Task<?>> taskProgressView = new TaskProgressView<>();
EasyBind.listBind(taskProgressView.getTasks(), stateManager.getBackgroundTasks());
taskProgressView.setRetainTasks(false);
taskProgressView.setGraphicFactory(BackgroundTask::getIcon);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Task;
import javafx.geometry.Orientation;
import javafx.scene.Group;
import javafx.scene.Node;
Expand Down Expand Up @@ -138,9 +139,9 @@
import org.jabref.preferences.LastFocusedTabPreferences;

import com.google.common.eventbus.Subscribe;
import com.tobiasdiez.easybind.EasyBind;
import org.controlsfx.control.PopOver;
import org.controlsfx.control.TaskProgressView;
import org.fxmisc.easybind.EasyBind;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

indicator.setOnMouseClicked(event -> {
TaskProgressView taskProgressView = new TaskProgressView();
TaskProgressView<Task<?>> taskProgressView = new TaskProgressView<>();
EasyBind.listBind(taskProgressView.getTasks(), stateManager.getBackgroundTasks());
taskProgressView.setRetainTasks(true);
taskProgressView.setGraphicFactory(BackgroundTask::getIcon);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/actions/ActionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import org.jabref.model.strings.StringUtil;

import com.sun.javafx.scene.control.ContextMenuContent;
import com.tobiasdiez.easybind.EasyBind;
import de.saxsys.mvvmfx.utils.commands.Command;
import org.controlsfx.control.action.ActionUtils;
import org.fxmisc.easybind.EasyBind;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
13 changes: 6 additions & 7 deletions src/main/java/org/jabref/gui/actions/ActionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.List;
import java.util.Optional;

import javafx.beans.binding.Binding;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanExpression;
import javafx.collections.ObservableList;
Expand All @@ -16,9 +17,7 @@
import org.jabref.model.util.FileHelper;
import org.jabref.preferences.PreferencesService;

import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.monadic.MonadicBinding;
import org.fxmisc.easybind.monadic.MonadicObservableValue;
import com.tobiasdiez.easybind.EasyBind;

public class ActionHelper {

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

public static BooleanExpression isAnyFieldSetForSelectedEntry(List<Field> fields, StateManager stateManager) {
ObservableList<BibEntry> selectedEntries = stateManager.getSelectedEntries();
MonadicBinding<Boolean> fieldsAreSet = EasyBind.monadic(Bindings.valueAt(selectedEntries, 0))
.flatMap(entry -> Bindings.createBooleanBinding(() -> {
Binding<Boolean> fieldsAreSet = EasyBind.wrapNullable(Bindings.valueAt(selectedEntries, 0))
.mapObservable(entry -> Bindings.createBooleanBinding(() -> {
return entry.getFields().stream().anyMatch(fields::contains);
}, entry.getFieldsObservable()))
.orElse(false);
.orElse(false);
return BooleanExpression.booleanExpression(fieldsAreSet);
}

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

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

if ((entry.getFiles().size() > 0) && stateManager.getActiveDatabase().isPresent()) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.model.database.BibDatabaseContext;

import org.fxmisc.easybind.EasyBind;
import com.tobiasdiez.easybind.EasyBind;

class ChangeDisplayDialog extends BaseDialog<Boolean> {

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

pane.getItems().addAll(leftScroll, infoPanel);
pane.setResizableWithParent(leftScroll, false);
SplitPane.setResizableWithParent(leftScroll, false);

getDialogPane().setContent(pane);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.jabref.model.entry.field.Field;

import com.airhacks.afterburner.views.ViewLoader;
import org.fxmisc.easybind.EasyBind;
import com.tobiasdiez.easybind.EasyBind;

public class ContentSelectorDialogView extends BaseDialog<Void> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
import org.jabref.model.entry.types.UnknownEntryType;
import org.jabref.preferences.PreferencesService;

import com.tobiasdiez.easybind.EasyBind;
import de.saxsys.mvvmfx.utils.validation.FunctionBasedValidator;
import de.saxsys.mvvmfx.utils.validation.ValidationMessage;
import de.saxsys.mvvmfx.utils.validation.ValidationStatus;
import de.saxsys.mvvmfx.utils.validation.Validator;
import org.fxmisc.easybind.EasyBind;

public class CustomEntryTypeDialogViewModel {

Expand Down Expand Up @@ -120,7 +120,7 @@ public enum FieldType {
REQUIRED(Localization.lang("Required")),
OPTIONAL(Localization.lang("Optional"));

private String name;
private final String name;

FieldType(String name) {
this.name = name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.TaskExecutor;

import org.fxmisc.easybind.EasyBind;
import com.tobiasdiez.easybind.EasyBind;
import org.fxmisc.flowless.Cell;
import org.fxmisc.flowless.VirtualFlow;
import org.fxmisc.flowless.VirtualFlowHit;

public class DocumentViewerControl extends StackPane {

private TaskExecutor taskExecutor;
private final TaskExecutor taskExecutor;

private ObjectProperty<Integer> currentPage = new SimpleObjectProperty<>(1);
private DoubleProperty scrollY = new SimpleDoubleProperty();
private DoubleProperty scrollYMax = new SimpleDoubleProperty();
private final ObjectProperty<Integer> currentPage = new SimpleObjectProperty<>(1);
private final DoubleProperty scrollY = new SimpleDoubleProperty();
private final DoubleProperty scrollYMax = new SimpleDoubleProperty();
private VirtualFlow<DocumentPageViewModel, DocumentViewerPage> flow;
private PageDimension desiredPageDimension = PageDimension.ofFixedWidth(600);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.LinkedFile;

import com.tobiasdiez.easybind.EasyBind;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.fxmisc.easybind.EasyBind;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -56,7 +56,7 @@ public DocumentViewerViewModel(StateManager stateManager) {
});

maxPages.bindBidirectional(
EasyBind.monadic(currentDocument).selectProperty(DocumentViewModel::maxPagesProperty));
EasyBind.wrapNullable(currentDocument).selectProperty(DocumentViewModel::maxPagesProperty));

setCurrentEntries(this.stateManager.getSelectedEntries());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.jabref.preferences.PreferencesService;

import com.airhacks.afterburner.views.ViewLoader;
import org.fxmisc.easybind.EasyBind;
import com.tobiasdiez.easybind.EasyBind;

public class ManageKeywordsDialog extends BaseDialog<Void> {
private final List<BibEntry> entries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.jabref.model.entry.KeywordList;
import org.jabref.preferences.PreferencesService;

import org.fxmisc.easybind.EasyBind;
import com.tobiasdiez.easybind.EasyBind;

public class ManageKeywordsViewModel {

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
import org.jabref.preferences.PreferencesService;

import com.airhacks.afterburner.views.ViewLoader;
import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.Subscription;
import com.tobiasdiez.easybind.EasyBind;
import com.tobiasdiez.easybind.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.preferences.PreferencesService;

import org.fxmisc.easybind.EasyBind;
import com.tobiasdiez.easybind.EasyBind;

public class LatexCitationsTab extends EntryEditorTab {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.model.util.FileUpdateMonitor;

import org.fxmisc.easybind.EasyBind;
import com.tobiasdiez.easybind.EasyBind;

public class FileAnnotationTabView {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import org.jabref.logic.util.BuildInfo;
import org.jabref.logic.util.OS;

import com.tobiasdiez.easybind.EasyBind;
import org.apache.http.client.utils.URIBuilder;
import org.apache.logging.log4j.core.LogEvent;
import org.fxmisc.easybind.EasyBind;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.jabref.preferences.PreferencesService;

import com.airhacks.afterburner.views.ViewLoader;
import org.fxmisc.easybind.EasyBind;
import com.tobiasdiez.easybind.EasyBind;

public class ExportCustomizationDialogView extends BaseDialog<Void> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.jabref.logic.net.ProgressInputStream;
import org.jabref.logic.net.URLDownload;

import org.fxmisc.easybind.EasyBind;
import com.tobiasdiez.easybind.EasyBind;

public class FileDownloadTask extends BackgroundTask<Path> {

Expand Down
Loading

0 comments on commit 4b40cce

Please sign in to comment.