Skip to content

Commit

Permalink
refactor: rename component as DayOfWeekSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
javier-godoy committed Dec 29, 2023
1 parent f9aff79 commit f9376f6
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@SuppressWarnings("serial")
@CssImport("./styles/fc-days-of-week-selector-styles.css")
public class DaysOfWeekSelector extends CustomField<Set<DayOfWeek>> {
public class DayOfWeekSelector extends CustomField<Set<DayOfWeek>> {

private static class DayOfWeekButton extends Button {
private static final String CLASS_NAME = "fc-days-of-week-selector-button";
Expand Down Expand Up @@ -54,7 +54,7 @@ private void setState(boolean state) {

private HorizontalLayout buttonsLayout;

public DaysOfWeekSelector() {
public DayOfWeekSelector() {
getStyle().set("padding", "var(--lumo-space-m)");

buttonsLayout = new HorizontalLayout();
Expand All @@ -71,19 +71,19 @@ public DaysOfWeekSelector() {
clear();
}

public DaysOfWeekSelector(DayOfWeek... value) {
public DayOfWeekSelector(DayOfWeek... value) {
this();
if (value.length > 0) {
setValue(value[0], value);
}
}

public DaysOfWeekSelector(String label) {
public DayOfWeekSelector(String label) {
this();
setLabel(label);
}

public DaysOfWeekSelector(String label, DayOfWeek... value) {
public DayOfWeekSelector(String label, DayOfWeek... value) {
this(value);
setLabel(label);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
@DemoSource
@PageTitle("Binder")
@SuppressWarnings("serial")
@Route(value = "day-of-week-selector/binder", layout = DaysOfWeekSelectorDemoView.class)
public class DaysOfWeekSelectorBinderDemo extends Div {
@Route(value = "day-of-week-selector/binder", layout = DayOfWeekSelectorDemoView.class)
public class DayOfWeekSelectorBinderDemo extends Div {

public DaysOfWeekSelectorBinderDemo() {
public DayOfWeekSelectorBinderDemo() {

// begin-block selector1
Span span1 = new Span();
Binder<Bean> binder1 = new Binder<>();
DaysOfWeekSelector selector1 = new DaysOfWeekSelector("Bound field");
DayOfWeekSelector selector1 = new DayOfWeekSelector("Bound field");
binder1.forField(selector1).bind(Bean::getDays, Bean::setDays);
add(selector1, span1);

Expand All @@ -36,7 +36,7 @@ public DaysOfWeekSelectorBinderDemo() {
// begin-block selector2
Span span2 = new Span();
Binder<Bean> binder2 = new Binder<>();
DaysOfWeekSelector selector2 = new DaysOfWeekSelector("Bound field, required");
DayOfWeekSelector selector2 = new DayOfWeekSelector("Bound field, required");
binder2.forField(selector2).asRequired().bind(Bean::getDays, Bean::setDays);
add(selector2, span2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
@DemoSource
@PageTitle("Demo")
@SuppressWarnings("serial")
@Route(value = "day-of-week-selector/demo", layout = DaysOfWeekSelectorDemoView.class)
public class DaysOfWeekSelectorDemo extends Div {
@Route(value = "day-of-week-selector/demo", layout = DayOfWeekSelectorDemoView.class)
public class DayOfWeekSelectorDemo extends Div {

public DaysOfWeekSelectorDemo() {
DaysOfWeekSelector selector1 =
new DaysOfWeekSelector("Enabled", DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY);
public DayOfWeekSelectorDemo() {
DayOfWeekSelector selector1 =
new DayOfWeekSelector("Enabled", DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY);
add(selector1);

DaysOfWeekSelector selector2 =
new DaysOfWeekSelector("Read-only", DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY);
DayOfWeekSelector selector2 =
new DayOfWeekSelector("Read-only", DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY);
selector2.setReadOnly(true);
add(selector2);

DaysOfWeekSelector selector3 =
new DaysOfWeekSelector("Disabled", DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY);
DayOfWeekSelector selector3 =
new DayOfWeekSelector("Disabled", DayOfWeek.MONDAY, DayOfWeek.WEDNESDAY);
selector3.setEnabled(false);
add(selector3);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@

@SuppressWarnings("serial")
@ParentLayout(DemoLayout.class)
@Route("days-of-week-selector")
@Route("day-of-week-selector")
@GithubLink("https://github.com/FlowingCode/AddonStarter24")
public class DaysOfWeekSelectorDemoView extends TabbedDemo {
public class DayOfWeekSelectorDemoView extends TabbedDemo {

public DaysOfWeekSelectorDemoView() {
addDemo(DaysOfWeekSelectorDemo.class);
addDemo(DaysOfWeekSelectorBinderDemo.class);
addDemo(DaysOfWeekSelectorI18NDemo.class);
public DayOfWeekSelectorDemoView() {
addDemo(DayOfWeekSelectorDemo.class);
addDemo(DayOfWeekSelectorBinderDemo.class);
addDemo(DayOfWeekSelectorI18NDemo.class);
setSizeFull();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
@DemoSource
@PageTitle("I18N")
@SuppressWarnings("serial")
@Route(value = "day-of-week-selector/i18n", layout = DaysOfWeekSelectorDemoView.class)
public class DaysOfWeekSelectorI18NDemo extends Div {
@Route(value = "day-of-week-selector/i18n", layout = DayOfWeekSelectorDemoView.class)
public class DayOfWeekSelectorI18NDemo extends Div {

public DaysOfWeekSelectorI18NDemo() {
DaysOfWeekSelector selector = new DaysOfWeekSelector();
public DayOfWeekSelectorI18NDemo() {
DayOfWeekSelector selector = new DayOfWeekSelector();
selector.setWeekDaysShort(List.of("D", "L", "M", "X", "J", "V", "S"));
selector.setFirstDayOfWeek(DayOfWeek.MONDAY);
add(selector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public class DemoView extends VerticalLayout implements BeforeEnterObserver {

@Override
public void beforeEnter(BeforeEnterEvent event) {
event.forwardTo(DaysOfWeekSelectorDemoView.class);
event.forwardTo(DayOfWeekSelectorDemoView.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
package com.flowingcode.vaadin.addons.dayofweekselector.test;

import com.flowingcode.vaadin.addons.dayofweekselector.DaysOfWeekSelector;
import com.flowingcode.vaadin.addons.dayofweekselector.DayOfWeekSelector;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand All @@ -44,7 +44,7 @@ private void testSerializationOf(Object obj) throws IOException, ClassNotFoundEx
@Test
public void testSerialization() throws ClassNotFoundException, IOException {
try {
testSerializationOf(new DaysOfWeekSelector());
testSerializationOf(new DayOfWeekSelector());
} catch (Exception e) {
Assert.fail("Problem while testing serialization: " + e.getMessage());
}
Expand Down

0 comments on commit f9376f6

Please sign in to comment.