public static boolean intersects(XlsUrlParser p1, XlsUrlParser p2) { if (!p1.getWbPath().equals(p2.getWbPath()) || !p1.getWbName().equals(p2.getWbName()) || !p1.getWsName() .equals(p2.getWsName())) { return false; } if (p1.getRange() == null || p2.getRange() == null) { return false; } return IGridRegion.Tool.intersects(IGridRegion.Tool.makeRegion(p1.getRange()), IGridRegion.Tool.makeRegion(p2.getRange())); } }
shiftActions.addAll(clearCells(region.getLeft(), IGridRegion.Tool.width(region), region.getBottom() + 1, nRows, grid, metaInfoWriter)); } else { if (!grid.isPartOfTheMergedRegion(column, row) || (grid.isTopLeftCellInMergedRegion(column, row) && IGridRegion.Tool .height(grid.getRegionStartingAt(column, row)) <= nRows)) {
private static IUndoableGridTableAction createPropertiesSection(IGridRegion tableRegion, IGrid grid, MetaInfoWriter metaInfoWriter) { int regionWidth = IGridRegion.Tool.width(tableRegion); int leftCell = tableRegion.getLeft(); int topCell = tableRegion.getTop();
IGridRegion existingMergedRegion = grid.getMergedRegion(i); if (IGridRegion.Tool.contains(regionOfTable, existingMergedRegion.getLeft(), existingMergedRegion .getTop())) { if (isRegionMustBeResized(existingMergedRegion, firstRowOrColumn, numberOfRowsOrColumns, isColumns,
IGridRegion.Tool.height(region), grid, metaInfoWriter)); } else { for (int column = startColumn - nCols; column < startColumn; column++) { if (!grid.isPartOfTheMergedRegion(column, row) || (grid.isTopLeftCellInMergedRegion(column, row) && IGridRegion.Tool .width(grid.getRegionStartingAt(column, row)) <= nCols)) {
void setVerticalBorder(int column, TableModel tm) { int height = IGridRegion.Tool.height(reg); int left = reg.getLeft(); int top = reg.getTop();
void setHorizontalBorder(int row, TableModel tm) { int width = IGridRegion.Tool.width(reg); int left = reg.getLeft(); int top = reg.getTop();
int col = cell.getAbsoluteColumn(); if (!IGridRegion.Tool.contains(region, col, row)) { continue;
void setHorizontalBorder(int row, TableModel tm) { int width = IGridRegion.Tool.width(reg); int left = reg.getLeft(); int top = reg.getTop();
void setVerticalBorder(int column, TableModel tm) { int height = IGridRegion.Tool.height(reg); int left = reg.getLeft(); int top = reg.getTop();
int leftCell = tableRegion.getLeft(); int topCell = tableRegion.getTop(); int firstPropertyRow = IGridRegion.Tool.height(grid.getCell(leftCell, topCell).getAbsoluteRegion()); int rowsToMove = IGridRegion.Tool.height(tableRegion) - firstPropertyRow; ArrayList<IUndoableGridTableAction> actions = new ArrayList<>(IGridRegion.Tool .width(tableRegion) * rowsToMove);
private void saveSimpleRulesMetaInfo(DecisionTable decisionTable, IGridRegion region) { for (Map.Entry<CellKey, Pair<String, IOpenClass>> entry : simpleRulesConditionMap.entrySet()) { String conditionStatement = entry.getValue().getLeft(); IOpenClass conditionType = entry.getValue().getRight(); CellKey key = entry.getKey(); int row = key.getRow(); int col = key.getColumn(); if (!IGridRegion.Tool.contains(region, col, row)) { continue; } // SimpleRules or SimpleLookup IGrid grid = getTableSyntaxNode().getGridTable().getGrid(); String cellValue = grid.getCell(col, row).getStringValue(); if (StringUtils.isBlank(cellValue)) { continue; } String text = String.format("Condition for %s: %s", conditionStatement, conditionType.getDisplayName(0)); SimpleNodeUsage simpleNodeUsage = new SimpleNodeUsage(0, cellValue.length() - 1, text, null, NodeType.OTHER); setPreparedMetaInfo(row, col, new CellMetaInfo(JavaOpenClass.STRING, false, Collections.singletonList(simpleNodeUsage))); } }
private TableStyles readTableStyles(int row, int column) { if (workbookPath == null) { // No need to show styles in read only mode (when access workbook through stream) return null; } TableStyles styles = null; for (IGridTable table : tables) { IGridRegion region = table.getRegion(); // Sometimes we need extra column and row to show the border of a table. // We need to know the styles of the cells lefter, above, righter and below the table. int left = region.getLeft() == 0 ? 0 : region.getLeft() - 1; int top = region.getTop() == 0 ? 0 : region.getTop() - 1; IGridRegion extendedRegion = new GridRegion(top, left, region.getBottom() + 1, region.getRight() + 1); if (IGridRegion.Tool.contains(extendedRegion, column, row)) { try (ExcelReader excelReader = ExcelReaderFactory.sequentialFactory().create(workbookPath)) { styles = excelReader.getTableStyles(sheetDescriptor, extendedRegion); } catch (Exception e) { // Fallback to empty style log.error("Can't read styles for sheet '{}'", sheetDescriptor.getName(), e); styles = new EmptyTableStyles(extendedRegion); } break; } } return styles; }
private void saveDescriptionMetaInfo(FunctionalRow funcRow, IGridRegion region) { // Condition/Action code (expression) ICell codeCell = funcRow.getCodeTable().getCell(0, 0); int row = codeCell.getAbsoluteRow(); int col = codeCell.getAbsoluteColumn(); if (IGridRegion.Tool.contains(region, col, row)) { List<CellMetaInfo> metaInfoList = OpenLCellExpressionsCompiler.getMetaInfo( funcRow.getSourceCodeModule(), funcRow.getMethod() ); // Decision table always contains 1 meta info setPreparedMetaInfo(row, col, metaInfoList.get(0)); } // Condition/Action type definition ILogicalTable paramsTable = funcRow.getParamsTable(); // In the case of errors params will be null IParameterDeclaration[] params = funcRow.getParams(); if (params != null && params.length > 0 && params[0] != null) { IParameterDeclaration param = params[0]; ICell paramCell = paramsTable.getCell(0, 0); row = paramCell.getAbsoluteRow(); col = paramCell.getAbsoluteColumn(); if (IGridRegion.Tool.contains(region, col, row)) { setPreparedMetaInfo(row, col, getMetaInfo(paramsTable, param.getType())); } } }
/** * Transformes current grid coordinates to appropriate table coordinates. * * @param col grid column index * @param row grid row index * @return {@link Transform} that contains coordinates to cell in the * appropriate grid. */ private Transform transform(int col, int row) { for (int i = 0; i < mappedRegions.length; i++) { // find the region to which this coordinates belong to if (IGridRegion.Tool.contains(mappedRegions[i], col, row)) { // according to the found region, get the appropriate table // region. IGridRegion reg = gridTables[i].getRegion(); // transform grid coordinates to table grid one. int transformedCol = reg.getLeft() + col - mappedRegions[i].getLeft(); int transformedRow = reg.getTop() + row - mappedRegions[i].getTop(); // return the transformer, with coordinates to source cell. return new Transform(gridTables[i].getGrid(), transformedCol, transformedRow); } } return null; }
private void saveCompoundReturnColumn(IGridRegion region) { for (Map.Entry<CellKey, String> entry : simpleRulesReturnDescriptions.entrySet()) { CellKey key = entry.getKey(); int row = key.getRow(); int col = key.getColumn(); if (!IGridRegion.Tool.contains(region, col, row)) { continue; } ICell cell = getTableSyntaxNode().getGridTable().getGrid().getCell(col, row); String stringValue = cell.getStringValue(); if (StringUtils.isBlank(stringValue)) { continue; } SimpleNodeUsage simpleNodeUsage = new SimpleNodeUsage(0, stringValue.length() - 1, entry.getValue(), null, NodeType.OTHER); CellMetaInfo metaInfo = new CellMetaInfo(JavaOpenClass.STRING, false, Collections.singletonList(simpleNodeUsage)); setPreparedMetaInfo(row, col, metaInfo); } }