[DataSpell] [DS-7097] Add an ability to unselect the cells in data grid

(cherry picked from commit 2edd8c1385e84fbc9b497519802ca519f185c429)

GitOrigin-RevId: c3b1f8172869b00399d751fca20cea3a1e4b02f3
This commit is contained in:
Alex Plate
2025-07-09 15:36:51 +03:00
committed by intellij-monorepo-bot
parent 595a7f661b
commit 200d15fa4f
5 changed files with 17 additions and 0 deletions

View File

@@ -46,6 +46,8 @@ public interface SelectionModel<Row, Column> {
void selectWholeColumn();
void clearSelection();
@NotNull
ModelIndex<Row> getSelectedRow();

View File

@@ -119,6 +119,10 @@ public final class SelectionModelUtil {
public void selectWholeColumn() {
}
@Override
public void clearSelection() {
}
@Override
public @NotNull ModelIndex<GridRow> getSelectedRow() {
return ModelIndex.forRow(myGrid, -1);

View File

@@ -201,6 +201,11 @@ class TableSelectionModel implements SelectionModel<GridRow, GridColumn>, Select
myGrid.getAutoscrollLocker().runWithLock(() -> setRowSelectionInterval(myTable.getRowCount() - 1, 0));
}
@Override
public void clearSelection() {
myTable.clearSelection();
}
private void setSelection(boolean columns, int[] array) {
if (myTable.isTransposed() && columns || !myTable.isTransposed() && !columns) {
setSelection(myTable.getSelectionModel(), false, myTable.getRowCount() - 1, array);

View File

@@ -182,6 +182,11 @@ class TreeTableSelectionModel implements SelectionModel<GridRow, GridColumn>, Se
});
}
@Override
public void clearSelection() {
myView.getComponent().getTree().clearSelection();
}
@Override
public @NotNull ModelIndex<GridRow> getSelectedRow() {
TreePath path = myView.getComponent().getTree().getSelectionPath();

View File

@@ -2967,6 +2967,7 @@ action.RestoreProtocolHandler.text=Register Gateway Protocol
action.GatewayPluginsAction.text=Manage Providers
action.DSOpenConsole.text=Open Python Console
action.CopyTableGridAction.text=Copy Data
action.ResetTableGridSelectionAction.text=Clear Selection
action.plugins.autoupdate.repository.view.text=View Plugins Auto-Update Repository
action.ToolWindowShowNamesAction.text=Show Tool Window Names