JetBrains/intellij-community · error · IllegalStateException

Operation is not permitted for nested grids.

Error message

Operation is not permitted for nested grids.

What it means

NestedTablesDataGridModel.allValuesEqualTo throws IllegalStateException when called while a nested (non-top-level) grid is selected. Bulk predicates over model index sets only make sense on the top-level model; when the user has drilled into a nested table, the operation is deliberately blocked.

Source

Thrown at grid/core-impl/src/datagrid/NestedTablesDataGridModel.java:106

  @Override
  public boolean hasListeners() {
    return myModel.hasListeners();
  }

  @Override
  public @Nullable Object getValueAt(ModelIndex<GridRow> rowIdx, ModelIndex<GridColumn> columnIdx) {
    if (isTopLevelGrid()) return myModel.getValueAt(rowIdx, columnIdx);
    if (!isValidRowIdx(rowIdx) || !isValidColumnIdx(columnIdx)) return null;

    return myCurrentlySelectedNestedTable.getValueAt(rowIdx.asInteger(), columnIdx.asInteger());
  }

  @Override
  public boolean allValuesEqualTo(@NotNull ModelIndexSet<GridRow> rowIndices,
                                  @NotNull ModelIndexSet<GridColumn> columnIndices,
                                  @Nullable Object what) {
    if (!isTopLevelGrid()) {
      throw new IllegalStateException("Operation is not permitted for nested grids.");
    }
    return myModel.allValuesEqualTo(rowIndices, columnIndices, what);
  }

  @Override
  public @Nullable GridRow getRow(@NotNull ModelIndex<GridRow> row) {
    if (isTopLevelGrid()) return myModel.getRow(row);
    return getRow(row.asInteger());
  }

  @Override
  public @Nullable GridColumn getColumn(@NotNull ModelIndex<GridColumn> column) {
    if (isTopLevelGrid()) return myModel.getColumn(column);
    return new NestedTableColumn(column.asInteger(), myCurrentlySelectedNestedTable);
  }

  @Override
  public @NotNull JBIterable<GridColumn> getColumnsAsIterable() {

View on GitHub (pinned to be881553f2)

Solutions

  1. Check isTopLevelGrid() (or that no nested table is selected) before calling allValuesEqualTo.
  2. Disable or re-scope bulk operations to the selected nested table when not top-level.
  3. Call the underlying model directly if the operation must run on top-level data while a nested view is open.

Example fix

// before
boolean all = model.allValuesEqualTo(rows, cols, value);

// after
if (model.isTopLevelGrid()) {
  boolean all = model.allValuesEqualTo(rows, cols, value);
}
Defensive patterns

Strategy: validation

Validate before calling

if (model.isTopLevelGrid()) {
  boolean all = model.allValuesEqualTo(rows, cols, what);
}

Type guard

static boolean supportsBulkOps(NestedTablesDataGridModel m) { return m.isTopLevelGrid(); }

Prevention

When it happens

Trigger: Invoking allValuesEqualTo(rowIndices, columnIndices, what) on the wrapper while myPathToSelectedNestedTable is non-empty (a nested table is currently selected).

Common situations: Bulk-edit or find/replace tooling that runs regardless of drill-down state; actions not disabled when the selection moves into a nested grid.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/a722e45beb8c71f6. Report an issue: GitHub.