io.imunity.console.views.directory_browser.GridSelectionSupport Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unity-server-console Show documentation
Show all versions of unity-server-console Show documentation
Task oriented web based administration UI
/*
* Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
* See LICENCE.txt file for licensing information.
*/
package io.imunity.console.views.directory_browser;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.grid.ItemClickEvent;
public class GridSelectionSupport
{
public static void installClickListener(Grid grid)
{
grid.addItemClickListener(e -> onMouseClick(grid, e));
}
private static void onMouseClick(Grid grid, ItemClickEvent event)
{
if (event.getClickCount() == 2)
return;
T item = event.getItem();
boolean alreadySelected = grid.getSelectedItems().contains(item);
if (!alreadySelected)
{
grid.deselectAll();
grid.select(item);
}
}
}