@Override public Object getObjectValue() { return delegate.getObjectValue(); }
public Object getObjectValue() { return cell.getObjectValue(); }
public Object getObjectValue() { return delegate.getObjectValue(); }
private boolean notEquals(ICell c1, ICell c2) { Object o1 = c1.getObjectValue(); Object o2 = c2.getObjectValue(); // TODO compare value, comment, value and so on... if (o1 == null) { return (o2 != null); } else { return !o1.equals(o2); } } }
private boolean notEquals(ICell c1, ICell c2) { Object o1 = c1.getObjectValue(); Object o2 = c2.getObjectValue(); // TODO compare value, comment, value and so on... if (o1 == null) { return (o2 != null); } else { return !o1.equals(o2); } } }
private String getCellEditorInitValue(String editorType, ICell cell) { String value = null; if (editorType.equals(ICellEditor.CE_NUMERIC)) { value = cell.getStringValue(); } else if (editorType.equals(ICellEditor.CE_FORMULA)) { value = "=" + cell.getFormula(); } else if (editorType.equals(ICellEditor.CE_TEXT) || editorType.equals(ICellEditor.CE_MULTILINE)) { value = cell.getStringValue(); } else if (editorType.equals(ICellEditor.CE_DATE)) { // Format must be same as in DateEditor.js value = FormattersManager.format(cell.getObjectValue()); } return value; }
private String getCellEditorInitValue(String editorType, ICell cell) { String value = null; if (editorType.equals(ICellEditor.CE_NUMERIC)) { value = cell.getStringValue(); } else if (editorType.equals(ICellEditor.CE_FORMULA)) { value = "=" + cell.getFormula(); } else if (CellMetaInfo.isCellContainsNodeUsages(cell)) { value = cell.getStringValue(); } else if (editorType.equals(ICellEditor.CE_DATE)) { // Format must be same as in DateEditor.js value = FormattersManager.format(cell.getObjectValue()); } return value; }
private Object extractValueFromRegion() { // If the top left cell is the current cell instance, we just extract it`s value. // In other case get string value of top left cell of the region. if (isCurrentCellATopLeftCellInRegion()) { return extractCellValue(); } else { ICell topLeftCell = getTopLeftCellFromRegion(); return topLeftCell.getObjectValue(); } }
@Override public List<Object> getUniqueValues(int colIdx) throws SyntaxNodeException { List<Object> values = new ArrayList<>(); int rows = logicalTable.getHeight(); for (int i = 1; i < rows; i++) { IGridTable gridTable = logicalTable.getSubtable(colIdx, i, 1, 1).getSource(); Object value = gridTable.getCell(0, 0).getObjectValue(); if (value == null) { throw SyntaxNodeExceptionUtils.createError("Empty key in an unique index", new GridCellSourceCodeModule(gridTable)); } if (values.contains(value)) { throw SyntaxNodeExceptionUtils.createError("Duplicated key in an unique index: " + value, new GridCellSourceCodeModule(gridTable)); } values.add(value); } return values; }
private Object findFirstValueInRegion(IGridRegion reg) { for (int row = reg.getTop(); row <= reg.getBottom(); row++) { for (int column = reg.getLeft(); column <= reg.getRight(); column++) { Object cellValue = getCell(column, row).getObjectValue(); if (cellValue != null) { return cellValue; } } } return null; }
public FormattedCell(ICell delegate, CellMetaInfo cellMetaInfo) { this.delegate = delegate; try { this.objectValue = this.delegate.getObjectValue(); } catch (IncorrectFormulaException e) { //logged in XlsCell.getObjectValue() method. this.objectValue = ERROR_VALUE; } this.formattedValue = XlsDataFormatterFactory.getFormattedValue(delegate, cellMetaInfo); this.font = new CellFont(delegate.getFont()); this.style = new CellStyle(delegate.getStyle()); this.metaInfo = cellMetaInfo; }
public static XlsProjection buildCell(ICell cell, String cellName) { Object cellValue = cell.getObjectValue(); /*int cellHeight = cell.getCellHeight(); int cellWidth = cell.getCellWidth(); ICellStyle cellStyle = cell.getCellStyle(); ICellFont cellFont = cell.getCellInfo().getFont();*/ XlsProjection projection = new XlsProjection(cellName, CELL); projection.addProperty(new AbstractProperty(CELL_VALUE.name(), cellValue)); /*projection.addProperty(new AbstractProperty(CELL_HEIGHT.name(), int.class, cellHeight)); projection.addProperty(new AbstractProperty(CELL_WIDTH.name(), int.class, cellWidth)); projection.addChild(buildCellStyle(cellStyle)); projection.addChild(buildCellFont(cellFont));*/ projection.setData(cell); // AbstractProperty cellProp = new AbstractProperty("cell", ICell.class, cell); // projection.addProperty(cellProp); return projection; }
public static XlsProjection buildCell(ICell cell, String cellName) { Object cellValue = cell.getObjectValue(); /*int cellHeight = cell.getCellHeight(); int cellWidth = cell.getCellWidth(); ICellStyle cellStyle = cell.getCellStyle(); ICellFont cellFont = cell.getCellInfo().getFont();*/ XlsProjection projection = new XlsProjection(cellName, CELL); projection.addProperty(new AbstractProperty(CELL_VALUE.name(), cellValue)); /*projection.addProperty(new AbstractProperty(CELL_HEIGHT.name(), int.class, cellHeight)); projection.addProperty(new AbstractProperty(CELL_WIDTH.name(), int.class, cellWidth)); projection.addChild(buildCellStyle(cellStyle)); projection.addChild(buildCellFont(cellFont));*/ projection.setData(cell); // AbstractProperty cellProp = new AbstractProperty("cell", ICell.class, cell); // projection.addProperty(cellProp); return projection; }
@Override public boolean select(TableSyntaxNode node) { if (StringUtils.isBlank(value)) { return true; } IGridTable table = node.getGridTable(); for (int row = 0; row < table.getHeight(); row++) { for (int col = 0; col < table.getWidth(); col++) { ICell cell = table.getCell(col, row); Object cellValue = cell.getObjectValue(); if (selectValue(cellValue)) { return true; } } } return false; }
private static IUndoableGridTableAction setExistingPropertyValue(IGridRegion tableRegion, IGrid grid, Object newPropValue, int propertyRowIndex, MetaInfoWriter metaInfoWriter) { int leftCell = tableRegion.getLeft(); int topCell = tableRegion.getTop(); int propNameCellOffset = grid.getCell(leftCell, topCell + 1).getWidth(); int propValueCellOffset = propNameCellOffset + grid.getCell(leftCell + propNameCellOffset, topCell + 1).getWidth(); Object propValueFromTable = grid.getCell(leftCell + propValueCellOffset, propertyRowIndex) .getObjectValue(); if (propValueFromTable != null && propValueFromTable.equals(newPropValue)) { // Property with such name and value already exists return null; } return new UndoableSetValueAction(leftCell + propValueCellOffset, propertyRowIndex, newPropValue, metaInfoWriter); }
@Override public boolean select(TableSyntaxNode node) { if (StringUtils.isBlank(value)) { return true; } IGridTable table = node.getGridTable(); for (int row = 0; row < table.getHeight(); row++) { for (int col = 0; col < table.getWidth(); col++) { ICell cell = table.getCell(col, row); Object cellValue = cell.getObjectValue(); if (selectValue(cellValue)) { return true; } } } return false; }
protected void savePrevCell(IWritableGrid grid) { ICell cell = grid.getCell(col, row); setPrevValue(cell.getObjectValue()); setPrevFormula(cell.getFormula()); setPrevStyle(cell.getStyle()); setPrevComment(cell.getComment()); setPrevMetaInfo(metaInfoWriter.getMetaInfo(row, col)); }
public void doAction(IGridTable table) { IWritableGrid grid = (IWritableGrid) table.getGrid(); ICell cell = grid.getCell(getCol(), getRow()); setPrevValue(cell.getObjectValue()); setPrevFormula(cell.getFormula()); setPrevMetaInfo(metaInfoWriter.getMetaInfo(getRow(), getCol())); grid.setCellValue(getCol(), getRow(), newValue); CellMetaInfo newMetaInfo = getNewMetaInfo(newValue); if (newMetaInfo != null) { metaInfoWriter.setMetaInfo(getRow(), getCol(), newMetaInfo); } }
public void undoAction(IGridTable table) { IWritableGrid grid = (IWritableGrid) table.getGrid(); ICell cell = grid.getCell(getCol(), getRow()); setPrevValue(cell.getObjectValue()); setPrevFormula(cell.getFormula()); setPrevStyle(cell.getStyle()); setPrevComment(cell.getComment()); if (toRemove != null) { grid.removeMergedRegion(toRemove); grid.addMergedRegion(toRestore); } grid.setCellFormula(colFrom, rowFrom, getPrevFormula()); grid.setCellValue(colFrom, rowFrom, getPrevValue()); grid.setCellStyle(colFrom, rowFrom, getPrevStyle()); grid.setCellComment(colFrom, rowFrom, getPrevComment()); metaInfoWriter.setMetaInfo(rowFrom, colFrom, getPrevMetaInfo()); }
public void doAction(IGridTable table) { IWritableGrid grid = (IWritableGrid) table.getGrid(); IGridRegion rrFrom = grid.getRegionStartingAt(colFrom, rowFrom); ICell cell = grid.getCell(colFrom, rowFrom); setPrevValue(cell.getObjectValue()); setPrevFormula(cell.getFormula()); setPrevStyle(cell.getStyle()); setPrevComment(cell.getComment()); setPrevMetaInfo(metaInfoWriter.getMetaInfo(rowFrom, colFrom)); if (rrFrom != null) { toRestore = rrFrom; grid.removeMergedRegion(rrFrom); GridRegion copyFrom = new GridRegion(rrFrom.getTop() + getRow() - rowFrom, rrFrom.getLeft() + getCol() - colFrom, rrFrom.getBottom() + getRow() - rowFrom, rrFrom.getRight() + getCol() - colFrom); grid.addMergedRegion(copyFrom); toRemove = copyFrom; } grid.setCellFormula(getCol(), getRow(), getPrevFormula()); grid.setCellValue(getCol(), getRow(), getPrevValue()); grid.setCellStyle(getCol(), getRow(), getPrevStyle()); grid.setCellComment(getCol(), getRow(), getPrevComment()); metaInfoWriter.setMetaInfo(getRow(), getCol(), getPrevMetaInfo()); ICell newCell = grid.getCell(getCol(), getRow()); if (cell.getType() == IGrid.CELL_TYPE_STRING && newCell.getType() == IGrid.CELL_TYPE_FORMULA) { grid.setCellStringValue(getCol(), getRow(), cell.getObjectValue().toString()); } }