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 theSpreadsheet.HyperlinkCellClickHandlerinterface. 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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultHyperlinkCellClickHandler.HyperlinkOpenStyleChoose how external links should open
-
Constructor Summary
Constructors Constructor Description DefaultHyperlinkCellClickHandler(Spreadsheet spreadsheet)DefaultHyperlinkCellClickHandler(Spreadsheet spreadsheet, DefaultHyperlinkCellClickHandler.HyperlinkOpenStyle openStyle)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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, translateStringgetHyperlinkFunctionTarget(org.apache.poi.ss.usermodel.Cell cell)Should only be called for cellsisHyperlinkFormulaCell(Cell)returns true.protected DefaultHyperlinkCellClickHandler.HyperlinkOpenStylegetOpenStyle()expose for subclassesprotected SpreadsheetgetSpreadsheet()expose for subclassesstatic 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.voidsetOpenStyle(DefaultHyperlinkCellClickHandler.HyperlinkOpenStyle openStyle)
-
-
-
Constructor Detail
-
DefaultHyperlinkCellClickHandler
public DefaultHyperlinkCellClickHandler(Spreadsheet spreadsheet)
- Parameters:
spreadsheet-
-
DefaultHyperlinkCellClickHandler
public DefaultHyperlinkCellClickHandler(Spreadsheet spreadsheet, DefaultHyperlinkCellClickHandler.HyperlinkOpenStyle openStyle)
- Parameters:
spreadsheet-openStyle- defaults toDefaultHyperlinkCellClickHandler.HyperlinkOpenStyle.NewTabif null
-
-
Method Detail
-
getSpreadsheet
protected Spreadsheet getSpreadsheet()
expose for subclasses- Returns:
- Spreadsheet for this handler
-
getOpenStyle
protected DefaultHyperlinkCellClickHandler.HyperlinkOpenStyle getOpenStyle()
expose for subclasses- Returns:
- the openStyle
-
setOpenStyle
public void setOpenStyle(DefaultHyperlinkCellClickHandler.HyperlinkOpenStyle openStyle)
- 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
public String getHyperlinkFunctionTarget(org.apache.poi.ss.usermodel.Cell cell)
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
protected String getFirstArgumentFromFormula(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, 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
protected void openExternalLink(String address)
Uses theDefaultHyperlinkCellClickHandler.HyperlinkOpenStyleto open link addresses. Subclass and override to use something else with the address.- Parameters:
address- to navigate to
-
-