Skip to content

Commit 8b586ea

Browse files
elPeirettijavier-godoy
authored andcommitted
feat(demo): add base demo class
1 parent 172fe46 commit 8b586ea

File tree

2 files changed

+45
-21
lines changed

2 files changed

+45
-21
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*-
2+
* #%L
3+
* LocaleComboBox Add-on
4+
* %%
5+
* Copyright (C) 2024 Flowing Code
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.flowingcode.vaadin.addons.localecombobox;
21+
22+
import com.vaadin.flow.component.Text;
23+
import com.vaadin.flow.component.html.Div;
24+
import com.vaadin.flow.component.html.Span;
25+
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
26+
import com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment;
27+
import com.vaadin.flow.component.orderedlayout.FlexComponent.JustifyContentMode;
28+
29+
@SuppressWarnings("serial")
30+
public class BaseLocaleComboBoxDemo extends Div {
31+
32+
protected HorizontalLayout createHorizontalContainer(String title, LocaleComboBox combo) {
33+
Span titleSpan = new Span(new Text(title));
34+
titleSpan.setWidth("300px");
35+
HorizontalLayout container = new HorizontalLayout();
36+
container.setWidthFull();
37+
container.setAlignItems(Alignment.CENTER);
38+
container.setJustifyContentMode(JustifyContentMode.BETWEEN);
39+
container.add(titleSpan, combo);
40+
container.expand(combo);
41+
return container;
42+
}
43+
44+
}

src/test/java/com/flowingcode/vaadin/addons/localecombobox/DisplayModeDemo.java

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
package com.flowingcode.vaadin.addons.localecombobox;
2222

2323
import com.flowingcode.vaadin.addons.demo.DemoSource;
24-
import com.vaadin.flow.component.Text;
25-
import com.vaadin.flow.component.html.Div;
26-
import com.vaadin.flow.component.html.Span;
27-
import com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment;
28-
import com.vaadin.flow.component.orderedlayout.FlexComponent.JustifyContentMode;
29-
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
3024
import com.vaadin.flow.router.PageTitle;
3125
import com.vaadin.flow.router.Route;
3226
import java.util.Arrays;
@@ -37,7 +31,7 @@
3731
@PageTitle("Display modes")
3832
@SuppressWarnings("serial")
3933
@Route(value = "demo", layout = LocaleComboBoxDemoView.class)
40-
public class DisplayModeDemo extends Div {
34+
public class DisplayModeDemo extends BaseLocaleComboBoxDemo {
4135

4236
public DisplayModeDemo() {
4337

@@ -70,18 +64,4 @@ public DisplayModeDemo() {
7064
// show-source add(selectedLocaleCombo);
7165
}
7266

73-
// #if vaadin eq 0
74-
private HorizontalLayout createHorizontalContainer(String title, LocaleComboBox combo) {
75-
Span titleSpan = new Span(new Text(title));
76-
titleSpan.setWidth("300px");
77-
HorizontalLayout container = new HorizontalLayout();
78-
container.setWidthFull();
79-
container.setAlignItems(Alignment.CENTER);
80-
container.setJustifyContentMode(JustifyContentMode.BETWEEN);
81-
container.add(titleSpan, combo);
82-
container.expand(combo);
83-
return container;
84-
}
85-
// #endif
86-
8767
}

0 commit comments

Comments
 (0)