Skip to content

Commit 225bba6

Browse files
Yubo-CaoSiedlerchr
andauthored
feat(gui): Better looking error console (#13783)
* feat(gui): Better looking error console * fix: Remove a trivial comments * fix: OpenRewrite * correct fxml --------- Co-authored-by: Siedlerchr <[email protected]>
1 parent 11db684 commit 225bba6

File tree

4 files changed

+60
-28
lines changed

4 files changed

+60
-28
lines changed

jabgui/src/main/java/org/jabref/gui/errorconsole/ErrorConsoleView.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import javafx.collections.ListChangeListener;
44
import javafx.collections.ObservableList;
55
import javafx.fxml.FXML;
6+
import javafx.geometry.Pos;
67
import javafx.scene.Node;
78
import javafx.scene.control.ButtonType;
89
import javafx.scene.control.ContentDisplay;
@@ -79,19 +80,21 @@ private void initialize() {
7980

8081
private Callback<ListView<LogEventViewModel>, ListCell<LogEventViewModel>> createCellFactory() {
8182
return cell -> new ListCell<>() {
82-
private HBox graphic;
83-
private Node icon;
84-
private VBox message;
85-
private Label heading;
86-
private Label stacktrace;
83+
private final HBox graphic;
84+
private final VBox message;
85+
private final Label heading;
86+
private final Label stacktrace;
8787

8888
{
89-
graphic = new HBox(10);
89+
graphic = new HBox();
9090
heading = new Label();
9191
stacktrace = new Label();
9292
message = new VBox();
93+
message.setAlignment(Pos.CENTER_LEFT);
9394
message.getChildren().setAll(heading, stacktrace);
95+
message.getStyleClass().add("message-box");
9496
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
97+
getStyleClass().add("error-console-cell");
9598
}
9699

97100
@Override
@@ -101,10 +104,17 @@ public void updateItem(LogEventViewModel event, boolean empty) {
101104
if ((event == null) || empty) {
102105
setGraphic(null);
103106
} else {
104-
icon = event.getIcon().getGraphicNode();
107+
Node icon = event.getIcon().getGraphicNode();
105108
heading.setText(event.getDisplayText());
106109
heading.getStyleClass().setAll(event.getStyleClass());
107-
stacktrace.setText(event.getStackTrace().orElse(""));
110+
event.getStackTrace().ifPresentOrElse(text -> {
111+
stacktrace.setText(text);
112+
stacktrace.setVisible(true);
113+
stacktrace.setManaged(true);
114+
}, () -> {
115+
stacktrace.setVisible(false);
116+
stacktrace.setManaged(false);
117+
});
108118
graphic.getStyleClass().setAll(event.getStyleClass());
109119
graphic.getChildren().setAll(icon, message);
110120
setGraphic(graphic);

jabgui/src/main/resources/org/jabref/gui/Base.css

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,47 +2148,69 @@ We want to have a look that matches our icons in the tool-bar */
21482148
}
21492149

21502150
/* ErrorConsole */
2151-
21522151
#errorConsole .list-content {
2153-
-fx-padding: 0.625em;
2152+
-fx-padding: 0em;
21542153
}
21552154

21562155
#errorConsole .info-section {
2157-
-fx-padding: 0.625em;
2158-
-fx-background-color: -fx-background;
2156+
-fx-graphic-text-gap: 0.8em;
2157+
-fx-font-size: 1.1em;
2158+
-fx-line-spacing: 0.2em;
2159+
-fx-padding: 0.6em 1em;
2160+
-fx-background-color: -jr-transparent-accent;
2161+
}
2162+
2163+
#errorConsole .button-bar {
2164+
-fx-padding: 1em 0em 0em 0em;
21592165
}
21602166

2161-
#errorConsole .info-section .glyph-icon {
2162-
-fx-font-size: 24.0;
2167+
#errorConsole .error-console-cell {
2168+
-fx-padding: 0.6em 1em;
2169+
}
2170+
2171+
#errorConsole .error-console-cell HBox {
2172+
-fx-spacing: 0.8em;
2173+
}
2174+
2175+
#errorConsole .message-box {
2176+
-fx-spacing: 0.5em;
2177+
}
2178+
2179+
#errorConsole .info-section .glyph-icon,
2180+
#errorConsole .exception .glyph-icon,
2181+
#errorConsole .output .glyph-icon,
2182+
#errorConsole .log .glyph-icon
2183+
{
2184+
-fx-font-size: 1.5em;
21632185
}
21642186

21652187
#errorConsole .exception .glyph-icon {
2166-
-fx-font-size: 18.0;
2167-
-fx-fill: -jr-error;
2188+
-fx-icon-color: -jr-error;
21682189
}
21692190

21702191
#errorConsole .output .glyph-icon {
2171-
-fx-font-size: 18.0;
2172-
-fx-fill: -jr-warn;
2192+
-fx-icon-color: -jr-warn;
21732193
}
21742194

21752195
#errorConsole .log .glyph-icon {
2176-
-fx-font-size: 18.0;
2177-
-fx-fill: -jr-info;
2196+
-fx-icon-color: -jr-info;
21782197
}
21792198

2180-
#errorConsole .custom-buttons {
2181-
-fx-padding: 0.312em;
2199+
/* Poor readability on -jr-accent. See: https://webaim.org/resources/contrastchecker/?fcolor=9E4C00&bcolor=A3B7E6 */
2200+
#errorConsole .error-console-cell:selected .exception .glyph-icon {
2201+
-fx-icon-color: derive(-jr-error, -50%);
21822202
}
21832203

2184-
#errorConsole .exception {
2185-
-fx-text-fill: -fx-text-base-color;
2204+
#errorConsole .error-console-cell:selected .output .glyph-icon {
2205+
-fx-icon-color: derive(-jr-warn, -50%);
21862206
}
21872207

2188-
#errorConsole .output {
2189-
-fx-text-fill: -fx-text-base-color;
2208+
#errorConsole .error-console-cell:selected .log .glyph-icon {
2209+
-fx-icon-color: derive(-jr-info, -50%);
21902210
}
21912211

2212+
#errorConsole .exception,
2213+
#errorConsole .output,
21922214
#errorConsole .log {
21932215
-fx-text-fill: -fx-text-base-color;
21942216
}

jabgui/src/main/resources/org/jabref/gui/errorconsole/ErrorConsole.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</content>
1616
<header>
1717
<Label fx:id="descriptionLabel" styleClass="info-section"
18-
text="%We now give you insight into the inner workings of JabRef's internals. This information might be helpful to diagnose the root cause of a problem. Please feel free to inform the developers about an issue."
18+
text="%The event log displays information regarding JabRef's internal processes. This data can be useful for debugging. If you encounter a problem, please consider reporting it to the development team."
1919
wrapText="true"/>
2020
</header>
2121
<buttonTypes>

jablib/src/main/resources/l10n/JabRef_en.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ Loading\ built\ in\ lists=Loading built in lists
17881788
JabRef\ built\ in\ list=JabRef built in list
17891789

17901790
Event\ log=Event log
1791-
We\ now\ give\ you\ insight\ into\ the\ inner\ workings\ of\ JabRef\'s\ internals.\ This\ information\ might\ be\ helpful\ to\ diagnose\ the\ root\ cause\ of\ a\ problem.\ Please\ feel\ free\ to\ inform\ the\ developers\ about\ an\ issue.=We now give you insight into the inner workings of JabRef\'s internals. This information might be helpful to diagnose the root cause of a problem. Please feel free to inform the developers about an issue.
1791+
The\ event\ log\ displays\ information\ regarding\ JabRef's\ internal\ processes.\ This\ data\ can\ be\ useful\ for\ debugging.\ If\ you\ encounter\ a\ problem,\ please\ consider\ reporting\ it\ to\ the\ development\ team.=The event log displays information regarding JabRef's internal processes. This data can be useful for debugging. If you encounter a problem, please consider reporting it to the development team.
17921792
Log\ copied\ to\ clipboard.=Log copied to clipboard.
17931793
Copy\ Log=Copy Log
17941794
Clear\ Log=Clear Log

0 commit comments

Comments
 (0)