diff --git a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow-integration-tests/src/main/java/com/vaadin/flow/component/spreadsheet/tests/fixtures/PopupButtonFixture.java b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow-integration-tests/src/main/java/com/vaadin/flow/component/spreadsheet/tests/fixtures/PopupButtonFixture.java index a78afcbecec..a3985d65a56 100644 --- a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow-integration-tests/src/main/java/com/vaadin/flow/component/spreadsheet/tests/fixtures/PopupButtonFixture.java +++ b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow-integration-tests/src/main/java/com/vaadin/flow/component/spreadsheet/tests/fixtures/PopupButtonFixture.java @@ -26,8 +26,9 @@ public void loadFixture(final Spreadsheet spreadsheet) { } List values = new ArrayList<>(VALUES); CellReference ref = event.getSelectedCellReference(); - CellReference newRef = new CellReference(ref.getRow(), - ref.getCol()); + CellReference newRef = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), ref.getRow(), + ref.getCol(), false, false); DataValidationButton popupButton = new DataValidationButton( spreadsheet, values); popupButton.setUp(); diff --git a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellSelectionManager.java b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellSelectionManager.java index 1a62df278d2..269e2c9ce3a 100644 --- a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellSelectionManager.java +++ b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellSelectionManager.java @@ -116,7 +116,9 @@ public SelectionChangeEvent getLatestSelectionEvent() { } boolean isCellInsideSelection(int row, int column) { - CellReference cellReference = new CellReference(row - 1, column - 1); + CellReference cellReference = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), row - 1, + column - 1, false, false); boolean inside = cellReference.equals(selectedCellReference) || individualSelectedCells.contains(cellReference); if (!inside) { @@ -173,7 +175,9 @@ protected void reloadCurrentSelection() { */ protected void onCellSelected(int row, int column, boolean discardOldRangeSelection) { - CellReference cellReference = new CellReference(row - 1, column - 1); + CellReference cellReference = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), row - 1, + column - 1, false, false); CellReference previousCellReference = selectedCellReference; if (!cellReference.equals(previousCellReference) || discardOldRangeSelection && (!cellRangeAddresses.isEmpty() @@ -217,8 +221,9 @@ protected void onSheetAddressChanged(String value, region.col1 - 1, region.col2 - 1); } handleCellRangeSelection(cra); - selectedCellReference = new CellReference(cra.getFirstRow(), - cra.getFirstColumn()); + selectedCellReference = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), + cra.getFirstRow(), cra.getFirstColumn(), false, false); paintedCellRange = cra; cellRangeAddresses.clear(); cellRangeAddresses.add(cra); @@ -234,8 +239,10 @@ protected void onSheetAddressChanged(String value, .createCorrectCellRangeAddress(region.row1, region.col1, region.row2, region.col2); handleCellRangeSelection(cra); - selectedCellReference = new CellReference(cra.getFirstRow(), - cra.getFirstColumn()); + selectedCellReference = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), + cra.getFirstRow(), cra.getFirstColumn(), false, + false); paintedCellRange = cra; cellRangeAddresses.clear(); cellRangeAddresses.add(cra); @@ -382,8 +389,9 @@ protected void handleCellRangeSelection(CellRangeAddress cra) { protected void handleCellRangeSelection(String name, CellRangeAddress cra) { - final CellReference firstCell = new CellReference(cra.getFirstRow(), - cra.getFirstColumn()); + final CellReference firstCell = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), cra.getFirstRow(), + cra.getFirstColumn(), false, false); handleCellRangeSelection(name, firstCell, cra, true); } @@ -463,8 +471,9 @@ protected void onCellRangePainted(int selectedCellRow, cellRangeAddresses.clear(); individualSelectedCells.clear(); - selectedCellReference = new CellReference(selectedCellRow - 1, - selectedCellColumn - 1); + selectedCellReference = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), + selectedCellRow - 1, selectedCellColumn - 1, false, false); CellRangeAddress cra = spreadsheet.createCorrectCellRangeAddress(row1, col1, row2, col2); @@ -507,7 +516,9 @@ protected void onCellAddToSelectionAndSelected(int row, int column) { individualSelectedCells.add(selectedCellReference); } handleCellSelection(row, column); - selectedCellReference = new CellReference(row - 1, column - 1); + selectedCellReference = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), row - 1, + column - 1, false, false); spreadsheet.loadCustomEditorOnSelectedCell(); if (individualSelectedCells.contains(selectedCellReference)) { individualSelectedCells.remove( @@ -558,8 +569,9 @@ protected void onCellsAddedToRangeSelection(int row1, int col1, int row2, */ protected void onRowSelected(int row, int firstColumnIndex) { handleCellSelection(row, firstColumnIndex); - selectedCellReference = new CellReference(row - 1, - firstColumnIndex - 1); + selectedCellReference = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), row - 1, + firstColumnIndex - 1, false, false); spreadsheet.loadCustomEditorOnSelectedCell(); cellRangeAddresses.clear(); individualSelectedCells.clear(); @@ -592,8 +604,9 @@ protected void onRowAddedToRangeSelection(int row, int firstColumnIndex) { individualSelectedCells.add(selectedCellReference); } handleCellSelection(row, firstColumnIndex); - selectedCellReference = new CellReference(row - 1, - firstColumnIndex - 1); + selectedCellReference = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), row - 1, + firstColumnIndex - 1, false, false); spreadsheet.loadCustomEditorOnSelectedCell(); cellRangeAddresses.add(spreadsheet.createCorrectCellRangeAddress(row, 1, row, spreadsheet.getColumns())); @@ -612,8 +625,9 @@ protected void onRowAddedToRangeSelection(int row, int firstColumnIndex) { */ protected void onColumnSelected(int firstRowIndex, int column) { handleCellSelection(firstRowIndex, column); - selectedCellReference = new CellReference(firstRowIndex - 1, - column - 1); + selectedCellReference = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), firstRowIndex - 1, + column - 1, false, false); spreadsheet.loadCustomEditorOnSelectedCell(); cellRangeAddresses.clear(); individualSelectedCells.clear(); @@ -646,8 +660,9 @@ protected void onColumnAddedToSelection(int firstRowIndex, int column) { individualSelectedCells.add(selectedCellReference); } handleCellSelection(firstRowIndex, column); - selectedCellReference = new CellReference(firstRowIndex - 1, - column - 1); + selectedCellReference = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), firstRowIndex - 1, + column - 1, false, false); spreadsheet.loadCustomEditorOnSelectedCell(); cellRangeAddresses.add(spreadsheet.createCorrectCellRangeAddress(1, column, spreadsheet.getRows(), column)); @@ -676,8 +691,10 @@ protected void mergedRegionAdded(CellRangeAddress region) { handleCellAddressChange(region.getFirstRow() + 1, region.getFirstColumn() + 1, false); } - selectedCellReference = new CellReference(region.getFirstRow(), - region.getFirstColumn()); + selectedCellReference = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), + region.getFirstRow(), region.getFirstColumn(), false, + false); fire = true; } for (Iterator i = cellRangeAddresses.iterator(); i diff --git a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellSelectionShifter.java b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellSelectionShifter.java index 1da9d750c24..e191c38dfaf 100644 --- a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellSelectionShifter.java +++ b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellSelectionShifter.java @@ -141,7 +141,9 @@ private void fireCellValueChangeEvent(CellRangeAddress region) { for (int x = region.getFirstColumn(); x <= region .getLastColumn(); x++) { for (int y = region.getFirstRow(); y <= region.getLastRow(); y++) { - cells.add(new CellReference(y, x)); + cells.add(new CellReference( + spreadsheet.getActiveSheet().getSheetName(), y, x, + false, false)); } } spreadsheet.fireEvent(new CellValueChangeEvent(spreadsheet, cells)); @@ -399,8 +401,10 @@ public void onSelectionDecreasePainted(int r, int c) { if (!SpreadsheetUtil.isCellInRange(selectedCellReference, newPaintedCellRange)) { selectedCellReference = new CellReference( + spreadsheet.getActiveSheet().getSheetName(), newPaintedCellRange.getFirstRow(), - newPaintedCellRange.getFirstColumn()); + newPaintedCellRange.getFirstColumn(), false, + false); } getCellSelectionManager().handleCellRangeSelection( selectedCellReference, newPaintedCellRange, false); diff --git a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellValueManager.java b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellValueManager.java index a0824104c57..6f4b98eaf36 100644 --- a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellValueManager.java +++ b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellValueManager.java @@ -602,7 +602,9 @@ public void onCellValueChange(int col, int row, String value) { // capture cell value to history CellValueCommand command = new CellValueCommand(spreadsheet); - command.captureCellValues(new CellReference(row - 1, col - 1)); + command.captureCellValues( + new CellReference(spreadsheet.getActiveSheet().getSheetName(), + row - 1, col - 1, false, false)); spreadsheet.getSpreadsheetHistoryManager().addCommand(command); boolean updateHyperlinks = false; boolean formulaChanged = false; diff --git a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/Spreadsheet.java b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/Spreadsheet.java index 09782c87760..8065b5473c3 100644 --- a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/Spreadsheet.java +++ b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/Spreadsheet.java @@ -643,7 +643,8 @@ void setNamedRanges(List namedRanges) { void onPopupButtonClick(int row, int column) { PopupButton popup = sheetPopupButtons .get(SpreadsheetUtil.relativeToAbsolute(this, - new CellReference(row - 1, column - 1))); + new CellReference(getActiveSheet().getSheetName(), + row - 1, column - 1, false, false))); if (popup != null) { popup.openPopup(); } @@ -652,7 +653,8 @@ void onPopupButtonClick(int row, int column) { void onPopupClose(int row, int column) { PopupButton popup = sheetPopupButtons .get(SpreadsheetUtil.relativeToAbsolute(this, - new CellReference(row - 1, column - 1))); + new CellReference(getActiveSheet().getSheetName(), + row - 1, column - 1, false, false))); if (popup != null) { popup.closePopup(); @@ -2922,7 +2924,8 @@ private void rowsMoved(int first, int last, int n) { } else if (numberOfRowsAboveWasChanged(row, last, first)) { int newRow = cell.getRow() + n; int col = cell.getCol(); - CellReference newCell = new CellReference(newRow, col, true, + CellReference newCell = new CellReference( + getActiveSheet().getSheetName(), newRow, col, true, true); pbutton.setCellReference(newCell); updated.put(newCell, pbutton); @@ -4760,7 +4763,8 @@ public void setPopup(String cellAddress, PopupButton popupButton) { * removes the pop-up button for the target cell. */ public void setPopup(int row, int col, PopupButton popupButton) { - setPopup(new CellReference(row, col), popupButton); + setPopup(new CellReference(getActiveSheet().getSheetName(), row, col, + false, false), popupButton); } /** @@ -5184,7 +5188,9 @@ private static Set getAllSelectedCells( for (int x = a.getFirstColumn(); x <= a.getLastColumn(); x++) { for (int y = a.getFirstRow(); y <= a.getLastRow(); y++) { - cells.add(new CellReference(y, x)); + cells.add(new CellReference( + selectedCellReference.getSheetName(), y, x, + false, false)); } } } diff --git a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/SpreadsheetHandlerImpl.java b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/SpreadsheetHandlerImpl.java index 91e77ba7ca5..3062ccf7eef 100644 --- a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/SpreadsheetHandlerImpl.java +++ b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/SpreadsheetHandlerImpl.java @@ -334,7 +334,9 @@ private void fireCellValueChangeEvent(CellRangeAddress region) { for (int x = region.getFirstColumn(); x <= region .getLastColumn(); x++) { for (int y = region.getFirstRow(); y <= region.getLastRow(); y++) { - cells.add(new CellReference(y, x)); + cells.add(new CellReference( + spreadsheet.getActiveSheet().getSheetName(), y, x, + false, false)); } } fireCellValueChangeEvent(cells); diff --git a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/command/CellShiftValuesCommand.java b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/command/CellShiftValuesCommand.java index 2fac89c4192..7296db6f849 100644 --- a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/command/CellShiftValuesCommand.java +++ b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/command/CellShiftValuesCommand.java @@ -52,8 +52,10 @@ public CellReference getSelectedCellReference() { .isCellInRange(selectedCellReference, paintedCellRange)) { return selectedCellReference; } else { - return new CellReference(paintedCellRange.getFirstRow(), - paintedCellRange.getFirstColumn()); + return new CellReference( + spreadsheet.getActiveSheet().getSheetName(), + paintedCellRange.getFirstRow(), + paintedCellRange.getFirstColumn(), false, false); } } diff --git a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/command/CellValueCommand.java b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/command/CellValueCommand.java index 95fa46e858d..949b875ecc9 100644 --- a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/command/CellValueCommand.java +++ b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/command/CellValueCommand.java @@ -148,7 +148,8 @@ public void captureCellRangeValues(CellRangeAddress... cellRanges) { @Override public CellReference getSelectedCellReference() { - return new CellReference(selectedCellRow, selectedcellCol); + return new CellReference(spreadsheet.getActiveSheet().getSheetName(), + selectedCellRow, selectedcellCol, false, false); } @Override @@ -339,13 +340,15 @@ public Set getChangedCells() { for (Object o : values) { if (o instanceof CellValue) { CellValue cellValue = (CellValue) o; - changedCells - .add(new CellReference(cellValue.row, cellValue.col)); + changedCells.add(new CellReference( + spreadsheet.getActiveSheet().getSheetName(), + cellValue.row, cellValue.col, false, false)); } else { CellRangeValue cellRangeValue = (CellRangeValue) o; for (int r = cellRangeValue.row1; r <= cellRangeValue.row2; r++) { for (int c = cellRangeValue.col1; c <= cellRangeValue.col2; c++) { - changedCells.add(new CellReference(r, c)); + changedCells.add(new CellReference( + getSheet().getSheetName(), r, c, false, false)); } } } diff --git a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/command/RowInsertOrDeleteCommand.java b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/command/RowInsertOrDeleteCommand.java index 07af0d092ac..fa85b2c1c53 100644 --- a/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/command/RowInsertOrDeleteCommand.java +++ b/vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/command/RowInsertOrDeleteCommand.java @@ -44,7 +44,8 @@ public void execute() { @Override public CellReference getSelectedCellReference() { - return new CellReference(row, 0); + return new CellReference(spreadsheet.getActiveSheet().getSheetName(), + row, 0, false, false); } @Override