All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.imunity.console.views.directory_browser.GridSelectionSupport Maven / Gradle / Ivy

There is a newer version: 4.0.3
Show newest version
/*
 * 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);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy