Skip to content

Commit 437c72e

Browse files
paodbjavier-godoy
authored andcommitted
style: apply code formatting
1 parent f2f4de9 commit 437c72e

File tree

6 files changed

+68
-76
lines changed

6 files changed

+68
-76
lines changed

src/main/java/com/flowingcode/vaadin/addons/chipfield/ChipField.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ public ChipRemovedEvent(ChipField<T> source, boolean fromClient, T item) {
102102
}
103103

104104
public static class ChipCreatedEvent<T> extends ChipEvent<T> {
105-
public ChipCreatedEvent(
106-
ChipField<T> source, boolean fromClient, T item) {
105+
public ChipCreatedEvent(ChipField<T> source, boolean fromClient, T item) {
107106
super(source, fromClient, item, source.itemLabelGenerator.apply(item));
108107
}
109108
}
@@ -123,19 +122,20 @@ public ChipField(String label, ItemLabelGenerator<T> itemLabelGenerator, T... av
123122
setLabel(label);
124123
this.availableItems = DataProvider.ofCollection(Arrays.asList(availableItems));
125124

126-
addValueChangeListener(ev -> {
127-
for (T t : ev.getOldValue()) {
128-
if (!ev.getValue().contains(t)) {
129-
fireEvent(new ChipRemovedEvent<>(this, ev.isFromClient(), t));
130-
}
131-
}
132-
133-
for (T t : ev.getValue()) {
134-
if (!ev.getOldValue().contains(t)) {
135-
fireEvent(new ChipCreatedEvent<>(this, ev.isFromClient(), t));
136-
}
137-
}
138-
});
125+
addValueChangeListener(
126+
ev -> {
127+
for (T t : ev.getOldValue()) {
128+
if (!ev.getValue().contains(t)) {
129+
fireEvent(new ChipRemovedEvent<>(this, ev.isFromClient(), t));
130+
}
131+
}
132+
133+
for (T t : ev.getValue()) {
134+
if (!ev.getOldValue().contains(t)) {
135+
fireEvent(new ChipCreatedEvent<>(this, ev.isFromClient(), t));
136+
}
137+
}
138+
});
139139
}
140140

141141
@SafeVarargs
@@ -429,7 +429,6 @@ private void removeSelectedItem(T itemToRemove, boolean fromClient) {
429429
setModelValue(value, fromClient);
430430
if (!fromClient) {
431431
setPresentationValue(value);
432-
433432
}
434433
}
435434
}
@@ -438,5 +437,4 @@ private void removeSelectedItem(T itemToRemove, boolean fromClient) {
438437
public Registration addChipClickedListener(ComponentEventListener<ChipClickedEvent<T>> listener) {
439438
return addListener(ChipClickedEvent.class, (ComponentEventListener) listener);
440439
}
441-
442440
}

src/test/java/com/flowingcode/vaadin/addons/chipfield/integration/AbstractRemoveAndReAddTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ public abstract class AbstractRemoveAndReAddTest extends AbstractViewTest implem
2626
protected AbstractRemoveAndReAddTest() {
2727
super("remove-add-test");
2828
}
29-
3029
}

src/test/java/com/flowingcode/vaadin/addons/chipfield/integration/ChipFieldElement.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,4 @@ public void click(int index) {
4545
TestBenchElement chip = $("paper-chip").get(index);
4646
executeScript("arguments[0].root.querySelector('.chip').click()", chip);
4747
}
48-
4948
}

src/test/java/com/flowingcode/vaadin/addons/chipfield/integration/RemoveAndReAddTestIT.java

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,30 +23,28 @@
2323
import static org.junit.Assert.assertFalse;
2424
import static org.junit.Assert.assertTrue;
2525

26-
import org.junit.Test;
27-
2826
import com.vaadin.flow.component.button.testbench.ButtonElement;
27+
import org.junit.Test;
2928

3029
/**
31-
* Test that shows that removing a chipfield with values from the layout and adding it again doesn't lose the chip values.
32-
*
30+
* Test that shows that removing a chipfield with values from the layout and adding it again doesn't
31+
* lose the chip values.
32+
*
3333
* @see https://github.com/FlowingCode/ChipFieldAddon/issues/33
34-
*
3534
*/
3635
public class RemoveAndReAddTestIT extends AbstractRemoveAndReAddTest {
37-
38-
@Test
39-
public void toggleChipField() {
40-
ChipFieldElement chipfield = $(ChipFieldElement.class).id("chipfield");
41-
assertTrue(chipfield.isDisplayed());
42-
assertEquals(chipfield.getValue().size(), 2);
43-
ButtonElement button = $(ButtonElement.class).id("toggle");
44-
button.click(); // remove chipfield
45-
assertFalse($(ChipFieldElement.class).exists());
46-
button.click(); // add chipfield again
47-
chipfield = $(ChipFieldElement.class).id("chipfield");
48-
assertTrue(chipfield.isDisplayed());
49-
assertEquals(chipfield.getValue().size(), 2);
50-
}
5136

37+
@Test
38+
public void toggleChipField() {
39+
ChipFieldElement chipfield = $(ChipFieldElement.class).id("chipfield");
40+
assertTrue(chipfield.isDisplayed());
41+
assertEquals(chipfield.getValue().size(), 2);
42+
ButtonElement button = $(ButtonElement.class).id("toggle");
43+
button.click(); // remove chipfield
44+
assertFalse($(ChipFieldElement.class).exists());
45+
button.click(); // add chipfield again
46+
chipfield = $(ChipFieldElement.class).id("chipfield");
47+
assertTrue(chipfield.isDisplayed());
48+
assertEquals(chipfield.getValue().size(), 2);
49+
}
5250
}

src/test/java/com/flowingcode/vaadin/addons/chipfield/integration/RemoveAndReAddTestView.java

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
99
* You may obtain a copy of the License at
10-
*
10+
*
1111
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
12+
*
1313
* Unless required by applicable law or agreed to in writing, software
1414
* distributed under the License is distributed on an "AS IS" BASIS,
1515
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,45 +19,42 @@
1919
*/
2020
package com.flowingcode.vaadin.addons.chipfield.integration;
2121

22-
import java.util.Arrays;
23-
2422
import com.flowingcode.vaadin.addons.chipfield.ChipField;
2523
import com.vaadin.flow.component.button.Button;
2624
import com.vaadin.flow.component.html.Div;
2725
import com.vaadin.flow.router.Route;
26+
import java.util.Arrays;
2827

29-
/**
30-
* Test class for fix for issue https://github.com/FlowingCode/ChipFieldAddon/issues/33
31-
*
32-
*/
28+
/** Test class for fix for issue https://github.com/FlowingCode/ChipFieldAddon/issues/33 */
3329
@Route("remove-add-test")
3430
public class RemoveAndReAddTestView extends Div {
35-
36-
public RemoveAndReAddTestView() {
37-
super.getElement().getStyle().set("padding", "5px");
38-
39-
setId("remove-add-test");
40-
41-
ChipField<String> chf =
42-
new ChipField<>("Planets", "Mercury", "Venus", "Earth");
43-
chf.setId("chipfield");
44-
chf.setWidthFull();
45-
46-
chf.addSelectedItem("Mercury");
47-
chf.addSelectedItem("Venus");
48-
chf.setValue(Arrays.asList("Mercury", "Venus"));
49-
50-
Button toggle = new Button("Toggle chipfield", e -> {
51-
if (getChildren().anyMatch(chf::equals)) {
52-
remove(chf);
53-
} else {
54-
add(chf);
55-
}
56-
});
57-
58-
toggle.setId("toggle");
59-
60-
add(toggle, chf);
61-
}
62-
31+
32+
public RemoveAndReAddTestView() {
33+
super.getElement().getStyle().set("padding", "5px");
34+
35+
setId("remove-add-test");
36+
37+
ChipField<String> chf = new ChipField<>("Planets", "Mercury", "Venus", "Earth");
38+
chf.setId("chipfield");
39+
chf.setWidthFull();
40+
41+
chf.addSelectedItem("Mercury");
42+
chf.addSelectedItem("Venus");
43+
chf.setValue(Arrays.asList("Mercury", "Venus"));
44+
45+
Button toggle =
46+
new Button(
47+
"Toggle chipfield",
48+
e -> {
49+
if (getChildren().anyMatch(chf::equals)) {
50+
remove(chf);
51+
} else {
52+
add(chf);
53+
}
54+
});
55+
56+
toggle.setId("toggle");
57+
58+
add(toggle, chf);
59+
}
6360
}

src/test/java/com/flowingcode/vaadin/addons/chipfield/integration/ViewIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static org.hamcrest.MatcherAssert.assertThat;
2323
import static org.junit.Assert.assertThrows;
2424
import static org.junit.Assert.assertTrue;
25+
2526
import java.util.Arrays;
2627
import java.util.Collection;
2728
import org.hamcrest.Matcher;

0 commit comments

Comments
 (0)