Class DefaultHyperlinkCellClickHandler
java.lang.Object
com.vaadin.flow.component.spreadsheet.DefaultHyperlinkCellClickHandler
- All Implemented Interfaces:
Spreadsheet.HyperlinkCellClickHandler,Serializable
public class DefaultHyperlinkCellClickHandler
extends Object
implements Spreadsheet.HyperlinkCellClickHandler
Default implementation of the
Spreadsheet.HyperlinkCellClickHandler interface.
Handles links to cells in either the same or some other sheet, as well as
external URLs.- Since:
- 1.0
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumChoose how external links should open -
Constructor Summary
ConstructorsConstructorDescriptionDefaultHyperlinkCellClickHandler(Spreadsheet spreadsheet) DefaultHyperlinkCellClickHandler(Spreadsheet spreadsheet, DefaultHyperlinkCellClickHandler.HyperlinkOpenStyle openStyle) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetFirstArgumentFromFormula(org.apache.poi.ss.usermodel.Cell cell) we parse the formula with a formula/POI trick so we don't have to use tricky regular expressions that hit terminal runaway evaluation cases see: https://www.regular-expressions.info/catastrophic.html Instead, translategetHyperlinkFunctionTarget(org.apache.poi.ss.usermodel.Cell cell) Should only be called for cellsisHyperlinkFormulaCell(Cell)returns true.expose for subclassesprotected Spreadsheetexpose for subclassesstatic final booleanisHyperlinkFormulaCell(org.apache.poi.ss.usermodel.Cell cell) Returns true if the cell contains a hyperlink function.voidonHyperLinkCellClick(org.apache.poi.ss.usermodel.Cell cell, org.apache.poi.ss.usermodel.Hyperlink hyperlink) Called when a hyperlink cell has been clicked.protected voidopenExternalLink(String address) Uses theDefaultHyperlinkCellClickHandler.HyperlinkOpenStyleto open link addresses.void
-
Constructor Details
-
DefaultHyperlinkCellClickHandler
- Parameters:
spreadsheet-
-
DefaultHyperlinkCellClickHandler
public DefaultHyperlinkCellClickHandler(Spreadsheet spreadsheet, DefaultHyperlinkCellClickHandler.HyperlinkOpenStyle openStyle) - Parameters:
spreadsheet-openStyle- defaults toDefaultHyperlinkCellClickHandler.HyperlinkOpenStyle.NewTabif null
-
-
Method Details
-
getSpreadsheet
expose for subclasses- Returns:
- Spreadsheet for this handler
-
getOpenStyle
expose for subclasses- Returns:
- the openStyle
-
setOpenStyle
- Parameters:
openStyle- the openStyle to set (uses NewTab if null)
-
onHyperLinkCellClick
public void onHyperLinkCellClick(org.apache.poi.ss.usermodel.Cell cell, org.apache.poi.ss.usermodel.Hyperlink hyperlink) Called when a hyperlink cell has been clicked.- Specified by:
onHyperLinkCellClickin interfaceSpreadsheet.HyperlinkCellClickHandler- Parameters:
cell-hyperlink- may be null, only for Excel link relations, not formula
-
getHyperlinkFunctionTarget
Should only be called for cellsisHyperlinkFormulaCell(Cell)returns true. Returns the target for tooltip use by default.The address is inside the first argument:
HYPERLINK("address","friendly name")orHYPERLINK("#!viewName[/arguments]","friendly name")orHYPERLINK(D5,"friendly name")orHYPERLINK([arbitrary formula],"friendly name")- Specified by:
getHyperlinkFunctionTargetin interfaceSpreadsheet.HyperlinkCellClickHandler- Parameters:
cell- Target cell containing a hyperlink function- Returns:
- the address that the hyperlink function points to
-
getFirstArgumentFromFormula
we parse the formula with a formula/POI trick so we don't have to use tricky regular expressions that hit terminal runaway evaluation cases see: https://www.regular-expressions.info/catastrophic.html Instead, translateHYPERLINK(arg1[, arg2]) to IF(true, arg1[, arg2])
-
isHyperlinkFormulaCell
public static final boolean isHyperlinkFormulaCell(org.apache.poi.ss.usermodel.Cell cell) Returns true if the cell contains a hyperlink function.- Parameters:
cell- Cell to investigate- Returns:
- True if hyperlink is found
-
openExternalLink
Uses theDefaultHyperlinkCellClickHandler.HyperlinkOpenStyleto open link addresses. Subclass and override to use something else with the address.- Parameters:
address- to navigate to
-