-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix!: use the same cell reference constructor in order to ensure consistency #4634
Draft
ugur-vaadin
wants to merge
18
commits into
main
Choose a base branch
from
4588-spreadsheet-does-not-trigger-addcellvaluechangelistener-for-anything-else-than-text-input
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
245d39b
fix: use the same cell reference constructor in order to ensure consi…
ugur-vaadin 2af83b6
Merge branch 'master' into 4588-spreadsheet-does-not-trigger-addcellv…
ugur-vaadin fe708df
fix: use getSheet from SpreadsheetCommand to get the sheet
ugur-vaadin 6227ec5
fix: apply formatter
ugur-vaadin 268ff65
fix: add cell reference without sheet name to cell value change event
ugur-vaadin 066e1d2
Merge branch 'main' into 4588-spreadsheet-does-not-trigger-addcellval…
ugur-vaadin 7105375
fix: add missing cell reference without sheet name to event
ugur-vaadin 893994a
Merge branch 'main' into 4588-spreadsheet-does-not-trigger-addcellval…
ugur-vaadin 31fa8ac
fix: update cell value change unit test
ugur-vaadin 8f08024
Merge branch '4588-spreadsheet-does-not-trigger-addcellvaluechangelis…
ugur-vaadin 9158159
Merge branch 'main' into 4588-spreadsheet-does-not-trigger-addcellval…
ugur-vaadin 5476fdd
fix: add sheet name to more internal cell references
ugur-vaadin 09928c6
Merge branch 'main' into 4588-spreadsheet-does-not-trigger-addcellval…
ugur-vaadin 530e9e7
fix: introduce cellset to avoid selected cell duplication in event
ugur-vaadin 27ce9d9
Merge branch 'main' into 4588-spreadsheet-does-not-trigger-addcellval…
ugur-vaadin f58821b
refactor: add contains checks for indexes and add javadocs
ugur-vaadin 60dd913
Merge branch 'main' into 4588-spreadsheet-does-not-trigger-addcellval…
ugur-vaadin e20b0fe
refactor: rename api to minimize the need for refactoring
ugur-vaadin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
.../vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/CellSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* Copyright 2023 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.flow.component.spreadsheet; | ||
|
||
import org.apache.poi.ss.util.CellReference; | ||
|
||
import java.util.Collections; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
|
||
/** | ||
* CellSet is a set of cells that also provides utilities regarding the contents | ||
* of the set. | ||
*/ | ||
public class CellSet { | ||
|
||
private final Set<CellReference> cells; | ||
|
||
/** | ||
* Creates a set with the specified cells | ||
* | ||
* @param cells | ||
* cells to construct the set with, not {@code null} | ||
*/ | ||
public CellSet(Set<CellReference> cells) { | ||
Objects.requireNonNull(cells, "Cells cannot be null"); | ||
this.cells = cells; | ||
} | ||
|
||
/** | ||
* Gets an unmodifiable set of the cells | ||
* | ||
* @return an unmodifiable set of the cells | ||
*/ | ||
public Set<CellReference> getCells() { | ||
return Collections.unmodifiableSet(cells); | ||
} | ||
|
||
/** | ||
* Gets the number of the cells | ||
* | ||
* @return number of cells | ||
*/ | ||
public int size() { | ||
return cells.size(); | ||
} | ||
|
||
/** | ||
* Whether the set contains the specified cell. Does not take the sheet | ||
* names of the cells in set into account if the sheet name of the cell | ||
* reference is {@code null}. | ||
* | ||
* @param cellReference | ||
* cell to be checked whether it exists in the set | ||
* @return {@code true} if set contains the specified cell, {@code false} | ||
* otherwise | ||
*/ | ||
public boolean contains(CellReference cellReference) { | ||
if (cells.isEmpty()) { | ||
return false; | ||
} | ||
if (cellReference.getSheetName() == null) { | ||
CellReference cellWithSheetName = new CellReference( | ||
cells.iterator().next().getSheetName(), | ||
cellReference.getRow(), cellReference.getCol(), | ||
cellReference.isRowAbsolute(), | ||
cellReference.isColAbsolute()); | ||
return cells.contains(cellWithSheetName); | ||
} | ||
return cells.contains(cellReference); | ||
} | ||
|
||
/** | ||
* Whether the set contains the specified cell. Does not take the sheet | ||
* names of the cells in set into account. | ||
* | ||
* @param row | ||
* row index of the cell, 0-based | ||
* @param col | ||
* col index of the cell, 0-based | ||
* @return {@code true} if set contains the specified cell, {@code false} | ||
* otherwise | ||
*/ | ||
public boolean contains(int row, int col) { | ||
return contains(new CellReference(row, col)); | ||
} | ||
|
||
/** | ||
* Whether the set contains the specified cell | ||
* | ||
* @param row | ||
* row index of the cell, 0-based | ||
* @param col | ||
* col index of the cell, 0-based | ||
* @param sheetName | ||
* sheet name of the cell, not {@code null} | ||
* @return {@code true} if set contains the specified cell, {@code false} | ||
* otherwise | ||
*/ | ||
public boolean contains(int row, int col, String sheetName) { | ||
Objects.requireNonNull(sheetName, "The sheet name cannot be null"); | ||
return contains(new CellReference(sheetName, row, col, false, false)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NULL_DEREFERENCE: object
selectedCellReference
last assigned on line 398 could be null and is dereferenced by call toisCellInRange(...)
at line 401.ℹ️ Learn about @sonatype-lift commands
You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.
@sonatype-lift ignore
@sonatype-lift ignoreall
@sonatype-lift exclude <file|issue|path|tool>
file|issue|path|tool
from Lift findings by updating your config.toml fileNote: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.
Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]