diff --git a/.gitattributes b/.gitattributes index 27afdcafc40..d37562eb76a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -16,4 +16,4 @@ AUTHORS text eol=lf *.bib text !eol # disable after a release -# CHANGELOG.md merge=union +CHANGELOG.md merge=union diff --git a/.github/failure-csl-update b/.github/failure-csl-update.md similarity index 100% rename from .github/failure-csl-update rename to .github/failure-csl-update.md diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 9db09bcbbb7..fa8a4727a04 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -1,6 +1,6 @@ name: Deployment -on: [create, push] +on: [push] jobs: deploy: @@ -11,17 +11,17 @@ jobs: include: - os: ubuntu-latest displayName: linux - jpackageDownload: https://download.java.net/java/early_access/jpackage/1/openjdk-14-jpackage+1-70_linux-x64_bin.tar.gz + jpackageDownload: https://download.java.net/java/early_access/jdk14/27/GPL/openjdk-14-ea+27_linux-x64_bin.tar.gz jdk14Path: /jdk-14 archivePortable: tar -czf build/distribution/JabRef-portable_linux.tar.gz -C build/distribution JabRef && rm -R build/distribution/JabRef - os: windows-latest displayName: windows - jpackageDownload: https://download.java.net/java/early_access/jpackage/1/openjdk-14-jpackage+1-70_windows-x64_bin.zip + jpackageDownload: https://download.java.net/java/early_access/jdk14/27/GPL/openjdk-14-ea+27_windows-x64_bin.zip jdk14Path: /jdk-14 archivePortable: 7z a -r build/distribution/JabRef-portable_windows.zip ./build/distribution/JabRef && rm -R build/distribution/JabRef - os: macOS-latest displayName: macOS - jpackageDownload: https://download.java.net/java/early_access/jpackage/1/openjdk-14-jpackage+1-70_osx-x64_bin.tar.gz + jpackageDownload: https://download.java.net/java/early_access/jdk14/27/GPL/openjdk-14-ea+27_osx-x64_bin.tar.gz jdk14Path: /jdk-14.jdk/Contents/Home archivePortable: tar -czf build/distribution/JabRef-portable_macos.tar.gz -C build/distribution JabRef.app && rm -R build/distribution/JabRef.app diff --git a/CHANGELOG.md b/CHANGELOG.md index 72ddc0c3a0f..044b4edc5d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,18 +13,31 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ### Changed +### Fixed + +- We fixed an issue where the Medline fetcher was only working when JabRef was running from source [#5645](https://github.com/JabRef/jabref/issues/5645) +- We fixed some visual issues in the dark theme [#5764](https://github.com/JabRef/jabref/pull/5764) [#5753](https://github.com/JabRef/jabref/issues/5753) + +### Removed + + +## [5.0-beta] – 2019-12-15 + +### Changed + - We added a short DOI field formatter which shortens DOI to more human-readable form. [koppor#343](https://github.com/koppor/jabref/issues/343) - We improved the display of group memberships by adding multiple colored bars if the entry belongs to more than one group. [#4574](https://github.com/JabRef/jabref/issues/4574) - We added an option to show the preview as an extra tab in the entry editor (instead of in a split view). [#5244](https://github.com/JabRef/jabref/issues/5244) - A custom Open/LibreOffice jstyle file now requires a layout line for the entry type `default` [#5452](https://github.com/JabRef/jabref/issues/5452) - The entry editor is now open by default when JabRef starts up. [#5460](https://github.com/JabRef/jabref/issues/5460) - Customized entry types are now serialized in alphabetical order in the bib file. -- We added a new ADS fetcher to use the new ADS API [#4949](https://github.com/JabRef/jabref/issues/4949) +- We added a new ADS fetcher to use the new ADS API. [#4949](https://github.com/JabRef/jabref/issues/4949) - We added support of the [X11 primary selection](https://unix.stackexchange.com/a/139193/18033) [#2389](https://github.com/JabRef/jabref/issues/2389) - We added support to switch between biblatex and bibtex library types. [#5550](https://github.com/JabRef/jabref/issues/5550) - We changed the save action buttons to be easier to understand. [#5565](https://github.com/JabRef/jabref/issues/5565) - We made the columns for groups, files and uri in the main table reorderable and merged the clickable icon columns for uri, url, doi and eprint. [#5544](https://github.com/JabRef/jabref/pull/5544) - We reduced the number of write actions performed when autosave is enabled [#5679](https://github.com/JabRef/jabref/issues/5679) +- We made the column sort order in the main table persistent [#5730](https://github.com/JabRef/jabref/pull/5730) ### Fixed @@ -64,6 +77,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an exception which occurred when an invalid jstyle was loaded. [#5452](https://github.com/JabRef/jabref/issues/5452) - We fixed an issue where the command line arguments `importBibtex` and `importToOpen` did not import into the currently open library, but opened a new one. [#5537](https://github.com/JabRef/jabref/issues/5537) - We fixed an error where the preview theme did not adapt to the "Dark" mode [#5463](https://github.com/JabRef/jabref/issues/5463) +- We fixed an issue where multiple entries were allowed in the "crossref" field [#5284](https://github.com/JabRef/jabref/issues/5284) - We fixed an issue where the merge dialog showed the wrong text colour in "Dark" mode [#5516](https://github.com/JabRef/jabref/issues/5516) - We fixed visibility issues with the scrollbar and group selection highlight in "Dark" mode, and enabled "Dark" mode for the OpenOffice preview in the style selection window. [#5522](https://github.com/JabRef/jabref/issues/5522) - We fixed an issue where the author field was not correctly parsed during bibtex key-generation. [#5551](https://github.com/JabRef/jabref/issues/5551) @@ -83,52 +97,6 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We removed the option to control the default drag and drop behaviour. You can use the modifier keys (like CtrL or Alt) instead. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ## [5.0-alpha] – 2019-08-25 ### Changed @@ -283,5 +251,6 @@ The changelog of JabRef 4.x is available at the [v4.x branch](https://github.com The changelog of JabRef 3.x is available at the [v3.8.2 tag](https://github.com/JabRef/jabref/blob/v3.8.2/CHANGELOG.md). The changelog of JabRef 2.11 and all previous versions is available as [text file in the v2.11.1 tag](https://github.com/JabRef/jabref/blob/v2.11.1/CHANGELOG). -[Unreleased]: https://github.com/JabRef/jabref/compare/v5.0-alpha...HEAD +[Unreleased]: https://github.com/JabRef/jabref/compare/v5.0-beta...HEAD +[5.0-beta]: https://github.com/JabRef/jabref/compare/v5.0-alpha...v5.0-beta [5.0-alpha]: https://github.com/JabRef/jabref/compare/v4.3...v5.0-alpha diff --git a/GitVersion.yml b/GitVersion.yml index 726025e5e03..1047b572bdf 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,10 +1,9 @@ assembly-versioning-format: '{major}.{minor}.{WeightedPreReleaseNumber}' assembly-informational-format: '{major}.{minor}{PreReleaseTagWithDash}--{CommitDate}--{ShortSha}' +mode: ContinuousDeployment branches: master: regex: ^master - mode: ContinuousDelivery tag: beta - increment: Minor pre-release-weight: 30000 # 0 after stable release, 15000 before alpha release, 30000 before beta release, 50000 before stable release diff --git a/build.gradle b/build.gradle index 39a78043a13..8ab7c060340 100644 --- a/build.gradle +++ b/build.gradle @@ -206,15 +206,15 @@ dependencies { } - testCompile 'io.github.classgraph:classgraph:4.8.58' + testCompile 'io.github.classgraph:classgraph:4.8.59' testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2' testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.5.2' testCompile 'org.junit.platform:junit-platform-launcher:1.5.2' - testCompile 'net.bytebuddy:byte-buddy-parent:1.10.4' + testCompile 'net.bytebuddy:byte-buddy-parent:1.10.5' testRuntime group: 'org.apache.logging.log4j', name: 'log4j-core', version: '3.0.0-SNAPSHOT' testRuntime group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '3.0.0-SNAPSHOT' - testCompile 'org.mockito:mockito-core:3.2.0' + testCompile 'org.mockito:mockito-core:3.2.4' //testCompile 'com.github.tomakehurst:wiremock:2.24.1' testCompile 'org.xmlunit:xmlunit-core:2.6.3' testCompile 'org.xmlunit:xmlunit-matchers:2.6.3' @@ -249,20 +249,29 @@ dependencyUpdates.resolutionStrategy = { selection.reject('Release candidate') } } - rules.withModule("com.github.tomtung:latex2unicode_2.12") { ComponentSelection selection -> - if (selection.candidate.version ==~ /0.2.*/) { - // Reject version higher than 2.0.2. see https://github.com/JabRef/jabref/pull/3781 - selection.reject("Cannot be updated to 0.2.4 until JabRef is prepared for it") + rules.withModule("org.python:jython-standalone") { ComponentSelection selection -> + if (selection.candidate.version ==~ /2.7.2b2/) { + selection.reject('Release candidate') + } + } + rules.withModule("de.jensd:fontawesomefx-materialdesignfont") { ComponentSelection selection -> + if (selection.candidate.version ==~ /2.0.26-9.1.2/) { + selection.reject('1.7.22-11 is actually newer (strange version system)') + } + } + rules.withModule("org.javamodularity.moduleplugin:org.javamodularity.moduleplugin.gradle.plugin") { ComponentSelection selection -> + if (selection.candidate.version ==~ /1.6.0/) { + selection.reject("Does not work due to bug, see https://github.com/JabRef/jabref/pull/5270") } } - rules.withModule("com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin") { ComponentSelection selection -> - if (selection.candidate.version ==~ /4.*/) { - selection.reject("Version 4.X breaks the release process.") + rules.withModule("com.microsoft.azure:applicationinsights-core") { ComponentSelection selection -> + if (selection.candidate.version ==~ /2.5.1/) { + selection.reject("Does not work due to bug, see https://github.com/JabRef/jabref/pull/5596") } } - rules.withModule("com.google.errorprone:error_prone_core") { ComponentSelection selection -> - if (selection.candidate.version ==~ /2.3.3/) { - selection.reject("Does not work due to bug https://github.com/google/error-prone/issues/1240") + rules.withModule("com.microsoft.azure:applicationinsights-logging-log4j2") { ComponentSelection selection -> + if (selection.candidate.version ==~ /2.5.1/) { + selection.reject("Does not work due to bug, see https://github.com/JabRef/jabref/pull/5596") } } } @@ -597,6 +606,7 @@ jlink { uses 'com.airhacks.afterburner.injection.PresenterFactory' uses 'org.controlsfx.glyphfont.GlyphFont' uses 'com.airhacks.afterburner.views.ResourceLocator' + uses 'javax.xml.bind.JAXBContextFactory' provides 'java.sql.Driver' with 'org.postgresql.Driver' provides 'org.controlsfx.glyphfont.GlyphFont' with 'org.controlsfx.glyphfont.FontAwesome' provides 'org.apache.commons.logging.LogFactory' with 'org.apache.logging.log4j.jcl.LogFactoryImpl' diff --git a/src/main/java/org/jabref/gui/Base.css b/src/main/java/org/jabref/gui/Base.css index be03cf88f99..8a99e653b8a 100644 --- a/src/main/java/org/jabref/gui/Base.css +++ b/src/main/java/org/jabref/gui/Base.css @@ -211,6 +211,7 @@ /* The small thin light "shadow" for mark-like objects. Typically used in * conjunction with -fx-mark-color with an insets of 1 0 -1 0. */ + -fx-mark-color: -fx-text-base-color; -fx-mark-highlight-color: transparent; /*-fx-mark-highlight-color: derive(-fx-color,80%);*/ @@ -235,12 +236,16 @@ /** Focus line for keyboard focus traversal on cell based controls */ -fx-cell-focus-inner-border: derive(-fx-selection-bar,30%); - -fx-focused-mark-color : -fx-focused-text-base-color; + -fx-focused-mark-color: -fx-focused-text-base-color; /* Consistent size for headers of tab-pane and side-panels*/ -jr-header-height: 3em; } +#frame { + -fx-background-color: -jr-background-alt; +} + /* * The base css file defining the style that is valid for every pane and dialog. */ @@ -262,6 +267,9 @@ the text is always vertically centered within the bounds. Based on the cap height of the text. */ -fx-bounds-type: logical_vertical_center; + + /* The base color of icons should always be the same as the text. */ + -fx-fill: -fx-text-base-color; } .tooltip { @@ -385,7 +393,7 @@ } .check-box > .box { - -fx-border-color: rgba(0, 0, 0, 0.54); + -fx-border-color: -fx-outer-border; /* rgba(0, 0, 0, 0.54); */ -fx-border-width: 2px; -fx-border-radius: 1px; -fx-padding: 0.1em 0.1em 0.2em 0.2em; @@ -564,6 +572,10 @@ -fx-background-insets: 0; } +.table-view .groupColumnBackground { + -fx-stroke: -jr-gray-2; +} + .scroll-pane:focused, .split-pane:focused, .list-view:focused, @@ -1071,3 +1083,41 @@ We want to have a look that matches our icons in the tool-bar */ .dialog-pane { -fx-background-color: -fx-control-inner-background; } + +.code-area .text { + -fx-fill: -fx-text-background-color; +} + +.code-area .selection { + -fx-fill: -jr-accent; +} + +.code-area .caret { + -fx-stroke: -fx-text-background-color; +} + +.code-area .context-menu { + -fx-font-family: sans-serif; +} + +.citationsList { + -fx-text-fill: -fx-text-base-color; +} + +.citationsList .contextBox { + -fx-border-color: -fx-outer-border; + -fx-border-insets: 5; + -fx-border-style: dashed; + -fx-border-width: 2; + -fx-padding: 12; +} + +.citationsList .contextBox * { + -fx-fill: -fx-text-base-color; +} + +.citationsList .label { + -fx-font-family: monospace; + -fx-font-weight: bold; + -fx-label-padding: 5 0 10 10; +} diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index c0c9731f703..ff63746c6cc 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -991,10 +991,6 @@ public BibDatabaseContext getBibDatabaseContext() { return this.bibDatabaseContext; } - public void markExternalChangesAsResolved() { - changeMonitor.ifPresent(DatabaseChangeMonitor::markExternalChangesAsResolved); - } - public SidePaneManager getSidePaneManager() { return sidePaneManager; } @@ -1059,10 +1055,6 @@ public void resetChangeMonitorAndChangePane() { this.getChildren().setAll(changePane); } - public void updateTimeStamp() { - changeMonitor.ifPresent(DatabaseChangeMonitor::markAsSaved); - } - public void copy() { mainTable.copy(); } diff --git a/src/main/java/org/jabref/gui/Dark.css b/src/main/java/org/jabref/gui/Dark.css index 7da937c01c3..148677bfe0a 100644 --- a/src/main/java/org/jabref/gui/Dark.css +++ b/src/main/java/org/jabref/gui/Dark.css @@ -47,7 +47,7 @@ -jr-menu-forground-active: derive(-fx-light-text-color, 50%); -jr-scrollbar-thumb: derive(-fx-outer-border, -30%); - -jr-scrollbar-track: derive(-fx-control-inner-background, -90%); + -jr-scrollbar-track: derive(-fx-control-inner-background, -90%); -fx-focused-text-base-color: -fx-dark-text-color; @@ -59,6 +59,15 @@ color : #7d8591; /* -fx-mid-text-color*/ } +.table-view .groupColumnBackground { + -fx-stroke: -jr-gray-4; +} + +.code-area .lineno { + -fx-background-color: -jr-background-alt; + -fx-text-fill: -fx-mid-text-color; +} + .text-unchanged { -fx-fill: -fx-light-text-color; } @@ -73,4 +82,8 @@ .numberColumn > .hits:all-selected { -fx-background-color: -jr-gray-3; -} \ No newline at end of file +} + +#preferencesContainer .tab-pane > .tab-header-area > .tab-header-background { + -fx-background-color: -jr-background; +} diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 541da4646e2..7fd1df234f9 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -40,6 +40,7 @@ import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; import javafx.stage.Stage; import org.jabref.Globals; @@ -405,9 +406,10 @@ public boolean quit() { private void initLayout() { setProgressBarVisible(false); - BorderPane head = new BorderPane(); - head.setTop(createMenu()); - head.setCenter(createToolbar()); + setId("frame"); + + VBox head = new VBox(createMenu(),createToolbar()); + head.setSpacing(0d); setTop(head); splitPane.getItems().addAll(sidePane, tabbedPane); diff --git a/src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java b/src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java index c7989d2c005..091354fca14 100644 --- a/src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java +++ b/src/main/java/org/jabref/gui/collab/ChangeDisplayDialog.java @@ -44,12 +44,14 @@ public ChangeDisplayDialog(BibDatabaseContext database, List { - if (button == ButtonType.CANCEL) { + if (button == dismissChanges) { return false; } else { // Perform all accepted changes diff --git a/src/main/java/org/jabref/gui/collab/ChangeScanner.java b/src/main/java/org/jabref/gui/collab/ChangeScanner.java index 284bc35cf58..97dde224108 100644 --- a/src/main/java/org/jabref/gui/collab/ChangeScanner.java +++ b/src/main/java/org/jabref/gui/collab/ChangeScanner.java @@ -10,8 +10,8 @@ import org.jabref.logic.bibtex.comparator.BibEntryDiff; import org.jabref.logic.bibtex.comparator.BibStringDiff; import org.jabref.logic.importer.ImportFormatPreferences; +import org.jabref.logic.importer.OpenDatabase; import org.jabref.logic.importer.ParserResult; -import org.jabref.logic.importer.fileformat.BibtexImporter; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.util.DummyFileUpdateMonitor; @@ -36,9 +36,9 @@ public List scanForChanges() { List changes = new ArrayList<>(); // Parse the modified file + // Important: apply all post-load actions ImportFormatPreferences importFormatPreferences = Globals.prefs.getImportFormatPreferences(); - ParserResult result = new BibtexImporter(importFormatPreferences, new DummyFileUpdateMonitor()) - .importDatabase(database.getDatabasePath().get(), importFormatPreferences.getEncoding()); + ParserResult result = OpenDatabase.loadDatabase(database.getDatabasePath().get(), importFormatPreferences, new DummyFileUpdateMonitor()); BibDatabaseContext databaseOnDisk = result.getDatabaseContext(); // Start looking at changes. diff --git a/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java b/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java index 0db0316af73..f43a5b0cc54 100644 --- a/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java +++ b/src/main/java/org/jabref/gui/collab/DatabaseChangeMonitor.java @@ -1,14 +1,11 @@ package org.jabref.gui.collab; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; import java.util.ArrayList; import java.util.List; import org.jabref.gui.util.BackgroundTask; import org.jabref.gui.util.TaskExecutor; -import org.jabref.logic.util.io.FileUtil; import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.util.FileUpdateListener; import org.jabref.model.util.FileUpdateMonitor; @@ -22,7 +19,6 @@ public class DatabaseChangeMonitor implements FileUpdateListener { private final BibDatabaseContext database; private final FileUpdateMonitor fileMonitor; private final List listeners; - private Path referenceFile; private TaskExecutor taskExecutor; public DatabaseChangeMonitor(BibDatabaseContext database, FileUpdateMonitor fileMonitor, TaskExecutor taskExecutor) { @@ -34,9 +30,6 @@ public DatabaseChangeMonitor(BibDatabaseContext database, FileUpdateMonitor file this.database.getDatabasePath().ifPresent(path -> { try { fileMonitor.addListenerForFile(path, this); - referenceFile = Files.createTempFile("jabref", ".bib"); - referenceFile.toFile().deleteOnExit(); - setAsReference(path); } catch (IOException e) { LOGGER.error("Error while trying to monitor " + path, e); } @@ -64,15 +57,4 @@ public void unregister() { database.getDatabasePath().ifPresent(file -> fileMonitor.removeListener(file, this)); } - public void markExternalChangesAsResolved() { - markAsSaved(); - } - - public void markAsSaved() { - database.getDatabasePath().ifPresent(this::setAsReference); - } - - private void setAsReference(Path file) { - FileUtil.copyFile(file, referenceFile, true); - } } diff --git a/src/main/java/org/jabref/gui/collab/DatabaseChangePane.java b/src/main/java/org/jabref/gui/collab/DatabaseChangePane.java index 17582a41ba9..a879f81489a 100644 --- a/src/main/java/org/jabref/gui/collab/DatabaseChangePane.java +++ b/src/main/java/org/jabref/gui/collab/DatabaseChangePane.java @@ -30,16 +30,13 @@ public DatabaseChangePane(Node parent, BibDatabaseContext database, DatabaseChan private void onDatabaseChanged(List changes) { this.getActions().setAll( new Action(Localization.lang("Dismiss changes"), event -> { - monitor.markExternalChangesAsResolved(); this.hide(); }), new Action(Localization.lang("Review changes"), event -> { ChangeDisplayDialog changeDialog = new ChangeDisplayDialog(database, changes); - boolean changesHandled = changeDialog.showAndWait().orElse(false); - if (changesHandled) { - monitor.markExternalChangesAsResolved(); - this.hide(); - } + changeDialog.showAndWait(); + + this.hide(); })); this.show(); } diff --git a/src/main/java/org/jabref/gui/collab/EntryAddChangeViewModel.java b/src/main/java/org/jabref/gui/collab/EntryAddChangeViewModel.java index 45832985b5b..cb41f3d4d0a 100644 --- a/src/main/java/org/jabref/gui/collab/EntryAddChangeViewModel.java +++ b/src/main/java/org/jabref/gui/collab/EntryAddChangeViewModel.java @@ -13,23 +13,27 @@ class EntryAddChangeViewModel extends DatabaseChangeViewModel { - private final BibEntry diskEntry; + private final BibEntry entry; - public EntryAddChangeViewModel(BibEntry diskEntry) { - super(Localization.lang("Added entry")); - this.diskEntry = diskEntry; + public EntryAddChangeViewModel(BibEntry entry) { + super(); + this.name = entry.getCiteKeyOptional() + .map(key -> Localization.lang("Added entry") + ": '" + key + '\'') + .orElse(Localization.lang("Added entry")); + this.entry = entry; } @Override public void makeChange(BibDatabaseContext database, NamedCompound undoEdit) { - database.getDatabase().insertEntry(diskEntry); - undoEdit.addEdit(new UndoableInsertEntry(database.getDatabase(), diskEntry)); + database.getDatabase().insertEntry(entry); + undoEdit.addEdit(new UndoableInsertEntry(database.getDatabase(), entry)); } @Override public Node description() { PreviewViewer previewViewer = new PreviewViewer(new BibDatabaseContext(), JabRefGUI.getMainFrame().getDialogService(), Globals.stateManager); - previewViewer.setEntry(diskEntry); + previewViewer.setLayout(Globals.prefs.getPreviewPreferences().getCurrentPreviewStyle()); + previewViewer.setEntry(entry); return previewViewer; } } diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.css b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.css index 799644a9839..e53c688a081 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.css +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.css @@ -41,10 +41,6 @@ -fx-font-weight: normal; } -.code-area .context-menu { - -fx-font-family: sans-serif; -} - .icon-button.narrow { -fx-padding: 0.1em; } @@ -90,35 +86,59 @@ -fx-background-color: -jr-error; } -.code-area .text { - -fx-fill: -fx-text-background-color; +.code-area .context-menu { + -fx-font-family: sans-serif; } -.gdpr-dialog { - -fx-font-size: 14pt; +#related-articles-tab { + -fx-padding: 20 20 20 20; + -fx-background-color: -fx-control-inner-background; } -.related-articles-tab { - -fx-padding: 20 20 20 20; +#related-articles-tab * { + -fx-fill: -fx-text-background-color; } -.recommendation-heading { - -fx-font-size: 14pt; - -fx-font-weight: bold; +#gdpr-dialog { + -fx-border-color: -jr-warn; + -fx-border-insets: 5; + -fx-border-style: dashed; + -fx-border-width: 2; + -fx-padding: 12; + -fx-font-size: 1.3em; } -.recommendation-description { - -fx-font-style: italic; +#gdpr-dialog * { + -fx-fill: -fx-text-background-color; } .recommendation-item { -fx-padding: 0 0 0 20; } +#bibtexSourceCodeArea { + -fx-padding: 4 4 4 4; + -fx-background-color: -fx-control-inner-background; +} + #bibtexSourceCodeArea .search { -fx-fill: red; } -.bibtexSourceCodeArea .text { +#citationsPane { + -fx-padding: 0; + -fx-background-color: -fx-control-inner-background; +} + +#citationsPane * { -fx-fill: -fx-text-background-color; } + +.heading { + -fx-font-size: 1.5em; + -fx-font-weight: bold; +} + +.description { + -fx-font-style: italic; +} diff --git a/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTab.java b/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTab.java index 5ba9cd7ad6f..727567965de 100644 --- a/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTab.java @@ -62,6 +62,7 @@ private void setSearchPane() { searchPane.getColumnConstraints().setAll(column); searchPane.getRowConstraints().setAll(mainRow, bottomRow); + searchPane.setId("citationsPane"); setContent(searchPane); EasyBind.subscribe(viewModel.statusProperty(), status -> { @@ -86,11 +87,9 @@ private void setSearchPane() { private HBox getLatexDirectoryBox() { Text latexDirectoryText = new Text(Localization.lang("Current search directory:")); - latexDirectoryText.setStyle("-fx-font-size: 0.9em;-fx-padding: 0;"); Text latexDirectoryPath = new Text(viewModel.directoryProperty().get().toString()); - latexDirectoryPath.setStyle("-fx-font-family: 'Courier New', Courier, monospace;-fx-font-size: 0.9em;-fx-font-weight: bold;"); + latexDirectoryPath.setStyle("-fx-font-family:monospace;-fx-font-weight: bold;"); Button latexDirectoryButton = new Button(Localization.lang("Set LaTeX file directory")); - latexDirectoryButton.setStyle("-fx-border-width: 1;-fx-font-size: 0.85em;-fx-padding: 0.2em;"); latexDirectoryButton.setGraphic(IconTheme.JabRefIcons.LATEX_FILE_DIRECTORY.getGraphicNode()); latexDirectoryButton.setOnAction(event -> viewModel.setLatexDirectory()); HBox latexDirectoryBox = new HBox(10, latexDirectoryText, latexDirectoryPath, latexDirectoryButton); @@ -106,8 +105,11 @@ private VBox getCitationsPane() { private VBox getNotFoundPane() { Label titleLabel = new Label(Localization.lang("No citations found")); - titleLabel.setStyle("-fx-font-size: 1.5em;-fx-font-weight: bold;-fx-text-fill: -jr-theme-text;"); + titleLabel.getStyleClass().add("heading"); + Text notFoundText = new Text(Localization.lang("No LaTeX files containing this entry were found.")); + notFoundText.getStyleClass().add("description"); + VBox notFoundBox = new VBox(30, titleLabel, notFoundText); notFoundBox.setStyle("-fx-padding: 30 0 0 30;"); return notFoundBox; diff --git a/src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java b/src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java index 045fca0613c..d1174993247 100644 --- a/src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java @@ -3,6 +3,8 @@ import java.io.IOException; import java.util.List; +import javafx.beans.binding.Bindings; +import javafx.beans.binding.DoubleBinding; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.Hyperlink; @@ -54,7 +56,7 @@ public RelatedArticlesTab(EntryEditor entryEditor, EntryEditorPreferences prefer */ private StackPane getRelatedArticlesPane(BibEntry entry) { StackPane root = new StackPane(); - root.getStyleClass().add("related-articles-tab"); + root.setId("related-articles-tab"); ProgressIndicator progress = new ProgressIndicator(); progress.setMaxSize(100, 100); @@ -92,10 +94,10 @@ private ScrollPane getRelatedArticleInfo(List list, MrDLibFetcher fetc String heading = fetcher.getHeading(); Text headingText = new Text(heading); - headingText.getStyleClass().add("recommendation-heading"); + headingText.getStyleClass().add("heading"); String description = fetcher.getDescription(); Text descriptionText = new Text(description); - descriptionText.getStyleClass().add("recommendation-description"); + descriptionText.getStyleClass().add("description"); vBox.getChildren().add(headingText); vBox.getChildren().add(descriptionText); @@ -143,7 +145,7 @@ private ScrollPane getErrorInfo() { vBox.setSpacing(20.0); Text descriptionText = new Text(Localization.lang("No recommendations received from Mr. DLib for this entry.")); - descriptionText.getStyleClass().add("recommendation-description"); + descriptionText.getStyleClass().add("description"); vBox.getChildren().add(descriptionText); scrollPane.setContent(vBox); @@ -157,20 +159,26 @@ private ScrollPane getErrorInfo() { */ private ScrollPane getPrivacyDialog(BibEntry entry) { ScrollPane root = new ScrollPane(); - root.getStyleClass().add("related-articles-tab"); + root.setId("related-articles-tab"); VBox vbox = new VBox(); - vbox.getStyleClass().add("gdpr-dialog"); + vbox.setId("gdpr-dialog"); vbox.setSpacing(20.0); + Text title = new Text(Localization.lang("Mr. DLib Privacy settings")); + title.getStyleClass().add("heading"); + Button button = new Button(Localization.lang("I Agree")); button.setDefaultButton(true); + DoubleBinding rootWidth = Bindings.subtract(root.widthProperty(),88d); + Text line1 = new Text(Localization.lang("JabRef requests recommendations from Mr. DLib, which is an external service. To enable Mr. DLib to calculate recommendations, some of your data must be shared with Mr. DLib. Generally, the more data is shared the better recommendations can be calculated. However, we understand that some of your data in JabRef is sensitive, and you may not want to share it. Therefore, Mr. DLib offers a choice of which data you would like to share.")); - line1.setWrappingWidth(1300.0); + line1.wrappingWidthProperty().bind(rootWidth); Text line2 = new Text(Localization.lang("Whatever option you choose, Mr. DLib may share its data with research partners to further improve recommendation quality as part of a 'living lab'. Mr. DLib may also release public datasets that may contain anonymized information about you and the recommendations (sensitive information such as metadata of your articles will be anonymised through e.g. hashing). Research partners are obliged to adhere to the same strict data protection policy as Mr. DLib.")); - line2.setWrappingWidth(1300.0); + line2.wrappingWidthProperty().bind(rootWidth); Text line3 = new Text(Localization.lang("This setting may be changed in preferences at any time.")); - Hyperlink mdlLink = new Hyperlink(Localization.lang("Further information about Mr DLib. for JabRef users.")); + line3.wrappingWidthProperty().bind(rootWidth); + Hyperlink mdlLink = new Hyperlink(Localization.lang("Further information about Mr. DLib for JabRef users.")); mdlLink.setOnAction(event -> { try { JabRefDesktop.openBrowser("http://mr-dlib.org/information-for-users/information-about-mr-dlib-for-jabref-users/"); @@ -202,7 +210,7 @@ private ScrollPane getPrivacyDialog(BibEntry entry) { setContent(getRelatedArticlesPane(entry)); }); - vbox.getChildren().addAll(line1, line2, mdlLink, line3, vb, button); + vbox.getChildren().addAll(title, line1, line2, mdlLink, line3, vb, button); root.setContent(vbox); return root; diff --git a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java index f3b55ea48ec..f131795a608 100644 --- a/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java +++ b/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java @@ -135,14 +135,12 @@ private boolean doSave() { SavePreferences.DatabaseSaveType.ALL); if (success) { - panel.updateTimeStamp(); panel.getUndoManager().markUnchanged(); // (Only) after a successful save the following // statement marks that the base is unchanged // since last save: panel.setNonUndoableChange(false); panel.setBaseChanged(false); - panel.markExternalChangesAsResolved(); // Reset title of tab frame.setTabTitle(panel, panel.getTabTitle(), diff --git a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java index d44cb882aad..77c02ef2e2d 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java +++ b/src/main/java/org/jabref/gui/fieldeditors/FieldEditors.java @@ -84,7 +84,9 @@ public static FieldEditorFX getForField(final Field field, } else { return new OptionEditor<>(new TypeEditorViewModel(field, suggestionProvider, fieldCheckers)); } - } else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK) || fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) { + } else if (fieldProperties.contains(FieldProperty.SINGLE_ENTRY_LINK)) { + return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers); + } else if (fieldProperties.contains(FieldProperty.MULTIPLE_ENTRY_LINK)) { return new LinkedEntriesEditor(field, databaseContext, suggestionProvider, fieldCheckers); } else if (fieldProperties.contains(FieldProperty.PERSON_NAMES)) { return new PersonsEditor(field, suggestionProvider, preferences, fieldCheckers, isSingleLine); diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java index 1f3b2b143a6..f510063ee90 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedEntriesEditor.java @@ -18,16 +18,19 @@ public class LinkedEntriesEditor extends HBox implements FieldEditorFX { - @FXML private final LinkedEntriesEditorViewModel viewModel; - @FXML private TagBar linkedEntriesBar; + @FXML + private final LinkedEntriesEditorViewModel viewModel; + @FXML + private TagBar linkedEntriesBar; public LinkedEntriesEditor(Field field, BibDatabaseContext databaseContext, AutoCompleteSuggestionProvider suggestionProvider, FieldCheckers fieldCheckers) { this.viewModel = new LinkedEntriesEditorViewModel(field, suggestionProvider, databaseContext, fieldCheckers); ViewLoader.view(this) - .root(this) - .load(); + .root(this) + .load(); + linkedEntriesBar.setFieldProperties(field.getProperties()); linkedEntriesBar.setStringConverter(viewModel.getStringConverter()); linkedEntriesBar.setOnTagClicked((parsedEntryLink, mouseEvent) -> viewModel.jumpToEntry(parsedEntryLink)); diff --git a/src/main/java/org/jabref/gui/importer/actions/AppendDatabaseAction.java b/src/main/java/org/jabref/gui/importer/actions/AppendDatabaseAction.java index 5e9d0fa323d..3e066cdece8 100644 --- a/src/main/java/org/jabref/gui/importer/actions/AppendDatabaseAction.java +++ b/src/main/java/org/jabref/gui/importer/actions/AppendDatabaseAction.java @@ -179,7 +179,7 @@ private String openIt(Path file, boolean importEntries, boolean importStrings, b boolean importSelectorWords) throws IOException, KeyCollisionException { Globals.prefs.put(JabRefPreferences.WORKING_DIRECTORY, file.getParent().toString()); // Should this be done _after_ we know it was successfully opened? - ParserResult parserResult = OpenDatabase.loadDatabase(file.toFile(), + ParserResult parserResult = OpenDatabase.loadDatabase(file, Globals.prefs.getImportFormatPreferences(), Globals.getFileUpdateMonitor()); AppendDatabaseAction.mergeFromBibtex(panel, parserResult, importEntries, importStrings, importGroups, importSelectorWords); diff --git a/src/main/java/org/jabref/gui/maintable/ColumnPreferences.java b/src/main/java/org/jabref/gui/maintable/ColumnPreferences.java index e80ed4b4bfa..d79b3a6857b 100644 --- a/src/main/java/org/jabref/gui/maintable/ColumnPreferences.java +++ b/src/main/java/org/jabref/gui/maintable/ColumnPreferences.java @@ -1,32 +1,25 @@ package org.jabref.gui.maintable; import java.util.List; -import java.util.Map; - -import javafx.scene.control.TableColumn.SortType; public class ColumnPreferences { - public static final double DEFAULT_WIDTH = 100; + public static final double DEFAULT_COLUMN_WIDTH = 100; public static final double ICON_COLUMN_WIDTH = 16 + 12; // add some additional space to improve appearance private final List columns; - private final boolean extraFileColumnsEnabled; - private final Map columnSortType; + private final List columnSortOrder; - public ColumnPreferences(List columns, boolean extraFileColumnsEnabled, Map columnSortType) { + public ColumnPreferences(List columns, List columnSortOrder) { this.columns = columns; - this.extraFileColumnsEnabled = extraFileColumnsEnabled; - this.columnSortType = columnSortType; + this.columnSortOrder = columnSortOrder; } - public boolean getExtraFileColumnsEnabled() { return extraFileColumnsEnabled; } - public List getColumns() { return columns; } - public Map getSortTypesForColumns() { - return columnSortType; + public List getColumnSortOrder() { + return columnSortOrder; } } diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index f7b02a713a7..5eb3b3704fa 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -97,15 +97,15 @@ public MainTable(MainTableDataModel model, JabRefFrame frame, .setOnMouseDragEntered(this::handleOnDragEntered) .install(this); - /*for (Entry entries : preferences.getColumnPreferences().getSortTypesForColumns().entrySet()) { - Optional> column = this.getColumns().stream().filter(col -> entries.getKey().equals(col.getText())).findFirst(); - column.ifPresent(col -> { - col.setSortType(entries.getValue()); - this.getSortOrder().add(col); - }); - }*/ - - if (preferences.resizeColumnsToFit()) { + this.getSortOrder().clear(); + preferences.getColumnPreferences().getColumnSortOrder().forEach(columnModel -> + this.getColumns().stream() + .map(column -> (MainTableColumn) column) + .filter(column -> column.getModel().equals(columnModel)) + .findFirst() + .ifPresent(column -> this.getSortOrder().add(column))); + + if (preferences.getResizeColumnsToFit()) { this.setColumnResizePolicy(new SmartConstrainedResizePolicy()); } this.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumn.java b/src/main/java/org/jabref/gui/maintable/MainTableColumn.java index efdfd28133a..2c205a6773c 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumn.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumn.java @@ -1,5 +1,6 @@ package org.jabref.gui.maintable; +import javafx.beans.value.ObservableValue; import javafx.scene.control.TableColumn; import org.jabref.gui.util.BindingsHelper; @@ -16,6 +17,12 @@ public MainTableColumn(MainTableColumnModel model) { model.widthProperty(), value -> this.setPrefWidth(model.widthProperty().getValue()), value -> model.widthProperty().setValue(this.getWidth())); + + BindingsHelper.bindBidirectional( + this.sortTypeProperty(), + (ObservableValue) model.sortTypeProperty(), + value -> this.setSortType(model.sortTypeProperty().getValue()), + value -> model.sortTypeProperty().setValue(this.getSortType())); } public MainTableColumnModel getModel() { return model; } diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java index 1448a7d68e7..eccc829ebb7 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java @@ -159,10 +159,10 @@ private Node createGroupColorRegion(BibEntryTableViewModel entry, List ICON_COLUMNS = EnumSet.of(EXTRAFILE,FILES,GROUPS,LINKED_IDENTIFIER); + private String name; private String displayName; @@ -67,35 +71,54 @@ public static Type fromString(String text) { } } - private final ObjectProperty typeProperty; - private final StringProperty qualifierProperty; - private final DoubleProperty widthProperty; + private final ObjectProperty typeProperty = new SimpleObjectProperty<>(); + private final StringProperty qualifierProperty = new SimpleStringProperty(); + private final DoubleProperty widthProperty = new SimpleDoubleProperty(); + private final ObjectProperty sortTypeProperty = new SimpleObjectProperty<>(); /** * This is used by the preferences dialog, to initialize available columns the user can add to the table. * - * @param type the {@code MainTableColumnModel.Type} of the column, e.g. "NORMALFIELD" or "GROUPS" + * @param type the {@code MainTableColumnModel.Type} of the column, e.g. "NORMALFIELD" or "EXTRAFILE" * @param qualifier the stored qualifier of the column, e.g. "author/editor" */ - public MainTableColumnModel(Type type, String qualifier, double width) { + public MainTableColumnModel(Type type, String qualifier) { Objects.requireNonNull(type); - typeProperty = new SimpleObjectProperty<>(type); - qualifierProperty = new SimpleStringProperty(qualifier); - widthProperty = new SimpleDoubleProperty(width); - } + Objects.requireNonNull(qualifier); - public MainTableColumnModel(Type type, String qualifier) { - this(type, qualifier, ColumnPreferences.DEFAULT_WIDTH); - } + this.typeProperty.setValue(type); + this.qualifierProperty.setValue(qualifier); + this.sortTypeProperty.setValue(TableColumn.SortType.ASCENDING); - public MainTableColumnModel(Type type, double width) { - this(type, "", width); + if (Type.ICON_COLUMNS.contains(type)) { + this.widthProperty.setValue(ColumnPreferences.ICON_COLUMN_WIDTH); + } else { + this.widthProperty.setValue(ColumnPreferences.DEFAULT_COLUMN_WIDTH); + } } + /** + * This is used by the preferences dialog, to initialize available basic icon columns, the user can add to the table. + * + * @param type the {@code MainTableColumnModel.Type} of the column, e.g. "GROUPS" or "LINKED_IDENTIFIER" + */ public MainTableColumnModel(Type type) { this(type, ""); } + /** + * This is used by the preference migrations. + * + * @param type the {@code MainTableColumnModel.Type} of the column, e.g. "NORMALFIELD" or "GROUPS" + * @param qualifier the stored qualifier of the column, e.g. "author/editor" + * @param width the stored width of the column + */ + public MainTableColumnModel(Type type, String qualifier, double width) { + this(type, qualifier); + + this.widthProperty.setValue(width); + } + public Type getType() { return typeProperty.getValue(); } public String getQualifier() { return qualifierProperty.getValue(); } @@ -109,10 +132,7 @@ public String getName() { } public String getDisplayName() { - if ((typeProperty.getValue() == Type.GROUPS - || typeProperty.getValue() == Type.FILES - || typeProperty.getValue() == Type.LINKED_IDENTIFIER) - && qualifierProperty.getValue().isBlank()) { + if (Type.ICON_COLUMNS.contains(typeProperty.getValue()) && qualifierProperty.getValue().isBlank()) { return typeProperty.getValue().getDisplayName(); } else { return FieldsUtil.getNameWithType(FieldFactory.parseField(qualifierProperty.getValue())); @@ -121,12 +141,14 @@ public String getDisplayName() { public StringProperty nameProperty() { return new ReadOnlyStringWrapper(getDisplayName()); } - public double getWidth() { - return widthProperty.get(); - } + public double getWidth() { return widthProperty.getValue(); } public DoubleProperty widthProperty() { return widthProperty; } + public TableColumn.SortType getSortType() { return sortTypeProperty.getValue(); } + + public ObjectProperty sortTypeProperty() { return sortTypeProperty; } + public boolean equals(Object o) { if (this == o) { return true; @@ -149,23 +171,11 @@ public int hashCode() { } /** - * This is used by JabRefPreferences, to create a new ColumnModel out ouf the stored preferences. + * This creates a new {@code MainTableColumnModel} out of a given string * - * @param rawColumnName the stored name of the column, e.g. "field:author" - * @param width the stored width of the column - */ - public static MainTableColumnModel parse(String rawColumnName, Double width) { - MainTableColumnModel columnModel = parse(rawColumnName); - - Objects.requireNonNull(width); - columnModel.widthProperty().setValue(width); - return columnModel; - } - - /** - * This is used by the preferences dialog, to allow the user to type in a field he wants to add to the table. + * @param rawColumnName the name of the column, e.g. "field:author", or "author" * - * @param rawColumnName the stored name of the column, e.g. "field:author", or "author" + * @return A new {@code MainTableColumnModel} */ public static MainTableColumnModel parse(String rawColumnName) { Objects.requireNonNull(rawColumnName); @@ -174,7 +184,9 @@ public static MainTableColumnModel parse(String rawColumnName) { Type type = Type.fromString(splittedName[0]); String qualifier = ""; - if (type == Type.NORMALFIELD || type == Type.SPECIALFIELD || type == Type.EXTRAFILE) { + if (type == Type.NORMALFIELD + || type == Type.SPECIALFIELD + || type == Type.EXTRAFILE) { if (splittedName.length == 1) { qualifier = splittedName[0]; // By default the rawColumnName is parsed as NORMALFIELD } else { diff --git a/src/main/java/org/jabref/gui/maintable/MainTablePreferences.java b/src/main/java/org/jabref/gui/maintable/MainTablePreferences.java index 8b9359c576b..6bd58ce495b 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTablePreferences.java +++ b/src/main/java/org/jabref/gui/maintable/MainTablePreferences.java @@ -3,17 +3,21 @@ public class MainTablePreferences { private final ColumnPreferences columnPreferences; private final boolean resizeColumnsToFit; + private final boolean extraFileColumnsEnabled; - public MainTablePreferences(ColumnPreferences columnPreferences, boolean resizeColumnsToFit) { + public MainTablePreferences(ColumnPreferences columnPreferences, boolean resizeColumnsToFit, boolean extraFileColumnsEnabled) { this.columnPreferences = columnPreferences; this.resizeColumnsToFit = resizeColumnsToFit; + this.extraFileColumnsEnabled = extraFileColumnsEnabled; } public ColumnPreferences getColumnPreferences() { return columnPreferences; } - public boolean resizeColumnsToFit() { + public boolean getResizeColumnsToFit() { return resizeColumnsToFit; } + + public boolean getExtraFileColumnsEnabled() { return extraFileColumnsEnabled; } } diff --git a/src/main/java/org/jabref/gui/maintable/PersistenceVisualStateTable.java b/src/main/java/org/jabref/gui/maintable/PersistenceVisualStateTable.java index e9ef10fcb74..03caa77521f 100644 --- a/src/main/java/org/jabref/gui/maintable/PersistenceVisualStateTable.java +++ b/src/main/java/org/jabref/gui/maintable/PersistenceVisualStateTable.java @@ -1,63 +1,45 @@ package org.jabref.gui.maintable; -import java.util.LinkedHashMap; -import java.util.Map; import java.util.stream.Collectors; -import javafx.collections.ListChangeListener; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableColumn.SortType; +import javafx.beans.InvalidationListener; import org.jabref.preferences.JabRefPreferences; /** - * Keep track of changes made to the columns, like reordering or resizing. - * + * Keep track of changes made to the columns (reordering, resorting, resizing). */ public class PersistenceVisualStateTable { private final MainTable mainTable; private final JabRefPreferences preferences; - private final Map columnsSortOrder = new LinkedHashMap<>(); public PersistenceVisualStateTable(final MainTable mainTable, JabRefPreferences preferences) { this.mainTable = mainTable; this.preferences = preferences; - mainTable.getColumns().addListener(this::onColumnsChanged); - mainTable.getColumns().forEach(col -> { - MainTableColumn column = (MainTableColumn) col; - col.sortTypeProperty().addListener(obs -> updateColumnSortType(column.getModel().getName(), column.getSortType())); - }); - mainTable.getColumns().forEach(col -> col.widthProperty().addListener(obs -> updateColumnPreferences())); + mainTable.getColumns().addListener((InvalidationListener) obs -> updateColumnPreferences()); + mainTable.getSortOrder().addListener((InvalidationListener) obs -> updateColumnPreferences()); - } - - private void onColumnsChanged(ListChangeListener.Change> change) { - boolean changed = false; - while (change.next()) { - changed = true; - } - - if (changed) { - updateColumnPreferences(); - } - - } - - private void updateColumnSortType(String text, SortType sortType) { - columnsSortOrder.put(text, sortType); - preferences.setMainTableColumnSortType(columnsSortOrder); + // As we store the ColumnModels of the MainTable, we need to add the listener to the ColumnModel properties, + // since the value is bound to the model after the listener to the column itself is called. + mainTable.getColumns().forEach(col -> + ((MainTableColumn) col).getModel().widthProperty().addListener(obs -> updateColumnPreferences())); + mainTable.getColumns().forEach(col -> + ((MainTableColumn) col).getModel().sortTypeProperty().addListener(obs -> updateColumnPreferences())); } /** - * Store shown columns and their width in preferences. + * Store shown columns, their width and their sortType in preferences. */ private void updateColumnPreferences() { - ColumnPreferences oldColumnPreferences = preferences.getColumnPreferences(); preferences.storeColumnPreferences(new ColumnPreferences( - mainTable.getColumns().stream().map(column -> ((MainTableColumn) column).getModel()).collect(Collectors.toList()), - oldColumnPreferences.getExtraFileColumnsEnabled(), - columnsSortOrder)); + mainTable.getColumns().stream() + .map(column -> ((MainTableColumn) column).getModel()) + .collect(Collectors.toList()), + mainTable.getSortOrder().stream() + .map(column -> ((MainTableColumn) column).getModel()) + .collect(Collectors.toList()) + )); } } diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.css b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.css index 1721967edab..c9788f41923 100644 --- a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.css +++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.css @@ -26,7 +26,7 @@ -fx-background-color: transparent; } -#container { +#preferencesContainer { -fx-padding: 0.5em; } @@ -38,7 +38,10 @@ -fx-padding: 0; -fx-border-width: 1; -fx-background-color: transparent; - -fx-border-color: -fx-outer-border; +} + +.code-area .text { + -fx-fill: -fx-text-background-color; } .code-area .tagmark { @@ -59,7 +62,7 @@ } .code-area .avalue { - -fx-fill: black; + -fx-fill: green; } .code-area .comment { @@ -70,10 +73,6 @@ -fx-text-fill: -jr-purple; } -.code-area .context-menu { - -fx-font-family: sans-serif; -} - .code-area .context-menu .menu-item .label { -fx-padding: 2; } diff --git a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.fxml b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.fxml index d2fcf62032e..d7ee3befc3e 100644 --- a/src/main/java/org/jabref/gui/preferences/PreferencesDialog.fxml +++ b/src/main/java/org/jabref/gui/preferences/PreferencesDialog.fxml @@ -41,7 +41,7 @@