public GridLocation(IGridTable table) { int width = table.getWidth(); int height = table.getHeight(); start = new GridPosition(table.getGridColumn(0, 0), table.getGridRow(0, 0), table.getGrid()); end = new GridPosition(table.getGridColumn(width - 1, height - 1), table.getGridRow(width - 1, height - 1), table.getGrid()); }
/** * @param entireTable The entire table with two dimensions(WITHOUT a * header). * @param lookupValuesTable The "values subtable" */ public TwoDimensionDecisionTableTranformer(IGridTable entireTable, IGridTable lookupValuesTable, int retTableWidth) { this.lookupValuesTableHeight = lookupValuesTable.getHeight(); this.lookupValuesTableWidth = lookupValuesTable.getWidth(); this.conditionsWidth = entireTable.getWidth() - lookupValuesTableWidth; this.hConditionsCount = entireTable.getHeight() - lookupValuesTableHeight - HCONDITION_HEADERS_HEIGHT; this.retTableWidth = retTableWidth; this.dtHeaderHeight = CONDITION_HEADERS_HEIGHT + (hConditionsCount - 1); }
headerStyle = originalTable.getCell(0, 0).getStyle(); logicBaseTableStartRow++; IGridTable gridTable = originalTable.getSubtable(0, logicBaseTableStartRow, originalTable.getWidth(), originalTable.getHeight() - logicBaseTableStartRow); int tableWidth = originalTable.getWidth(); if (tableWidth < 3 && buildedPropForNewTable != null && !buildedPropForNewTable.isEmpty()) { tableWidth = 3; tableHeight += buildedPropForNewTable.size(); tableHeight += gridTable.getHeight();
public static boolean canInsertColumns(IGridTable table, int nCols) { IGridRegion region = getOriginalRegion(table); GridRegion newRegion = new GridRegion(region.getTop() - 1, region.getRight() + 1, region.getBottom() + 1, region.getRight() + 1 + nCols); IGridTable[] allGridTables = table.getGrid().getTables(); for (IGridTable allGridTable : allGridTables) { if (!table.getUri().equals(allGridTable.getUri()) && IGridRegion.Tool.intersects(newRegion, allGridTable.getRegion())) { return false; } } return true; }
/** * @return Count of rows that is not showed. */ public int getNumberOfNonShownRows() { return GridRegion.Tool.height(getOriginalTableRegion()) - GridRegion.Tool.height(gridTable.getRegion()); }
public static int[] calculateRowOffsets(int height, IGridTable gt) { int[] rowOffset = new int[height + 1]; int offset = 0; for (int i = 0, cellHeight = 0; i < height; offset += cellHeight, ++i) { rowOffset[i] = offset; cellHeight = gt.getCell(0, offset).getHeight(); } rowOffset[height] = offset; return rowOffset; }
public synchronized void moveTableTo(IGridTable table, IGridRegion destRegion) throws TableServiceException { if (Tool.height(destRegion) != table.getHeight() || Tool.width(destRegion) != table.getWidth()) { throw new TableServiceException("Bad destination region size."); } try { TableBuilder tableBuilder = new TableBuilder((XlsSheetGridModel) table.getGrid(), metaInfoWriter); tableBuilder.beginTable(destRegion); tableBuilder.writeGridTable(table); tableBuilder.endTable(); } catch (Exception e) { throw new TableServiceException("Could not move the table", e); } removeTable(table); } }
private static int calculateCompoundReturnColumnsCount(ILogicalTable originalTable, int numberOfConditions, int numberOfMergedRows) { IGridTable gt = originalTable.getSource().getRow(numberOfMergedRows); int w = gt.getWidth(); int w0 = 0; int i = 0; while (i < w) { i = i + gt.getCell(i, 0).getWidth(); w0++; } return w0 - numberOfConditions; }
private SubValue[] createSV(TableColumn column, IGridTable grid, int r, int subColumns) { SubValue[] values = new SubValue[subColumns]; for (int c = 0; c < subColumns; c++) { String value = grid.getCell(c, r).getStringValue(); if (value == null) { value = ""; } else { // kill extra spaces -- fix type errors value = value.trim(); } String cellName = "cell" + r + "_" + column.getColumnIndex() + "_" + c; StringValue sv = new StringValue(value, cellName, cellName, new GridCellSourceCodeModule(grid, c, r, bindingContext)); values[c] = new SubValue(sv, grid.getCell(c, r).getStyle()); IGridTable lr = grid.getSubtable(c, r, 1, 1); values[c].setGridRegion(lr.getRegion()); } return values; }
/** * Check is the table is partial */ public boolean isTablePart(String uri) { IGridTable grid = this.getGridTable(uri); if (grid != null && grid.getGrid() instanceof CompositeGrid) { return true; } return false; }
private IGridFilter makeFilter(IGridTable table, List<ICell> selectedCells) { List<IGridRegion> regions = new ArrayList<IGridRegion>(); for (ICell cell : selectedCells) { IGridRegion region = table.getSubtable(cell.getColumn(), cell.getRow(), 1, 1).getRegion(); regions.add(region); } if (regions.isEmpty()) { return null; } IGridRegion[] aRegions = regions.toArray(new IGridRegion[regions.size()]); return new ColorGridFilter(new RegionGridSelector(aRegions, true), WebStudioUtils.getWebStudio().getModel().getFilterHolder().makeFilter()); }
private void initUri() { uri = table.getUri(column, row); }
public static TableModel initializeTableModel(IGridTable table, IGridFilter[] filters, int numRows, LinkBuilder linkBuilder, String mode, String view, MetaInfoReader metaInfoReader) { if (table == null) { return null; } boolean editing = Constants.MODE_EDIT.equals(mode); if (editing) { // Prepare workbook for edit (load it to memory before editing starts) table.edit(); } IGrid grid; if (CollectionUtils.isNotEmpty(filters)) { grid = new FilteredGrid(table.getGrid(), filters, metaInfoReader); } else { grid = table.getGrid(); } IGridRegion region = table.getRegion(); if (numRows > -1 && region.getTop() + numRows < region.getBottom()) { region = new GridRegion(region); ((GridRegion) region).setBottom(region.getTop() + numRows - 1); } return new TableViewer(grid, region, linkBuilder, mode, view, metaInfoReader).buildModel(table, numRows); }
public String[] getParamPresentation() { int length = paramsTable.getHeight(); String[] result = new String[length]; int fromHeight = 0; for (int i = 0; i < result.length; i++) { int gridHeight = paramsTable.getRow(i).getSource().getHeight(); IGridTable singleParamGridTable = presentationTable.getSource().getRows(fromHeight, fromHeight + gridHeight - 1); result[i] = singleParamGridTable.getCell(0, 0).getStringValue(); fromHeight += gridHeight; } return result; }
/** * @return New table id on the sheet where it was saved. It is needed for tables that were moved * to new place during adding new rows and columns on editing. We need to know new destination of the table. * @throws IOException */ public synchronized String save() throws IOException { XlsSheetGridModel xlsgrid = (XlsSheetGridModel) gridTable.getGrid(); xlsgrid.getSheetSource().getWorkbookSource().save(); actions = new UndoableActions(); String uri = getOriginalGridTable().getUri(); return TableUtils.makeTableId(uri); }
public String removeTable() throws Throwable { try { final WebStudio studio = WebStudioUtils.getWebStudio(); IGridTable gridTable = table.getGridTable(IXlsTableNames.VIEW_DEVELOPER); gridTable.edit(); new TableServiceImpl().removeTable(gridTable); XlsSheetGridModel sheetModel = (XlsSheetGridModel) gridTable.getGrid(); sheetModel.getSheetSource().getWorkbookSource().save(); gridTable.stopEditing(); FacesUtils.removeSessionParam(org.openl.rules.tableeditor.util.Constants.TABLE_EDITOR_MODEL_NAME); studio.compile(); RecentlyVisitedTables visitedTables = studio.getModel().getRecentlyVisitedTables(); visitedTables.remove(table); } catch (Exception e) { throw e.getCause(); } return null; }