diff --git a/CHANGELOG.md b/CHANGELOG.md index aa8854dcfe4..b9cb7693c9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Fixed +- We fixed an issue where the user could not rate an entry in the main table when an entry was not yet ranked. [#5842](https://github.com/JabRef/jabref/issues/5842) - We fixed an issue that caused JabRef to sometimes open multiple instances when "Remote Operation" is enabled. [#8653](https://github.com/JabRef/jabref/issues/8653) - We fixed an issue where linked files with the filetype "application/pdf" in an entry were not shown with the correct PDF-Icon in the main table [8930](https://github.com/JabRef/jabref/issues/8930) - We fixed an issue where "open folder" for linked files did not open the folder and did not select the file unter certain Linux desktop environments [#8679](https://github.com/JabRef/jabref/issues/8679), [#8849](https://github.com/JabRef/jabref/issues/8849) diff --git a/src/main/java/org/jabref/gui/Base.css b/src/main/java/org/jabref/gui/Base.css index 188182d5151..f1829b7cc7e 100644 --- a/src/main/java/org/jabref/gui/Base.css +++ b/src/main/java/org/jabref/gui/Base.css @@ -1305,3 +1305,16 @@ TextFlow * { .text-field:invalid { -fx-background-color: rgba(240, 128, 128, 0.5); } + +.rating { + -fx-skin: "org.jabref.gui.util.CustomRatingSkin"; + -fx-padding: 0.5em 0px 0px 0px; +} + +.rating > .container > .button { + -fx-icon-color: derive(-fx-text-base-color, 85%); +} + +.rating > .container > .button.strong { + -fx-icon-color: -fx-text-base-color; +} diff --git a/src/main/java/org/jabref/gui/Dark.css b/src/main/java/org/jabref/gui/Dark.css index adaa1cd1a83..0c23ea36773 100644 --- a/src/main/java/org/jabref/gui/Dark.css +++ b/src/main/java/org/jabref/gui/Dark.css @@ -132,3 +132,11 @@ .notification-bar > .pane { -fx-background-color: -fx-light-text-color; } + +.rating > .container > .button { + -fx-icon-color: derive(-fx-light-text-color, -50%); +} + +.rating > .container > .button.strong { + -fx-icon-color: -fx-light-text-color; +} diff --git a/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java b/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java index 271a7abe4cb..971bb5e0f69 100644 --- a/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java +++ b/src/main/java/org/jabref/gui/maintable/columns/SpecialFieldColumn.java @@ -9,6 +9,7 @@ import javafx.scene.control.MenuItem; import javafx.scene.control.Tooltip; import javafx.scene.input.MouseButton; +import javafx.scene.input.MouseEvent; import org.jabref.gui.icon.JabRefIcon; import org.jabref.gui.maintable.BibEntryTableViewModel; @@ -55,7 +56,7 @@ public SpecialFieldColumn(MainTableColumnModel model, PreferencesService prefere MainTableColumnFactory.setExactWidth(this, SpecialFieldsPreferences.COLUMN_RANKING_WIDTH); this.setResizable(false); new OptionalValueTableCellFactory() - .withGraphicIfPresent(this::createSpecialRating) + .withGraphic(this::createSpecialRating) .install(this); } else { MainTableColumnFactory.setExactWidth(this, ColumnPreferences.ICON_COLUMN_WIDTH); @@ -89,9 +90,24 @@ public SpecialFieldColumn(MainTableColumnModel model, PreferencesService prefere this.setSortable(true); } - private Rating createSpecialRating(BibEntryTableViewModel entry, SpecialFieldValueViewModel value) { + private Rating createSpecialRating(BibEntryTableViewModel entry, Optional value) { Rating ranking = new Rating(); - ranking.setRating(value.getValue().toRating()); + + if (value.isPresent()) { + ranking.setRating(value.get().getValue().toRating()); + } else { + ranking.setRating(0); + } + + ranking.addEventFilter(MouseEvent.MOUSE_CLICKED, event -> { + if (event.getButton().equals(MouseButton.PRIMARY) && event.getClickCount() == 2) { + ranking.setRating(0); + event.consume(); + } else if (event.getButton().equals(MouseButton.SECONDARY)) { + event.consume(); + } + }); + EasyBind.subscribe(ranking.ratingProperty(), rating -> new SpecialFieldViewModel(SpecialField.RANKING, preferencesService, undoManager) .setSpecialFieldValue(entry.getEntry(), SpecialFieldValue.getRating(rating.intValue()))); diff --git a/src/main/java/org/jabref/gui/util/CustomRatingSkin.java b/src/main/java/org/jabref/gui/util/CustomRatingSkin.java new file mode 100644 index 00000000000..96e6e8d75d5 --- /dev/null +++ b/src/main/java/org/jabref/gui/util/CustomRatingSkin.java @@ -0,0 +1,21 @@ +package org.jabref.gui.util; + +import javafx.scene.Node; + +import org.jabref.gui.icon.IconTheme; + +import impl.org.controlsfx.skin.RatingSkin; +import org.controlsfx.control.Rating; + +public class CustomRatingSkin extends RatingSkin { + public CustomRatingSkin(Rating control) { + super(control); + + consumeMouseEvents(false); + } + + @Override + protected Node createButtonNode() { + return IconTheme.JabRefIcons.RANKING.getGraphicNode(); + } +} diff --git a/src/main/java/org/jabref/model/entry/field/SpecialFieldValue.java b/src/main/java/org/jabref/model/entry/field/SpecialFieldValue.java index d4c1f8df7d5..6c3337b41f6 100644 --- a/src/main/java/org/jabref/model/entry/field/SpecialFieldValue.java +++ b/src/main/java/org/jabref/model/entry/field/SpecialFieldValue.java @@ -39,6 +39,7 @@ public enum SpecialFieldValue { public static SpecialFieldValue getRating(int ranking) { return switch (ranking) { + case 0 -> CLEAR_RANK; case 1 -> RANK_1; case 2 -> RANK_2; case 3 -> RANK_3; @@ -58,6 +59,7 @@ public Optional getFieldValue() { public int toRating() { return switch (this) { + case CLEAR_RANK -> 0; case RANK_1 -> 1; case RANK_2 -> 2; case RANK_3 -> 3;