diff --git a/build.gradle b/build.gradle index 7a9a8af2541..8f2df80ed2d 100644 --- a/build.gradle +++ b/build.gradle @@ -81,6 +81,7 @@ sourceSets { } repositories { + mavenLocal() jcenter() maven { url 'https://oss.sonatype.org/content/groups/public' } maven { url 'https://repository.apache.org/snapshots' } @@ -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' diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index c494250e6f2..acb5dd6e5ef 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -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; @@ -51,7 +52,6 @@ // Other modules requires commons.logging; requires com.google.common; - requires easybind; requires jakarta.inject; requires org.apache.pdfbox; requires reactfx; diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index 1e6d3a0ed74..7055194e48f 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -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; @@ -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 file = bibDatabaseContext.getDatabasePath(); @@ -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()); } diff --git a/src/main/java/org/jabref/gui/BasePanelPreferences.java b/src/main/java/org/jabref/gui/BasePanelPreferences.java index 56f8e356272..595bfc81740 100644 --- a/src/main/java/org/jabref/gui/BasePanelPreferences.java +++ b/src/main/java/org/jabref/gui/BasePanelPreferences.java @@ -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; diff --git a/src/main/java/org/jabref/gui/EntryTypeView.java b/src/main/java/org/jabref/gui/EntryTypeView.java index 476455469d8..5fe33bb6774 100644 --- a/src/main/java/org/jabref/gui/EntryTypeView.java +++ b/src/main/java/org/jabref/gui/EntryTypeView.java @@ -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. diff --git a/src/main/java/org/jabref/gui/JabRefDialogService.java b/src/main/java/org/jabref/gui/JabRefDialogService.java index b431a21c70c..25a56b5ff15 100644 --- a/src/main/java/org/jabref/gui/JabRefDialogService.java +++ b/src/main/java/org/jabref/gui/JabRefDialogService.java @@ -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; @@ -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) { @@ -293,7 +293,7 @@ public void showProgressDialog(String title, String content, Task task) { @Override public Optional showBackgroundProgressDialogAndWait(String title, String content, StateManager stateManager) { - TaskProgressView taskProgressView = new TaskProgressView<>(); + TaskProgressView> taskProgressView = new TaskProgressView<>(); EasyBind.listBind(taskProgressView.getTasks(), stateManager.getBackgroundTasks()); taskProgressView.setRetainTasks(false); taskProgressView.setGraphicFactory(BackgroundTask::getIcon); diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 67d97243523..47d6c35ab6b 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -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; @@ -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; @@ -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> taskProgressView = new TaskProgressView<>(); EasyBind.listBind(taskProgressView.getTasks(), stateManager.getBackgroundTasks()); taskProgressView.setRetainTasks(true); taskProgressView.setGraphicFactory(BackgroundTask::getIcon); diff --git a/src/main/java/org/jabref/gui/actions/ActionFactory.java b/src/main/java/org/jabref/gui/actions/ActionFactory.java index be72a1e7e40..d0b75659396 100644 --- a/src/main/java/org/jabref/gui/actions/ActionFactory.java +++ b/src/main/java/org/jabref/gui/actions/ActionFactory.java @@ -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; diff --git a/src/main/java/org/jabref/gui/actions/ActionHelper.java b/src/main/java/org/jabref/gui/actions/ActionHelper.java index b6b0415f59e..89f9b4e67ad 100644 --- a/src/main/java/org/jabref/gui/actions/ActionHelper.java +++ b/src/main/java/org/jabref/gui/actions/ActionHelper.java @@ -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; @@ -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 { @@ -41,18 +40,18 @@ public static BooleanExpression isFieldSetForSelectedEntry(Field field, StateMan public static BooleanExpression isAnyFieldSetForSelectedEntry(List fields, StateManager stateManager) { ObservableList selectedEntries = stateManager.getSelectedEntries(); - MonadicBinding fieldsAreSet = EasyBind.monadic(Bindings.valueAt(selectedEntries, 0)) - .flatMap(entry -> Bindings.createBooleanBinding(() -> { + Binding 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 selectedEntries = stateManager.getSelectedEntries(); - MonadicObservableValue fileIsPresent = EasyBind.monadic(Bindings.valueAt(selectedEntries, 0)).map(entry -> { + Binding fileIsPresent = EasyBind.wrapNullable(Bindings.valueAt(selectedEntries, 0)).map(entry -> { List files = entry.getFiles(); if ((entry.getFiles().size() > 0) && stateManager.getActiveDatabase().isPresent()) { diff --git a/src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java b/src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java index d5adf8673ed..e9f0751cc07 100644 --- a/src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java +++ b/src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java @@ -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 { @@ -63,7 +63,7 @@ public ChangeDisplayDialog(BibDatabaseContext database, List { diff --git a/src/main/java/org/jabref/gui/customentrytypes/CustomEntryTypeDialogViewModel.java b/src/main/java/org/jabref/gui/customentrytypes/CustomEntryTypeDialogViewModel.java index 95f4c62b469..86ecc9980b3 100644 --- a/src/main/java/org/jabref/gui/customentrytypes/CustomEntryTypeDialogViewModel.java +++ b/src/main/java/org/jabref/gui/customentrytypes/CustomEntryTypeDialogViewModel.java @@ -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 { @@ -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; diff --git a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerControl.java b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerControl.java index 4064601b705..75709e4f28b 100644 --- a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerControl.java +++ b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerControl.java @@ -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 currentPage = new SimpleObjectProperty<>(1); - private DoubleProperty scrollY = new SimpleDoubleProperty(); - private DoubleProperty scrollYMax = new SimpleDoubleProperty(); + private final ObjectProperty currentPage = new SimpleObjectProperty<>(1); + private final DoubleProperty scrollY = new SimpleDoubleProperty(); + private final DoubleProperty scrollYMax = new SimpleDoubleProperty(); private VirtualFlow flow; private PageDimension desiredPageDimension = PageDimension.ofFixedWidth(600); diff --git a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java index fb5299a3859..48097879406 100644 --- a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java +++ b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java @@ -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; @@ -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()); } diff --git a/src/main/java/org/jabref/gui/edit/ManageKeywordsDialog.java b/src/main/java/org/jabref/gui/edit/ManageKeywordsDialog.java index 2b1201fd24e..fe8112a6829 100644 --- a/src/main/java/org/jabref/gui/edit/ManageKeywordsDialog.java +++ b/src/main/java/org/jabref/gui/edit/ManageKeywordsDialog.java @@ -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 { private final List entries; diff --git a/src/main/java/org/jabref/gui/edit/ManageKeywordsViewModel.java b/src/main/java/org/jabref/gui/edit/ManageKeywordsViewModel.java index 2c4e3e01e6a..3cf44e966fb 100644 --- a/src/main/java/org/jabref/gui/edit/ManageKeywordsViewModel.java +++ b/src/main/java/org/jabref/gui/edit/ManageKeywordsViewModel.java @@ -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 { diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index c0a58e12319..7aba4446f67 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -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; diff --git a/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTab.java b/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTab.java index 727567965de..87658d4e46c 100644 --- a/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTab.java @@ -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 { diff --git a/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabView.java b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabView.java index b95b1d36596..849a6d1b0ee 100644 --- a/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabView.java +++ b/src/main/java/org/jabref/gui/entryeditor/fileannotationtab/FileAnnotationTabView.java @@ -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 { diff --git a/src/main/java/org/jabref/gui/errorconsole/ErrorConsoleViewModel.java b/src/main/java/org/jabref/gui/errorconsole/ErrorConsoleViewModel.java index b8bf04ea855..4ba3b30eccf 100644 --- a/src/main/java/org/jabref/gui/errorconsole/ErrorConsoleViewModel.java +++ b/src/main/java/org/jabref/gui/errorconsole/ErrorConsoleViewModel.java @@ -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; diff --git a/src/main/java/org/jabref/gui/exporter/ExportCustomizationDialogView.java b/src/main/java/org/jabref/gui/exporter/ExportCustomizationDialogView.java index 8a10a3dc97e..18e844536e9 100644 --- a/src/main/java/org/jabref/gui/exporter/ExportCustomizationDialogView.java +++ b/src/main/java/org/jabref/gui/exporter/ExportCustomizationDialogView.java @@ -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 { diff --git a/src/main/java/org/jabref/gui/externalfiles/FileDownloadTask.java b/src/main/java/org/jabref/gui/externalfiles/FileDownloadTask.java index 6880d8b7c0a..cb49f8f7f11 100644 --- a/src/main/java/org/jabref/gui/externalfiles/FileDownloadTask.java +++ b/src/main/java/org/jabref/gui/externalfiles/FileDownloadTask.java @@ -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 { diff --git a/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditorViewModel.java index 4e7c43f0c7b..b85942e0c25 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditorViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/IdentifierEditorViewModel.java @@ -23,15 +23,15 @@ import org.jabref.model.entry.field.Field; import org.jabref.model.entry.identifier.Identifier; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; public class IdentifierEditorViewModel extends AbstractEditorViewModel { - private BooleanProperty validIdentifierIsNotPresent = new SimpleBooleanProperty(true); - private BooleanProperty identifierLookupInProgress = new SimpleBooleanProperty(false); - private BooleanProperty idFetcherAvailable = new SimpleBooleanProperty(true); - private ObjectProperty> identifier = new SimpleObjectProperty<>(); - private TaskExecutor taskExecutor; - private DialogService dialogService; + private final BooleanProperty validIdentifierIsNotPresent = new SimpleBooleanProperty(true); + private final BooleanProperty identifierLookupInProgress = new SimpleBooleanProperty(false); + private final BooleanProperty idFetcherAvailable = new SimpleBooleanProperty(true); + private final ObjectProperty> identifier = new SimpleObjectProperty<>(); + private final TaskExecutor taskExecutor; + private final DialogService dialogService; public IdentifierEditorViewModel(Field field, SuggestionProvider suggestionProvider, TaskExecutor taskExecutor, DialogService dialogService, FieldCheckers fieldCheckers) { super(field, suggestionProvider, fieldCheckers); diff --git a/src/main/java/org/jabref/gui/fieldeditors/UrlEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/UrlEditorViewModel.java index 76f6f465ef0..5e2dfdb7cdd 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/UrlEditorViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/UrlEditorViewModel.java @@ -13,11 +13,11 @@ import org.jabref.model.entry.field.Field; import org.jabref.model.strings.StringUtil; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; public class UrlEditorViewModel extends AbstractEditorViewModel { - private DialogService dialogService; - private BooleanProperty validUrlIsNotPresent = new SimpleBooleanProperty(true); + private final DialogService dialogService; + private final BooleanProperty validUrlIsNotPresent = new SimpleBooleanProperty(true); public UrlEditorViewModel(Field field, SuggestionProvider suggestionProvider, DialogService dialogService, FieldCheckers fieldCheckers) { super(field, suggestionProvider, fieldCheckers); diff --git a/src/main/java/org/jabref/gui/filelist/LinkedFilesEditDialogViewModel.java b/src/main/java/org/jabref/gui/filelist/LinkedFilesEditDialogViewModel.java index c2cfd7fbc11..c28444b2a59 100644 --- a/src/main/java/org/jabref/gui/filelist/LinkedFilesEditDialogViewModel.java +++ b/src/main/java/org/jabref/gui/filelist/LinkedFilesEditDialogViewModel.java @@ -25,8 +25,8 @@ import org.jabref.model.util.FileHelper; import org.jabref.preferences.PreferencesService; -import org.fxmisc.easybind.EasyBind; -import org.fxmisc.easybind.monadic.MonadicObservableValue; +import com.tobiasdiez.easybind.EasyBind; +import com.tobiasdiez.easybind.optional.ObservableOptionalValue; public class LinkedFilesEditDialogViewModel extends AbstractViewModel { @@ -35,7 +35,7 @@ public class LinkedFilesEditDialogViewModel extends AbstractViewModel { private final StringProperty description = new SimpleStringProperty(""); private final ListProperty allExternalFileTypes = new SimpleListProperty<>(FXCollections.emptyObservableList()); private final ObjectProperty selectedExternalFileType = new SimpleObjectProperty<>(); - private final MonadicObservableValue monadicSelectedExternalFileType; + private final ObservableOptionalValue monadicSelectedExternalFileType; private final BibDatabaseContext database; private final DialogService dialogService; private final PreferencesService preferences; @@ -48,7 +48,7 @@ public LinkedFilesEditDialogViewModel(LinkedFile linkedFile, BibDatabaseContext this.externalFileTypes = externalFileTypes; allExternalFileTypes.set(FXCollections.observableArrayList(externalFileTypes.getExternalFileTypeSelection())); - monadicSelectedExternalFileType = EasyBind.monadic(selectedExternalFileType); + monadicSelectedExternalFileType = EasyBind.wrapNullable(selectedExternalFileType); setValues(linkedFile); } @@ -125,7 +125,7 @@ public ObjectProperty selectedExternalFileTypeProperty() { } public LinkedFile getNewLinkedFile() { - return new LinkedFile(description.getValue(), link.getValue(), monadicSelectedExternalFileType.map(ExternalFileType::toString).getOrElse("")); + return new LinkedFile(description.getValue(), link.getValue(), monadicSelectedExternalFileType.getValue().map(ExternalFileType::toString).orElse("")); } private String relativize(Path filePath) { diff --git a/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java index f4a4472bf41..a091683722f 100644 --- a/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupNodeViewModel.java @@ -38,8 +38,8 @@ import org.jabref.model.strings.StringUtil; import com.google.common.base.Enums; +import com.tobiasdiez.easybind.EasyBind; import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; -import org.fxmisc.easybind.EasyBind; public class GroupNodeViewModel { diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeView.java b/src/main/java/org/jabref/gui/groups/GroupTreeView.java index 8572ee5277e..ee6c69ce77f 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeView.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeView.java @@ -46,9 +46,9 @@ import org.jabref.model.groups.AllEntriesGroup; import org.jabref.preferences.PreferencesService; +import com.tobiasdiez.easybind.EasyBind; import org.controlsfx.control.textfield.CustomTextField; import org.controlsfx.control.textfield.TextFields; -import org.fxmisc.easybind.EasyBind; import org.reactfx.util.FxTimer; import org.reactfx.util.Timer; import org.slf4j.Logger; @@ -182,7 +182,7 @@ public void initialize() { // Add context menu (only for non-null items) row.contextMenuProperty().bind( - EasyBind.monadic(row.itemProperty()) + EasyBind.wrapNullable(row.itemProperty()) .map(this::createContextMenuForGroup) .orElse((ContextMenu) null)); row.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> { diff --git a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java index 1c57e43c41d..4ea073c297d 100644 --- a/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupTreeViewModel.java @@ -31,7 +31,7 @@ import org.jabref.model.metadata.MetaData; import org.jabref.preferences.PreferencesService; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; public class GroupTreeViewModel extends AbstractViewModel { diff --git a/src/main/java/org/jabref/gui/icon/JabRefIconView.java b/src/main/java/org/jabref/gui/icon/JabRefIconView.java index 3beff07dd98..60e3af62c5a 100644 --- a/src/main/java/org/jabref/gui/icon/JabRefIconView.java +++ b/src/main/java/org/jabref/gui/icon/JabRefIconView.java @@ -3,8 +3,8 @@ import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; +import com.tobiasdiez.easybind.EasyBind; import de.jensd.fx.glyphs.GlyphIcon; -import org.fxmisc.easybind.EasyBind; public class JabRefIconView extends GlyphIcon { @@ -12,7 +12,7 @@ public class JabRefIconView extends GlyphIcon { * This property is only needed to get proper IDE support in FXML files * (e.g. validation that parameter passed to "icon" is indeed of type {@link IconTheme.JabRefIcons}). */ - private ObjectProperty glyph; + private final ObjectProperty glyph; public JabRefIconView(IconTheme.JabRefIcons icon, String iconSize) { super(IconTheme.JabRefIcons.class); diff --git a/src/main/java/org/jabref/gui/importer/ImportCustomizationDialog.java b/src/main/java/org/jabref/gui/importer/ImportCustomizationDialog.java index 47cffbae4ae..6f535951846 100644 --- a/src/main/java/org/jabref/gui/importer/ImportCustomizationDialog.java +++ b/src/main/java/org/jabref/gui/importer/ImportCustomizationDialog.java @@ -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 ImportCustomizationDialog extends BaseDialog { diff --git a/src/main/java/org/jabref/gui/importer/ImportEntriesDialog.java b/src/main/java/org/jabref/gui/importer/ImportEntriesDialog.java index 17fc725077f..b6301f58aae 100644 --- a/src/main/java/org/jabref/gui/importer/ImportEntriesDialog.java +++ b/src/main/java/org/jabref/gui/importer/ImportEntriesDialog.java @@ -42,8 +42,8 @@ import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; +import com.tobiasdiez.easybind.EasyBind; import org.controlsfx.control.CheckListView; -import org.fxmisc.easybind.EasyBind; public class ImportEntriesDialog extends BaseDialog { @@ -60,7 +60,7 @@ public class ImportEntriesDialog extends BaseDialog { @Inject private PreferencesService preferences; @Inject private StateManager stateManager; @Inject private FileUpdateMonitor fileUpdateMonitor; - private BibDatabaseContext database; + private final BibDatabaseContext database; /** * Imports the given entries into the given database. The entries are provided using the BackgroundTask diff --git a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPane.java b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPane.java index c855506211d..64b005c2f1b 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPane.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPane.java @@ -25,7 +25,7 @@ import org.jabref.logic.l10n.Localization; import org.jabref.preferences.JabRefPreferences; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; public class WebSearchPane extends SidePaneComponent { diff --git a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java index 2bfdfa32545..342d7e61fc3 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/WebSearchPaneViewModel.java @@ -23,7 +23,7 @@ import org.jabref.model.strings.StringUtil; import org.jabref.preferences.JabRefPreferences; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; public class WebSearchPaneViewModel { diff --git a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsView.java b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsView.java index 56ca1475799..9de0c673925 100644 --- a/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsView.java +++ b/src/main/java/org/jabref/gui/journals/ManageJournalAbbreviationsView.java @@ -24,7 +24,7 @@ import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; /** * This class controls the user interface of the journal abbreviations dialog. The UI elements and their layout are diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogView.java b/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogView.java index 69528fc8927..21170bad2f1 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogView.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogView.java @@ -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 KeyBindingsDialogView extends BaseDialog { @@ -54,9 +54,9 @@ private void initialize() { keyBindingsTable.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); viewModel.selectedKeyBindingProperty().bind( - EasyBind.monadic(keyBindingsTable.selectionModelProperty()) - .flatMap(SelectionModel::selectedItemProperty) - .selectProperty(TreeItem::valueProperty) + EasyBind.wrapNullable(keyBindingsTable.selectionModelProperty()) + .mapObservable(SelectionModel::selectedItemProperty) + .mapObservable(TreeItem::valueProperty) ); keyBindingsTable.setOnKeyPressed(evt -> viewModel.setNewBindingForCurrent(evt)); keyBindingsTable.rootProperty().bind( diff --git a/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModel.java b/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModel.java index fb76d660499..6125b01230a 100644 --- a/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModel.java +++ b/src/main/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModel.java @@ -1,6 +1,7 @@ package org.jabref.gui.keyboard; import java.util.Objects; +import java.util.Optional; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; @@ -11,6 +12,7 @@ import org.jabref.gui.AbstractViewModel; import org.jabref.gui.DialogService; +import org.jabref.gui.util.OptionalObjectProperty; import org.jabref.logic.l10n.Localization; import org.jabref.preferences.PreferencesService; @@ -18,7 +20,7 @@ public class KeyBindingsDialogViewModel extends AbstractViewModel { private final KeyBindingRepository keyBindingRepository; private final PreferencesService preferences; - private final ObjectProperty selectedKeyBinding = new SimpleObjectProperty<>(); + private final OptionalObjectProperty selectedKeyBinding = OptionalObjectProperty.empty(); private final ObjectProperty rootKeyBinding = new SimpleObjectProperty<>(); private final DialogService dialogService; @@ -29,7 +31,7 @@ public KeyBindingsDialogViewModel(KeyBindingRepository keyBindingRepository, Dia populateTable(); } - public ObjectProperty selectedKeyBindingProperty() { + public OptionalObjectProperty selectedKeyBindingProperty() { return selectedKeyBinding; } @@ -56,12 +58,13 @@ private void populateTable() { } public void setNewBindingForCurrent(KeyEvent event) { - // first check if a valid entry is selected - if (selectedKeyBinding.isNull().get()) { + Optional selectedKeyBindingValue = selectedKeyBinding.getValue(); + if (selectedKeyBindingValue.isEmpty()) { return; } - KeyBindingViewModel selectedEntry = selectedKeyBinding.get(); - if ((selectedEntry == null) || (selectedEntry.isCategory())) { + + KeyBindingViewModel selectedEntry = selectedKeyBindingValue.get(); + if (selectedEntry.isCategory()) { return; } diff --git a/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java b/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java index 3db6023abe8..fd011a8cfdf 100644 --- a/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java +++ b/src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java @@ -26,8 +26,8 @@ import org.jabref.model.groups.AbstractGroup; import org.jabref.model.groups.GroupTreeNode; -import org.fxmisc.easybind.EasyBind; -import org.fxmisc.easybind.monadic.MonadicBinding; +import com.tobiasdiez.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBinding; public class BibEntryTableViewModel { private final BibEntry entry; @@ -35,7 +35,7 @@ public class BibEntryTableViewModel { private final MainTableNameFormatter nameFormatter; private final Map> fieldValues = new HashMap<>(); private final Map>> specialFieldValues = new HashMap<>(); - private final MonadicBinding> linkedFiles; + private final EasyBinding> linkedFiles; private final ObjectBinding> linkedIdentifiers; private final ObservableValue> matchedGroups; diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java index 5b18e6e3774..42cb1ddc4cb 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java @@ -54,8 +54,8 @@ import org.jabref.model.groups.AbstractGroup; import org.jabref.model.util.OptionalUtil; +import com.tobiasdiez.easybind.EasyBind; import org.controlsfx.control.Rating; -import org.fxmisc.easybind.EasyBind; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/jabref/gui/mergeentries/MergeEntries.java b/src/main/java/org/jabref/gui/mergeentries/MergeEntries.java index 6530d2aa257..eca551942e9 100644 --- a/src/main/java/org/jabref/gui/mergeentries/MergeEntries.java +++ b/src/main/java/org/jabref/gui/mergeentries/MergeEntries.java @@ -42,7 +42,7 @@ import org.jabref.model.entry.field.FieldFactory; import org.jabref.preferences.JabRefPreferences; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; public class MergeEntries extends BorderPane { diff --git a/src/main/java/org/jabref/gui/metadata/BibtexStringEditorDialogViewModel.java b/src/main/java/org/jabref/gui/metadata/BibtexStringEditorDialogViewModel.java index 4ede8938062..723342b0f0e 100644 --- a/src/main/java/org/jabref/gui/metadata/BibtexStringEditorDialogViewModel.java +++ b/src/main/java/org/jabref/gui/metadata/BibtexStringEditorDialogViewModel.java @@ -18,7 +18,7 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibtexString; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; public class BibtexStringEditorDialogViewModel extends AbstractViewModel { private static final String NEW_STRING_LABEL = "NewString"; // must not contain spaces diff --git a/src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java b/src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java index d4fac5b02ce..6f8da3c0083 100644 --- a/src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java +++ b/src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java @@ -28,7 +28,7 @@ import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; public class StyleSelectDialogView extends BaseDialog { diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialogView.java b/src/main/java/org/jabref/gui/preferences/PreferencesDialogView.java index 4c64b288280..46ed9b1c6f6 100644 --- a/src/main/java/org/jabref/gui/preferences/PreferencesDialogView.java +++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialogView.java @@ -19,8 +19,8 @@ import org.jabref.logic.l10n.Localization; import com.airhacks.afterburner.views.ViewLoader; +import com.tobiasdiez.easybind.EasyBind; import org.controlsfx.control.textfield.CustomTextField; -import org.fxmisc.easybind.EasyBind; /** * Preferences dialog. Contains a TabbedPane, and tabs will be defined in separate classes. Tabs MUST implement the @@ -37,7 +37,7 @@ public class PreferencesDialogView extends BaseDialog { diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java index 988ef5fcbd8..28ab38de947 100644 --- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java +++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java @@ -42,12 +42,12 @@ import org.jabref.model.database.shared.DatabaseNotSupportedException; import org.jabref.preferences.JabRefPreferences; +import com.tobiasdiez.easybind.EasyBind; import de.saxsys.mvvmfx.utils.validation.CompositeValidator; 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; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/jabref/gui/texparser/ParseLatexDialogView.java b/src/main/java/org/jabref/gui/texparser/ParseLatexDialogView.java index d5c1fb50920..e7719e66fa3 100644 --- a/src/main/java/org/jabref/gui/texparser/ParseLatexDialogView.java +++ b/src/main/java/org/jabref/gui/texparser/ParseLatexDialogView.java @@ -24,9 +24,9 @@ import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; +import com.tobiasdiez.easybind.EasyBind; import de.saxsys.mvvmfx.utils.validation.visualization.ControlsFxVisualizer; import org.controlsfx.control.CheckTreeView; -import org.fxmisc.easybind.EasyBind; public class ParseLatexDialogView extends BaseDialog { diff --git a/src/main/java/org/jabref/gui/texparser/ParseLatexResultView.java b/src/main/java/org/jabref/gui/texparser/ParseLatexResultView.java index 68cf53f7be7..286b33dc5f0 100644 --- a/src/main/java/org/jabref/gui/texparser/ParseLatexResultView.java +++ b/src/main/java/org/jabref/gui/texparser/ParseLatexResultView.java @@ -16,7 +16,7 @@ import org.jabref.model.texparser.LatexBibEntriesResolverResult; import com.airhacks.afterburner.views.ViewLoader; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; public class ParseLatexResultView extends BaseDialog { diff --git a/src/main/java/org/jabref/gui/util/BackgroundTask.java b/src/main/java/org/jabref/gui/util/BackgroundTask.java index 2b9e7b65d2a..3209fd7f0bd 100644 --- a/src/main/java/org/jabref/gui/util/BackgroundTask.java +++ b/src/main/java/org/jabref/gui/util/BackgroundTask.java @@ -21,7 +21,7 @@ import org.jabref.logic.l10n.Localization; import com.google.common.collect.ImmutableMap; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; /** * This class is essentially a wrapper around {@link Task}. @@ -41,12 +41,12 @@ public abstract class BackgroundTask { private Consumer onSuccess; private Consumer onException; private Runnable onFinished; - private BooleanProperty isCanceled = new SimpleBooleanProperty(false); - private ObjectProperty progress = new SimpleObjectProperty<>(new BackgroundProgress(0, 0)); - private StringProperty message = new SimpleStringProperty(""); - private StringProperty title = new SimpleStringProperty(this.getClass().getSimpleName()); - private DoubleProperty workDonePercentage = new SimpleDoubleProperty(0); - private BooleanProperty showToUser = new SimpleBooleanProperty(false); + private final BooleanProperty isCanceled = new SimpleBooleanProperty(false); + private final ObjectProperty progress = new SimpleObjectProperty<>(new BackgroundProgress(0, 0)); + private final StringProperty message = new SimpleStringProperty(""); + private final StringProperty title = new SimpleStringProperty(this.getClass().getSimpleName()); + private final DoubleProperty workDonePercentage = new SimpleDoubleProperty(0); + private final BooleanProperty showToUser = new SimpleBooleanProperty(false); public BackgroundTask() { workDonePercentage.bind(EasyBind.map(progress, BackgroundTask.BackgroundProgress::getWorkDonePercentage)); @@ -257,11 +257,8 @@ public BackgroundTask withInitialMessage(String message) { return this; } - public static Node getIcon(Object task) { - if (task instanceof Task) { - return BackgroundTask.iconMap.getOrDefault(((Task) task).getTitle(), null); - } - return null; + public static Node getIcon(Task task) { + return BackgroundTask.iconMap.getOrDefault(task.getTitle(), null); } static class BackgroundProgress { diff --git a/src/main/java/org/jabref/gui/util/BindingsHelper.java b/src/main/java/org/jabref/gui/util/BindingsHelper.java index a089ee7d770..d144bccff65 100644 --- a/src/main/java/org/jabref/gui/util/BindingsHelper.java +++ b/src/main/java/org/jabref/gui/util/BindingsHelper.java @@ -22,9 +22,9 @@ import javafx.css.PseudoClass; import javafx.scene.Node; -import org.fxmisc.easybind.EasyBind; -import org.fxmisc.easybind.PreboundBinding; -import org.fxmisc.easybind.Subscription; +import com.tobiasdiez.easybind.EasyBind; +import com.tobiasdiez.easybind.PreboundBinding; +import com.tobiasdiez.easybind.Subscription; /** * Helper methods for javafx binding. @@ -57,7 +57,7 @@ public static Subscription includePseudoClassWhen(Node node, PseudoClass pseudoC * Creates a new list in which each element is converted using the provided mapping. * All changes to the underlying list are propagated to the converted list. * - * In contrast to {@link org.fxmisc.easybind.EasyBind#map(ObservableList, Function)}, + * In contrast to {@link com.tobiasdiez.easybind.EasyBind#map(ObservableList, Function)}, * the items are converted when the are inserted (and at the initialization) instead of when they are accessed. * Thus the initial CPU overhead and memory consumption is higher but the access to list items is quicker. */ diff --git a/src/main/java/org/jabref/gui/util/OptionalObjectProperty.java b/src/main/java/org/jabref/gui/util/OptionalObjectProperty.java index f8e9e5d7263..c544126e74c 100644 --- a/src/main/java/org/jabref/gui/util/OptionalObjectProperty.java +++ b/src/main/java/org/jabref/gui/util/OptionalObjectProperty.java @@ -6,10 +6,10 @@ import javafx.beans.binding.ObjectBinding; import javafx.beans.property.SimpleObjectProperty; -import org.fxmisc.easybind.PreboundBinding; +import com.tobiasdiez.easybind.PreboundBinding; /** - * Similar to {@link org.fxmisc.easybind.monadic.MonadicObservableValue} + * Similar to {@link com.tobiasdiez.easybind.monadic.MonadicObservableValue} */ public class OptionalObjectProperty extends SimpleObjectProperty> { diff --git a/src/main/java/org/jabref/gui/util/ViewModelListCellFactory.java b/src/main/java/org/jabref/gui/util/ViewModelListCellFactory.java index 2e9be5c1ae1..851cddd3c92 100644 --- a/src/main/java/org/jabref/gui/util/ViewModelListCellFactory.java +++ b/src/main/java/org/jabref/gui/util/ViewModelListCellFactory.java @@ -22,8 +22,8 @@ import org.jabref.gui.icon.JabRefIcon; import org.jabref.model.strings.StringUtil; +import com.tobiasdiez.easybind.Subscription; import de.saxsys.mvvmfx.utils.validation.ValidationStatus; -import org.fxmisc.easybind.Subscription; /** * Constructs a {@link ListCell} based on the view model of the row and a bunch of specified converter methods. @@ -45,7 +45,7 @@ public class ViewModelListCellFactory implements Callback, ListCe private BiConsumer toOnDragEntered; private BiConsumer toOnDragExited; private BiConsumer toOnDragOver; - private Map>> pseudoClasses = new HashMap<>(); + private final Map>> pseudoClasses = new HashMap<>(); private Callback validationStatusProperty; public ViewModelListCellFactory withText(Callback toText) { diff --git a/src/main/java/org/jabref/gui/util/ViewModelTextFieldTableCellVisualizationFactory.java b/src/main/java/org/jabref/gui/util/ViewModelTextFieldTableCellVisualizationFactory.java index e042404213a..583d95cc7eb 100644 --- a/src/main/java/org/jabref/gui/util/ViewModelTextFieldTableCellVisualizationFactory.java +++ b/src/main/java/org/jabref/gui/util/ViewModelTextFieldTableCellVisualizationFactory.java @@ -16,8 +16,8 @@ import javafx.util.Callback; import javafx.util.StringConverter; +import com.tobiasdiez.easybind.Subscription; import de.saxsys.mvvmfx.utils.validation.ValidationStatus; -import org.fxmisc.easybind.Subscription; public class ViewModelTextFieldTableCellVisualizationFactory implements Callback, TableCell> { diff --git a/src/main/java/org/jabref/gui/util/component/Tag.java b/src/main/java/org/jabref/gui/util/component/Tag.java index 4a2661f0ba6..998f044eac5 100644 --- a/src/main/java/org/jabref/gui/util/component/Tag.java +++ b/src/main/java/org/jabref/gui/util/component/Tag.java @@ -12,14 +12,14 @@ import javafx.scene.layout.HBox; import com.airhacks.afterburner.views.ViewLoader; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; /** * A tag item in a {@link TagBar}. */ public class Tag extends HBox { - private ObjectProperty value; + private final ObjectProperty value; private Consumer tagRemovedConsumer; @FXML private Label text; diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java index 42a9a1b5d77..703a38dcd30 100644 --- a/src/main/java/org/jabref/model/entry/BibEntry.java +++ b/src/main/java/org/jabref/model/entry/BibEntry.java @@ -41,7 +41,7 @@ import com.google.common.base.Strings; import com.google.common.eventbus.EventBus; -import org.fxmisc.easybind.EasyBind; +import com.tobiasdiez.easybind.EasyBind; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/test/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModelTest.java b/src/test/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModelTest.java index 1bdc248771a..748a6554157 100644 --- a/src/test/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModelTest.java +++ b/src/test/java/org/jabref/gui/keyboard/KeyBindingsDialogViewModelTest.java @@ -1,5 +1,7 @@ package org.jabref.gui.keyboard; +import java.util.Optional; + import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCombination; import javafx.scene.input.KeyEvent; @@ -21,22 +23,22 @@ /** * Test class for the keybindings dialog view model */ -public class KeyBindingsDialogViewModelTest { +class KeyBindingsDialogViewModelTest { private KeyBindingsDialogViewModel model; private KeyBindingRepository keyBindingRepository; @BeforeEach - public void setUp() { + void setUp() { keyBindingRepository = new KeyBindingRepository(); model = new KeyBindingsDialogViewModel(keyBindingRepository, mock(DialogService.class), mock(PreferencesService.class)); } @Test - public void testInvalidKeyBindingIsNotSaved() { + void testInvalidKeyBindingIsNotSaved() { setKeyBindingViewModel(KeyBinding.COPY); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_RELEASED, "Q", "Q", KeyCode.Q, false, false, false, - false); + false); assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.COPY, shortcutKeyEvent)); model.setNewBindingForCurrent(shortcutKeyEvent); KeyCombination combination = KeyCombination.keyCombination(keyBindingRepository.get(KeyBinding.COPY).get()); @@ -46,16 +48,16 @@ public void testInvalidKeyBindingIsNotSaved() { } @Test - public void testSpecialKeysValidKeyBindingIsSaved() { + void testSpecialKeysValidKeyBindingIsSaved() { setKeyBindingViewModel(KeyBinding.IMPORT_INTO_NEW_DATABASE); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_RELEASED, "F1", "F1", KeyCode.F1, false, false, false, - false); + false); assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.IMPORT_INTO_NEW_DATABASE, - shortcutKeyEvent)); + shortcutKeyEvent)); model.setNewBindingForCurrent(shortcutKeyEvent); KeyCombination combination = KeyCombination - .keyCombination(keyBindingRepository.get(KeyBinding.IMPORT_INTO_NEW_DATABASE).get()); + .keyCombination(keyBindingRepository.get(KeyBinding.IMPORT_INTO_NEW_DATABASE).get()); assertTrue(KeyBindingRepository.checkKeyCombinationEquality(combination, shortcutKeyEvent)); @@ -66,17 +68,17 @@ public void testSpecialKeysValidKeyBindingIsSaved() { } @Test - public void testKeyBindingCategory() { + void testKeyBindingCategory() { KeyBindingViewModel bindViewModel = new KeyBindingViewModel(keyBindingRepository, KeyBindingCategory.FILE); - model.selectedKeyBindingProperty().set(bindViewModel); + model.selectedKeyBindingProperty().set(Optional.of(bindViewModel)); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "M", "M", KeyCode.M, true, true, true, false); assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.CLEANUP, shortcutKeyEvent)); model.setNewBindingForCurrent(shortcutKeyEvent); - assertNull(model.selectedKeyBindingProperty().get().getKeyBinding()); + assertNull(model.selectedKeyBindingProperty().get().get().getKeyBinding()); } @Test - public void testRandomNewKeyKeyBindingInRepository() { + void testRandomNewKeyKeyBindingInRepository() { setKeyBindingViewModel(KeyBinding.CLEANUP); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "K", "K", KeyCode.K, true, true, true, false); assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.CLEANUP, shortcutKeyEvent)); @@ -90,7 +92,7 @@ public void testRandomNewKeyKeyBindingInRepository() { } @Test - public void testSaveNewKeyBindingsToPreferences() { + void testSaveNewKeyBindingsToPreferences() { assumeFalse(OS.OS_X); setKeyBindingViewModel(KeyBinding.ABBREVIATE); @@ -104,10 +106,10 @@ public void testSaveNewKeyBindingsToPreferences() { } @Test - public void testSaveNewSpecialKeysKeyBindingsToPreferences() { + void testSaveNewSpecialKeysKeyBindingsToPreferences() { setKeyBindingViewModel(KeyBinding.ABBREVIATE); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "F1", "F1", KeyCode.F1, true, false, false, - false); + false); assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); model.setNewBindingForCurrent(shortcutKeyEvent); @@ -118,7 +120,7 @@ public void testSaveNewSpecialKeysKeyBindingsToPreferences() { } @Test - public void testSetAllKeyBindingsToDefault() { + void testSetAllKeyBindingsToDefault() { assumeFalse(OS.OS_X); setKeyBindingViewModel(KeyBinding.ABBREVIATE); @@ -138,9 +140,9 @@ public void testSetAllKeyBindingsToDefault() { } @Test - public void testCloseEntryEditorCloseEntryKeybinding() { + void testCloseEntryEditorCloseEntryKeybinding() { KeyBindingViewModel viewModel = setKeyBindingViewModel(KeyBinding.CLOSE); - model.selectedKeyBindingProperty().set(viewModel); + model.selectedKeyBindingProperty().set(Optional.of(viewModel)); KeyEvent closeEditorEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "", "", KeyCode.ESCAPE, false, false, false, false); assertEquals(KeyBinding.CLOSE.getDefaultKeyBinding(), KeyCode.ESCAPE.getName()); @@ -152,11 +154,11 @@ public void testCloseEntryEditorCloseEntryKeybinding() { } @Test - public void testSetSingleKeyBindingToDefault() { + void testSetSingleKeyBindingToDefault() { assumeFalse(OS.OS_X); KeyBindingViewModel viewModel = setKeyBindingViewModel(KeyBinding.ABBREVIATE); - model.selectedKeyBindingProperty().set(viewModel); + model.selectedKeyBindingProperty().set(Optional.of(viewModel)); KeyEvent shortcutKeyEvent = new KeyEvent(KeyEvent.KEY_PRESSED, "C", "C", KeyCode.C, true, true, true, false); assertFalse(keyBindingRepository.checkKeyCombinationEquality(KeyBinding.ABBREVIATE, shortcutKeyEvent)); @@ -173,8 +175,8 @@ public void testSetSingleKeyBindingToDefault() { } private KeyBindingViewModel setKeyBindingViewModel(KeyBinding binding) { - KeyBindingViewModel bindViewModel = new KeyBindingViewModel(keyBindingRepository, binding, binding.getDefaultKeyBinding()); - model.selectedKeyBindingProperty().set(bindViewModel); - return bindViewModel; + KeyBindingViewModel viewModel = new KeyBindingViewModel(keyBindingRepository, binding, binding.getDefaultKeyBinding()); + model.selectedKeyBindingProperty().set(Optional.of(viewModel)); + return viewModel; } }