Skip to content

Commit 86c1930

Browse files
javier-godoymlopezFC
authored andcommitted
style: apply code formatting
1 parent d73c8b1 commit 86c1930

File tree

5 files changed

+146
-144
lines changed

5 files changed

+146
-144
lines changed

src/main/java/com/flowingcode/vaadin/addons/GithubLink.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88

99
/**
1010
* This annotation is used for configuring the URL in the {@code GitHubCorner}
11-
* @author Javier Godoy / Flowing Code
1211
*
12+
* @author Javier Godoy / Flowing Code
1313
*/
1414
@Retention(RetentionPolicy.RUNTIME)
1515
@Target(ElementType.TYPE)
1616
@Inherited
1717
public @interface GithubLink {
18-
String value();
18+
String value();
1919
}

src/main/java/com/flowingcode/vaadin/addons/demo/SourceCodeView.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,21 @@
2525
@SuppressWarnings("serial")
2626
class SourceCodeView extends Composite<IFrame> {
2727

28-
public SourceCodeView(String sourceUrl) {
29-
getContent().getElement().setAttribute("frameborder", "0");
30-
getContent().setMinHeight("0");
31-
getContent().setMinWidth("0");
32-
getContent().getElement().setAttribute("srcdoc", getSrcdoc(sourceUrl));
33-
getContent().setSizeFull();
34-
}
28+
public SourceCodeView(String sourceUrl) {
29+
getContent().getElement().setAttribute("frameborder", "0");
30+
getContent().setMinHeight("0");
31+
getContent().setMinWidth("0");
32+
getContent().getElement().setAttribute("srcdoc", getSrcdoc(sourceUrl));
33+
getContent().setSizeFull();
34+
}
3535

36-
private String getSrcdoc(String sourceUrl) {
37-
return "<html style=\"overflow-y:hidden; height:100%;\"><body style=\"overflow-y: scroll; height:100%;\"><script src=\"https://gist-it.appspot.com/"
38-
+ sourceUrl + "\"></script></body></html>";
39-
}
36+
private String getSrcdoc(String sourceUrl) {
37+
return "<html style=\"overflow-y:hidden; height:100%;\"><body style=\"overflow-y: scroll; height:100%;\"><script src=\"https://gist-it.appspot.com/"
38+
+ sourceUrl
39+
+ "\"></script></body></html>";
40+
}
4041

41-
public void setSizeFull() {
42-
getContent().setSizeFull();
43-
}
42+
public void setSizeFull() {
43+
getContent().setSizeFull();
44+
}
4445
}

src/main/java/com/flowingcode/vaadin/addons/demo/SplitLayoutDemo.java

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,31 @@
2727
@SuppressWarnings("serial")
2828
class SplitLayoutDemo extends Composite<SplitLayout> {
2929

30-
private SourceCodeView code;
31-
32-
public SplitLayoutDemo(Component demo, String sourceUrl) {
33-
getContent().setOrientation(Orientation.HORIZONTAL);
34-
code = new SourceCodeView(sourceUrl);
35-
36-
getContent().addToPrimary(demo);
37-
getContent().addToSecondary(code);
38-
getContent().setSizeFull();
39-
}
40-
41-
public void setOrientation(Orientation o) {
42-
getContent().setOrientation(o);
43-
getContent().getPrimaryComponent().getElement().setAttribute("style", "width: 100%; height: 100%");
44-
code.setSizeFull();
45-
}
46-
47-
public void setSplitterPosition(int pos) {
48-
getContent().setSplitterPosition(pos);
49-
}
50-
public void setSizeFull() {
51-
getContent().setSizeFull();
52-
}
30+
private SourceCodeView code;
31+
32+
public SplitLayoutDemo(Component demo, String sourceUrl) {
33+
getContent().setOrientation(Orientation.HORIZONTAL);
34+
code = new SourceCodeView(sourceUrl);
35+
36+
getContent().addToPrimary(demo);
37+
getContent().addToSecondary(code);
38+
getContent().setSizeFull();
39+
}
40+
41+
public void setOrientation(Orientation o) {
42+
getContent().setOrientation(o);
43+
getContent()
44+
.getPrimaryComponent()
45+
.getElement()
46+
.setAttribute("style", "width: 100%; height: 100%");
47+
code.setSizeFull();
48+
}
49+
50+
public void setSplitterPosition(int pos) {
51+
getContent().setSplitterPosition(pos);
52+
}
53+
54+
public void setSizeFull() {
55+
getContent().setSizeFull();
56+
}
5357
}

src/main/java/com/flowingcode/vaadin/addons/demo/TabbedDemo.java

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
*/
2020
package com.flowingcode.vaadin.addons.demo;
2121

22-
import java.util.HashMap;
23-
import java.util.Map;
24-
2522
import com.vaadin.flow.component.Component;
2623
import com.vaadin.flow.component.checkbox.Checkbox;
2724
import com.vaadin.flow.component.dependency.StyleSheet;
@@ -30,96 +27,99 @@
3027
import com.vaadin.flow.component.splitlayout.SplitLayout.Orientation;
3128
import com.vaadin.flow.component.tabs.Tab;
3229
import com.vaadin.flow.component.tabs.Tabs;
30+
import java.util.HashMap;
31+
import java.util.Map;
3332

3433
@StyleSheet("context://frontend/styles/commons-demo/shared-styles.css")
3534
@SuppressWarnings("serial")
3635
public class TabbedDemo extends VerticalLayout {
3736

38-
private Tabs tabs;
39-
private HorizontalLayout footer;
40-
private SplitLayoutDemo currentLayout;
41-
private Map<Tab, Component> demos;
42-
private Checkbox orientationCB;
43-
private Checkbox codeCB;
37+
private Tabs tabs;
38+
private HorizontalLayout footer;
39+
private SplitLayoutDemo currentLayout;
40+
private Map<Tab, Component> demos;
41+
private Checkbox orientationCB;
42+
private Checkbox codeCB;
4443

45-
public TabbedDemo() {
46-
tabs = new Tabs();
47-
demos = new HashMap<>();
48-
tabs.setWidthFull();
44+
public TabbedDemo() {
45+
tabs = new Tabs();
46+
demos = new HashMap<>();
47+
tabs.setWidthFull();
4948

50-
// Footer
51-
orientationCB = new Checkbox("Toggle Orientation");
52-
orientationCB.setValue(true);
53-
orientationCB.addClassName("smallcheckbox");
54-
orientationCB.addValueChangeListener(cb -> {
55-
updateSplitterOrientation();
56-
});
57-
codeCB = new Checkbox("Show Source Code");
58-
codeCB.setValue(true);
59-
codeCB.addClassName("smallcheckbox");
60-
codeCB.addValueChangeListener(cb -> {
61-
updateSplitterPosition();
62-
});
63-
footer = new HorizontalLayout();
64-
footer.setWidthFull();
65-
footer.setJustifyContentMode(JustifyContentMode.END);
66-
footer.add(codeCB, orientationCB);
49+
// Footer
50+
orientationCB = new Checkbox("Toggle Orientation");
51+
orientationCB.setValue(true);
52+
orientationCB.addClassName("smallcheckbox");
53+
orientationCB.addValueChangeListener(
54+
cb -> {
55+
updateSplitterOrientation();
56+
});
57+
codeCB = new Checkbox("Show Source Code");
58+
codeCB.setValue(true);
59+
codeCB.addClassName("smallcheckbox");
60+
codeCB.addValueChangeListener(
61+
cb -> {
62+
updateSplitterPosition();
63+
});
64+
footer = new HorizontalLayout();
65+
footer.setWidthFull();
66+
footer.setJustifyContentMode(JustifyContentMode.END);
67+
footer.add(codeCB, orientationCB);
6768

68-
tabs.addSelectedChangeListener(e -> {
69-
removeAll();
70-
Component currentDemo = demos.get(tabs.getSelectedTab());
71-
this.add(tabs, currentDemo);
72-
if (currentDemo instanceof SplitLayoutDemo) {
73-
currentLayout = (SplitLayoutDemo) currentDemo;
74-
this.add(footer);
75-
updateSplitterPosition();
76-
updateSplitterOrientation();
77-
} else {
78-
currentLayout = null;
79-
}
80-
});
69+
tabs.addSelectedChangeListener(
70+
e -> {
71+
removeAll();
72+
Component currentDemo = demos.get(tabs.getSelectedTab());
73+
this.add(tabs, currentDemo);
74+
if (currentDemo instanceof SplitLayoutDemo) {
75+
currentLayout = (SplitLayoutDemo) currentDemo;
76+
this.add(footer);
77+
updateSplitterPosition();
78+
updateSplitterOrientation();
79+
} else {
80+
currentLayout = null;
81+
}
82+
});
8183

82-
setSizeFull();
83-
}
84+
setSizeFull();
85+
}
8486

85-
/**
86-
*
87-
* @param demo the demo instance
88-
* @param name the demo name (tab label)
89-
* @param sourceCodeUrl the url of the demo, <b>null</b> to not show source code
90-
* section.
91-
*/
92-
public void addDemo(Component demo, String label, String sourceCodeUrl) {
93-
Tab tab = new Tab(label);
94-
if (sourceCodeUrl != null) {
95-
demos.put(tab, new SplitLayoutDemo(demo, sourceCodeUrl));
96-
} else {
97-
demos.put(tab, demo);
98-
}
99-
tabs.add(tab);
100-
}
87+
/**
88+
* @param demo the demo instance
89+
* @param name the demo name (tab label)
90+
* @param sourceCodeUrl the url of the demo, <b>null</b> to not show source code section.
91+
*/
92+
public void addDemo(Component demo, String label, String sourceCodeUrl) {
93+
Tab tab = new Tab(label);
94+
if (sourceCodeUrl != null) {
95+
demos.put(tab, new SplitLayoutDemo(demo, sourceCodeUrl));
96+
} else {
97+
demos.put(tab, demo);
98+
}
99+
tabs.add(tab);
100+
}
101101

102-
public void addDemo(Component demo, String label) {
103-
addDemo(demo, label, null);
104-
}
102+
public void addDemo(Component demo, String label) {
103+
addDemo(demo, label, null);
104+
}
105105

106-
private void updateSplitterPosition() {
107-
boolean b = codeCB.getValue();
108-
if (b) {
109-
currentLayout.setSplitterPosition(50);
110-
orientationCB.setEnabled(true);
111-
} else {
112-
currentLayout.setSplitterPosition(100);
113-
orientationCB.setEnabled(false);
114-
}
115-
}
106+
private void updateSplitterPosition() {
107+
boolean b = codeCB.getValue();
108+
if (b) {
109+
currentLayout.setSplitterPosition(50);
110+
orientationCB.setEnabled(true);
111+
} else {
112+
currentLayout.setSplitterPosition(100);
113+
orientationCB.setEnabled(false);
114+
}
115+
}
116116

117-
private void updateSplitterOrientation() {
118-
boolean b = orientationCB.getValue();
119-
if (b) {
120-
currentLayout.setOrientation(Orientation.HORIZONTAL);
121-
} else {
122-
currentLayout.setOrientation(Orientation.VERTICAL);
123-
}
124-
}
117+
private void updateSplitterOrientation() {
118+
boolean b = orientationCB.getValue();
119+
if (b) {
120+
currentLayout.setOrientation(Orientation.HORIZONTAL);
121+
} else {
122+
currentLayout.setOrientation(Orientation.VERTICAL);
123+
}
124+
}
125125
}

src/test/java/com/flowingcode/vaadin/addons/demo/Demo.java

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,35 @@
1919
*/
2020
package com.flowingcode.vaadin.addons.demo;
2121

22-
import com.flowingcode.vaadin.addons.demo.TabbedDemo;
2322
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
2423
import com.vaadin.flow.component.textfield.TextField;
2524
import com.vaadin.flow.router.Route;
2625

27-
/**
28-
* Hello world!
29-
*
30-
*/
26+
/** Hello world! */
3127
@Route("")
3228
public class Demo extends VerticalLayout {
3329

34-
public Demo() {
35-
final String sourceCodeUrl = "https://github.com/FlowingCode/CommonsDemo/blob/master/src/test/java/com/flowingcode/vaadin/addons/demo/impl/Demo.java";
36-
VerticalLayout vl = new VerticalLayout();
37-
VerticalLayout vl2 = new VerticalLayout();
38-
VerticalLayout vl3 = new VerticalLayout();
39-
vl.setSizeFull();
40-
vl.add(new TextField("Hello"));
30+
public Demo() {
31+
final String sourceCodeUrl =
32+
"https://github.com/FlowingCode/CommonsDemo/blob/master/src/test/java/com/flowingcode/vaadin/addons/demo/impl/Demo.java";
33+
VerticalLayout vl = new VerticalLayout();
34+
VerticalLayout vl2 = new VerticalLayout();
35+
VerticalLayout vl3 = new VerticalLayout();
36+
vl.setSizeFull();
37+
vl.add(new TextField("Hello"));
4138

42-
TabbedDemo tabbedDemo = new TabbedDemo();
43-
tabbedDemo.addDemo(vl, "Demo 1", sourceCodeUrl);
39+
TabbedDemo tabbedDemo = new TabbedDemo();
40+
tabbedDemo.addDemo(vl, "Demo 1", sourceCodeUrl);
4441

45-
vl2.add(new TextField("Hi"));
46-
tabbedDemo.addDemo(vl2, "Demo 2", sourceCodeUrl);
42+
vl2.add(new TextField("Hi"));
43+
tabbedDemo.addDemo(vl2, "Demo 2", sourceCodeUrl);
4744

48-
TextField tf = new TextField("Demo Without Source Code");
49-
tf.setWidthFull();
50-
vl3.add(tf);
51-
tabbedDemo.addDemo(vl3, "Demo Without Source Code");
45+
TextField tf = new TextField("Demo Without Source Code");
46+
tf.setWidthFull();
47+
vl3.add(tf);
48+
tabbedDemo.addDemo(vl3, "Demo Without Source Code");
5249

53-
add(tabbedDemo);
54-
setSizeFull();
55-
}
50+
add(tabbedDemo);
51+
setSizeFull();
52+
}
5653
}

0 commit comments

Comments
 (0)