From 854f9b7a25f24f44a4cbad8f4d7a13ce5113c1d4 Mon Sep 17 00:00:00 2001 From: "TatuWorkLenovo\\Tatu" Date: Wed, 29 Nov 2023 10:49:38 +0200 Subject: [PATCH] Version 3.1.5: Small fixes and fix class name conflict with Tree add-on --- pom.xml | 4 +-- src/main/java/org/vaadin/tatu/BeanTable.java | 35 ++++++++++++------- ...va => BeanTableSelectionChangedEvent.java} | 4 +-- .../resources/frontend/styles/bean-table.css | 2 +- .../org/vaadin/tatu/AbstractViewTest.java | 2 +- 5 files changed, 28 insertions(+), 19 deletions(-) rename src/main/java/org/vaadin/tatu/{SelectionChangedEvent.java => BeanTableSelectionChangedEvent.java} (73%) diff --git a/pom.xml b/pom.xml index 11b49a8..736d9ba 100644 --- a/pom.xml +++ b/pom.xml @@ -3,11 +3,11 @@ 4.0.0 org.vaadin.tatu beantable - 3.1.4 + 3.1.5 BeanTable Table component for Vaadin platform - 24.1.7 + 24.2.2 17 17 UTF-8 diff --git a/src/main/java/org/vaadin/tatu/BeanTable.java b/src/main/java/org/vaadin/tatu/BeanTable.java index 323e7f0..e9bbf5c 100644 --- a/src/main/java/org/vaadin/tatu/BeanTable.java +++ b/src/main/java/org/vaadin/tatu/BeanTable.java @@ -488,8 +488,8 @@ void toggleSelection() { rowElement.getChildren().forEach( cell -> cell.setAttribute("aria-selected", "true")); } - fireEvent(new SelectionChangedEvent<>(BeanTable.this, selected, - true)); + fireEvent(new BeanTableSelectionChangedEvent<>(BeanTable.this, + selected, true)); } } @@ -1369,7 +1369,7 @@ public Optional> getColumn(String key) { } private String randomId(String prefix, int chars) { - int limit = (10 * chars) - 1; + int limit = (int) (Math.pow(10, chars) - 1); String key = "" + rand.nextInt(limit); key = String.format("%" + chars + "s", key).replace(' ', '0'); return prefix + "-" + key; @@ -1472,8 +1472,8 @@ public void focus(T item) { *

* Note: If FocusBehavior.NONE used, then does nothing. * - * @param row - * @param col + * @param row int value + * @param col int value */ public void focus(int row, int col) { if (focusBehavior != FocusBehavior.NONE) { @@ -1587,8 +1587,8 @@ public void select(T... items) { } if (added) { getDataProvider().refreshAll(); - fireEvent(new SelectionChangedEvent<>(BeanTable.this, selected, - false)); + fireEvent(new BeanTableSelectionChangedEvent<>(BeanTable.this, + selected, false)); } } @@ -1609,8 +1609,8 @@ public void deselect(T... items) { } if (removed) { getDataProvider().refreshAll(); - fireEvent(new SelectionChangedEvent<>(BeanTable.this, selected, - false)); + fireEvent(new BeanTableSelectionChangedEvent<>(BeanTable.this, + selected, false)); } } @@ -1620,8 +1620,8 @@ public void deselect(T... items) { public void deselectAll() { if (!selected.isEmpty()) { selected.clear(); - fireEvent(new SelectionChangedEvent<>(BeanTable.this, selected, - false)); + fireEvent(new BeanTableSelectionChangedEvent<>(BeanTable.this, + selected, false)); getDataProvider().refreshAll(); } } @@ -1667,8 +1667,9 @@ public void setSelectionEnabled(boolean selectionEnabled) { */ @SuppressWarnings("unchecked") public Registration addSelectionChangedListener( - ComponentEventListener>> listener) { - return ComponentUtil.addListener(this, SelectionChangedEvent.class, + ComponentEventListener>> listener) { + return ComponentUtil.addListener(this, + BeanTableSelectionChangedEvent.class, (ComponentEventListener) listener); } @@ -1686,6 +1687,9 @@ public Registration addItemClickedListener( (ComponentEventListener) listener); } + /** + * Localization object for BeanTable + */ @SuppressWarnings("serial") public static class BeanTableI18n implements Serializable { private String lastPage; @@ -1762,6 +1766,11 @@ public void setPageProvider( this.pageProvider = provider; } + /** + * Generate the default English localization. + * + * @return localization object + */ public static BeanTableI18n getDefault() { BeanTableI18n english = new BeanTableI18n(); english.setFirstPage("First page"); diff --git a/src/main/java/org/vaadin/tatu/SelectionChangedEvent.java b/src/main/java/org/vaadin/tatu/BeanTableSelectionChangedEvent.java similarity index 73% rename from src/main/java/org/vaadin/tatu/SelectionChangedEvent.java rename to src/main/java/org/vaadin/tatu/BeanTableSelectionChangedEvent.java index 112a964..4d125a9 100644 --- a/src/main/java/org/vaadin/tatu/SelectionChangedEvent.java +++ b/src/main/java/org/vaadin/tatu/BeanTableSelectionChangedEvent.java @@ -5,11 +5,11 @@ import com.vaadin.flow.component.ComponentEvent; @SuppressWarnings({ "serial", "rawtypes" }) -public class SelectionChangedEvent +public class BeanTableSelectionChangedEvent extends ComponentEvent { private Set selection; - public SelectionChangedEvent(C source, Set selection, + public BeanTableSelectionChangedEvent(C source, Set selection, boolean fromClient) { super(source, fromClient); this.selection = selection; diff --git a/src/main/resources/META-INF/resources/frontend/styles/bean-table.css b/src/main/resources/META-INF/resources/frontend/styles/bean-table.css index b043e34..40bd5b9 100644 --- a/src/main/resources/META-INF/resources/frontend/styles/bean-table.css +++ b/src/main/resources/META-INF/resources/frontend/styles/bean-table.css @@ -2,7 +2,7 @@ font-weight: 700; background: var(--lumo-contrast-5pct); position: relative; - height: 30px; + height: var(--lumo-size-xs); } .bean-table thead tr { diff --git a/src/test/java/org/vaadin/tatu/AbstractViewTest.java b/src/test/java/org/vaadin/tatu/AbstractViewTest.java index d6e9721..29aeb45 100644 --- a/src/test/java/org/vaadin/tatu/AbstractViewTest.java +++ b/src/test/java/org/vaadin/tatu/AbstractViewTest.java @@ -105,7 +105,7 @@ public static String getTestURL(String rootUrl, String... parameters) { @Before public void setup() throws Exception { ChromeOptions options = new ChromeOptions(); - options.setHeadless(true); + options.addArguments("--headless=new"); setDriver(TestBench.createDriver(new ChromeDriver(options))); getDriver().get(getURL(route));