@@ -37,6 +37,7 @@ public UpdatePane(GuiController controller) {
37
37
GridPane grid = new GridPane ();
38
38
GridPane .setFillHeight (btn , true );
39
39
GridPane .setFillWidth (btn , true );
40
+ grid .setMaxWidth (800 );
40
41
grid .setPadding (new Insets (10 ));
41
42
grid .setVgap (10 );
42
43
grid .setHgap (10 );
@@ -62,17 +63,46 @@ private BorderPane getNotes() {
62
63
Node document = parser .parse (SelfUpdater .getLatestPatchnotes ().replaceAll ("\\ (\\ [.+\\ )\\ )" , "" ));
63
64
document .accept (new AbstractVisitor () {
64
65
@ Override
65
- public void visit (Text text ) {
66
- Node parent = getRoot (text );
67
- if (parent instanceof Heading ) {
68
- // Skip the version H1 text
69
- if (((Heading ) parent ).getLevel () == 1 )
70
- return ;
71
- //
72
- addLine (text .getLiteral (), "h2" );
73
- } else if (parent instanceof BulletList || parent instanceof OrderedList ) {
74
- String msg = text .getLiteral ();
75
- addLine (" ● " + msg , null );
66
+ public void visit (Paragraph paragraph ) {
67
+ StringBuilder sb = new StringBuilder ();
68
+ Node node = paragraph .getFirstChild ();
69
+ build (sb , node );
70
+ addLine (sb .toString (), null );
71
+ }
72
+
73
+ @ Override
74
+ public void visit (Heading heading ) {
75
+ // Skip the version H2 text
76
+ if (heading .getLevel () <= 2 )
77
+ return ;
78
+ addLine (build (heading ), "h2" );
79
+ }
80
+
81
+ @ Override
82
+ public void visit (BulletList list ) {
83
+ Node item = list .getFirstChild ();
84
+ do {
85
+ String itemText = build (item );
86
+ addLine (" ● " + itemText , null );
87
+ item = item .getNext ();
88
+ } while (item != null );
89
+ }
90
+
91
+ private String build (Node node ) {
92
+ StringBuilder sb = new StringBuilder ();
93
+ build (sb , node );
94
+ return sb .toString ();
95
+ }
96
+
97
+ private void build (StringBuilder sb , Node node ) {
98
+ if (node instanceof Text )
99
+ sb .append (((Text ) node ).getLiteral ());
100
+ else {
101
+ Node child = node .getFirstChild ();
102
+ do {
103
+ build (sb , child );
104
+ child = child .getNext ();
105
+ } while (child != null );
76
106
}
77
107
}
78
108
@@ -82,12 +112,6 @@ private void addLine(String text, String style) {
82
112
t .getStyleClass ().add (style );
83
113
flow .getChildren ().add (t );
84
114
}
85
-
86
- private Node getRoot (Node node ) {
87
- while (!(node .getParent () instanceof Document ))
88
- node = node .getParent ();
89
- return node ;
90
- }
91
115
});
92
116
BorderPane pane = new BorderPane (flow );
93
117
pane .getStyleClass ().add ("content" );
@@ -120,7 +144,7 @@ private void update() {
120
144
try {
121
145
SelfUpdater .updateRecaf ();
122
146
controller .exit ();
123
- } catch (IOException ex ) {
147
+ } catch (IOException ex ) {
124
148
Log .error (ex , "Failed to start update process" );
125
149
ExceptionAlert .show (ex , "Recaf failed to start the update process" );
126
150
}
0 commit comments