public void doAction(IGridTable table) { IWritableGrid grid = (IWritableGrid) table.getGrid(); removedRegions = new ArrayList<IGridRegion>(); int nregions = grid.getNumberOfMergedRegions(); for (int i = 0; i < nregions; i++) { IGridRegion reg = grid.getMergedRegion(i); if (IGridRegion.Tool.contains(region, reg.getLeft(), reg.getTop())) { removedRegions.add(reg); } } for (IGridRegion regionToRemove : removedRegions) { grid.removeMergedRegion(regionToRemove); } grid.addMergedRegion(region); }
public static boolean canInsertRows(IGridTable table, int nRows) { IGridRegion region = getOriginalRegion(table); GridRegion newRegion = new GridRegion( region.getBottom() + 1, region.getLeft() - 1, region.getBottom() + 1 + nRows, region.getRight() + 1); IGridTable[] allGridTables = table.getGrid().getTables(); for (int i = 0; i < allGridTables.length; i++) { if (!table.getUri().equals(allGridTables[i].getUri()) && IGridRegion.Tool.intersects(newRegion, allGridTables[i].getRegion())) { return false; } } return true; }