Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ types.d.ts
/.npmrc
/frontend/generated
/frontend/index.html
/src/main/frontend/generated
/src/main/frontend/index.html
/pnpm-lock.yaml
/pnpmfile.js
/src/main/dev-bundle
/src/main/bundles
vite.generated.ts
vite.config.ts
27 changes: 16 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.vaadin.addons.flowingcode</groupId>
<artifactId>grid-helpers</artifactId>
<version>1.4.6-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
<name>Grid Helpers Add-on</name>
<description>Grid Helpers Add-on for Vaadin Flow</description>
<url>https://www.flowingcode.com/en/open-source/</url>
Expand Down Expand Up @@ -89,6 +89,16 @@
<id>vaadin-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
</repository>
<repository>
<id>FlowingCode Snapshots</id>
<url>https://maven.flowingcode.com/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>

<pluginRepositories>
Expand Down Expand Up @@ -124,6 +134,11 @@
<artifactId>vaadin-core</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.flowingcode.vaadin</groupId>
<artifactId>json-migration-helper</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
Expand Down Expand Up @@ -595,16 +610,6 @@
<id>vaadin-prerelease</id>
<url>https://maven.vaadin.com/vaadin-prereleases</url>
</repository>
<repository>
<id>FlowingCode Snapshots</id>
<url>https://maven.flowingcode.com/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@

package com.flowingcode.vaadin.addons.gridhelpers;

import com.flowingcode.vaadin.jsonmigration.JsonMigration;
import com.vaadin.flow.component.ComponentUtil;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.grid.dataview.GridListDataView;
import com.vaadin.flow.shared.Registration;
import elemental.json.JsonObject;
import java.io.Serializable;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -101,26 +103,27 @@ void enableEnhancedSelection() {
});

keyUpRegistration = grid.getElement().addEventListener("keyup", ev -> {
String keyUp = ev.getEventData().getString(KEY_UP_EVENT_KEY);
JsonObject eventData = JsonMigration.getEventData(ev);

String keyUp = eventData.getString(KEY_UP_EVENT_KEY);
boolean arrowsKey = "ArrowDown".equals(keyUp) || "ArrowUp".equals(keyUp);

GridListDataView<T> dataView = grid.getListDataView();

Optional<T> newFocusedItemMaybe = Optional.empty();
int newFocusedItemIndex =
(int) ev.getEventData().getNumber(KEY_UP_ELEMENT_FOCUSED_ITEM_INDEX);
int newFocusedItemIndex = (int) eventData.getNumber(KEY_UP_ELEMENT_FOCUSED_ITEM_INDEX);
if (newFocusedItemIndex >= 0) {
newFocusedItemMaybe = dataView.getItems().skip(newFocusedItemIndex).findFirst();
}

if (newFocusedItemMaybe.isPresent()) {
T newFocusedItem = newFocusedItemMaybe.get();
boolean isSpecialKey = ev.getEventData().getBoolean(KEY_UP_EVENT_META_KEY)
|| ev.getEventData().getBoolean(KEY_UP_EVENT_CTRL_KEY)
|| ev.getEventData().getBoolean(KEY_UP_EVENT_ALT_KEY);
boolean isSpecialKey = eventData.getBoolean(KEY_UP_EVENT_META_KEY)
|| eventData.getBoolean(KEY_UP_EVENT_CTRL_KEY)
|| eventData.getBoolean(KEY_UP_EVENT_ALT_KEY);

Object lastFocusedItem = ComponentUtil.getData(grid, LAST_FOCUSED_ITEM);
boolean shiftKey = ev.getEventData().getBoolean(KEY_UP_EVENT_SHIFT_KEY);
boolean shiftKey = eventData.getBoolean(KEY_UP_EVENT_SHIFT_KEY);
if (shiftKey) {
if (lastFocusedItem == null) {
ComponentUtil.setData(grid, LAST_FOCUSED_ITEM, newFocusedItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
* Server side implementation for the flow specific grid radio selection column.
*/
@Tag("grid-flow-radio-selection-column")
@JsModule("@vaadin/polymer-legacy-adapter/style-modules.js")
@JsModule("./fcGridHelper/grid-flow-radio-selection-column.js")
@Uses(RadioButtonGroup.class)
// Indirectly ensure @NpmPackage(value = "@vaadin/polymer-legacy-adapter", version = "x.x.x")
// and @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js")
@Uses(Grid.class)
public class GridRadioSelectionColumn extends Component implements HasStyle {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* #%L
* Grid Helpers Add-on
* %%
* Copyright (C) 2022 - 2024 Flowing Code
* Copyright (C) 2022 - 2025 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@
*/
package com.flowingcode.vaadin.addons.gridhelpers;

import com.flowingcode.vaadin.jsonmigration.JsonMigration;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.dom.DebouncePhase;
import com.vaadin.flow.shared.Registration;
Expand Down Expand Up @@ -76,7 +77,7 @@ GridResponsiveStep<T> getOrCreate(int minWidth) {
private void initialize() {
Grid<T> grid = helper.getGrid();
grid.getElement().addEventListener("fcgh-responsive-step", ev -> {
apply((int) ev.getEventData().getNumber("event.detail.step"), false);
apply((int) JsonMigration.getEventData(ev).getNumber("event.detail.step"), false);
}).addEventData("event.detail.step").debounce(200, DebouncePhase.TRAILING);
sendSteps();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.grid.Grid.SelectionMode;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Label;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.FlexComponent.JustifyContentMode;
Expand Down Expand Up @@ -189,7 +188,8 @@ public AllFeaturesDemo() {
heightByRowsField.setStepButtonsVisible(true);

binder.getFields().map(Component.class::cast).forEach(features::add);
Label label = new Label("Features");

CompatibilityLabel label = new CompatibilityLabel("Features");
label.addClassNames("label");

features.addComponentAtIndex(2, label);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*-
* #%L
* Grid Helpers Add-on
* %%
* Copyright (C) 2022 - 2025 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.flowingcode.vaadin.addons.gridhelpers;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.HasStyle;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.Text;

@Tag(Tag.LABEL)
public class CompatibilityLabel extends Component implements HasStyle {

public CompatibilityLabel(String text) {
getElement().appendChild(new Text(text).getElement());
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public WebElement getHeaderRow(int rowIndex) {
return headerRows.get(rowIndex);
}

public WebElement getHeaderCell(int rowIndex, int columnIndex) {
public WebElement getHeaderCellAt(int rowIndex, int columnIndex) {
List<WebElement> headerCells = getHeaderRow(rowIndex).findElements(By.tagName("th"));
return headerCells.get(columnIndex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public void testHeaderClassesApplied() {
row1.getCell(i).setClassName("row1-cell" + i);
}

assertEquals("row0-cell0", grid.getHeaderCell(0, 0).getAttribute("class"));
assertEquals("row0-cell1", grid.getHeaderCell(0, 1).getAttribute("class"));
assertEquals("row0-cell0", grid.getHeaderCellAt(0, 0).getAttribute("class"));
assertEquals("row0-cell1", grid.getHeaderCellAt(0, 1).getAttribute("class"));

for (int i = 0; i < 5; i++) {
assertEquals("row1-cell" + i, grid.getHeaderCell(1, i).getAttribute("class"));
assertEquals("row1-cell" + i, grid.getHeaderCellAt(1, i).getAttribute("class"));
}
}

Expand All @@ -72,8 +72,8 @@ public void testHeaderCellMutability() {
$server.setColumnOrder(2, 3, 0, 1, 4);
header0.setClassName("row0-cell0");
header1.setClassName("row0-cell1");
assertEquals("row0-cell1", grid.getHeaderCell(0, 0).getAttribute("class"));
assertEquals("row0-cell0", grid.getHeaderCell(0, 1).getAttribute("class"));
assertEquals("row0-cell1", grid.getHeaderCellAt(0, 0).getAttribute("class"));
assertEquals("row0-cell0", grid.getHeaderCellAt(0, 1).getAttribute("class"));
}

}