Skip to content

Commit 342f8fd

Browse files
ngonzalezpazFCjavier-godoy
authored andcommitted
refactor(demo): integrate commons-demo
1 parent 068cfd7 commit 342f8fd

File tree

2 files changed

+50
-35
lines changed

2 files changed

+50
-35
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.flowingcode.vaadin.addons.errorwindow;
2+
3+
import com.vaadin.flow.component.button.Button;
4+
import com.vaadin.flow.component.checkbox.Checkbox;
5+
import com.vaadin.flow.component.notification.Notification;
6+
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
7+
8+
@SuppressWarnings("serial")
9+
public class ErrorwindowDemo extends VerticalLayout {
10+
11+
public ErrorwindowDemo() {
12+
Button errorButton = new Button("Throw Error", event -> {
13+
Integer.parseInt("asdf");
14+
});
15+
16+
Button throwErrorWithoutErrorHandler = new Button("Throw Error without an error handler", ev -> {
17+
try {
18+
Integer.parseInt("asdf");
19+
} catch (NumberFormatException e) {
20+
ErrorManager.showError(e);
21+
}
22+
});
23+
24+
Button throwErrorWithCustomMessage = new Button("Throw Error with custom message", ev -> {
25+
try {
26+
Integer.parseInt("asdf");
27+
} catch (NumberFormatException e) {
28+
ErrorWindow w = new ErrorWindow(e, "CUSTOM ERROR MESSAGE");
29+
w.open();
30+
}
31+
});
32+
33+
Checkbox productionModeCb = new Checkbox("Production Mode");
34+
productionModeCb.addValueChangeListener(e -> {
35+
System.setProperty("productionMode", "" + productionModeCb.getValue().toString());
36+
Notification.show("Currently production mode is: " + System.getProperty("productionMode"));
37+
});
38+
39+
setSizeFull();
40+
add(productionModeCb, errorButton, throwErrorWithoutErrorHandler, throwErrorWithCustomMessage);
41+
}
42+
43+
}
Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,22 @@
11
package com.flowingcode.vaadin.addons.errorwindow;
22

33
import com.flowingcode.vaadin.addons.DemoLayout;
4-
import com.vaadin.flow.component.button.Button;
5-
import com.vaadin.flow.component.button.ButtonVariant;
6-
import com.vaadin.flow.component.checkbox.Checkbox;
7-
import com.vaadin.flow.component.html.Label;
8-
import com.vaadin.flow.component.html.Paragraph;
9-
import com.vaadin.flow.component.notification.Notification;
4+
import com.flowingcode.vaadin.addons.demo.impl.TabbedDemoImpl;
105
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
116
import com.vaadin.flow.router.Route;
12-
import java.awt.TextField;
137

148
@SuppressWarnings("serial")
159
@Route(value = "error-window", layout = DemoLayout.class)
1610
public class ErrorwindowDemoView extends VerticalLayout {
1711

18-
public ErrorwindowDemoView() {
19-
Button errorButton = new Button("Throw Error", event -> {
20-
Integer.parseInt("asdf");
21-
});
22-
23-
Button throwErrorWithoutErrorHandler = new Button("Throw Error without an error handler", ev->{
24-
try {
25-
Integer.parseInt("asdf");
26-
} catch (NumberFormatException e) {
27-
ErrorManager.showError(e);
28-
}
29-
});
30-
31-
Button throwErrorWithCustomMessage = new Button("Throw Error with custom message", ev->{
32-
try {
33-
Integer.parseInt("asdf");
34-
} catch (NumberFormatException e) {
35-
ErrorWindow w = new ErrorWindow(e, "CUSTOM ERROR MESSAGE");
36-
w.open();
37-
}
38-
});
39-
40-
Checkbox productionModeCb = new Checkbox("Production Mode");
41-
productionModeCb.addValueChangeListener(e -> {
42-
System.setProperty("productionMode", "" + productionModeCb.getValue().toString());
43-
Notification.show("Currently production mode is: " + System.getProperty("productionMode"));
44-
});
12+
private static final String ERROR_DEMO = "Error Window Demo";
13+
private static final String ERROR_SOURCE = "https://github.com/FlowingCode/ErrorWindowAddon/blob/master/src/test/java/com/flowingcode/vaadin/addons/errorwindow/ErrorwindowDemoView.java";
4514

15+
public ErrorwindowDemoView() {
16+
TabbedDemoImpl<ErrorwindowDemo> errorDemo = new TabbedDemoImpl<>(new ErrorwindowDemo(), ERROR_DEMO,
17+
ERROR_SOURCE);
18+
add(errorDemo);
4619
setSizeFull();
47-
add(productionModeCb, errorButton, throwErrorWithoutErrorHandler, throwErrorWithCustomMessage);
4820
}
4921

5022
}

0 commit comments

Comments
 (0)