Example usage for org.apache.poi.common.usermodel Hyperlink getType

List of usage examples for org.apache.poi.common.usermodel Hyperlink getType

Introduction

In this page you can find the example usage for org.apache.poi.common.usermodel Hyperlink getType.

Prototype

public HyperlinkType getType();

Source Link

Document

Return the type of this hyperlink

Usage

From source file:com.vaadin.addon.spreadsheet.DefaultHyperlinkCellClickHandler.java

License:Open Source License

@Override
public void onHyperLinkCellClick(Cell cell, Hyperlink hyperlink, Spreadsheet spreadsheet) {
    if (hyperlink != null) {
        if (hyperlink.getType() == LINK_DOCUMENT) { // internal
            navigateTo(cell, spreadsheet, hyperlink.getAddress());
        } else {/*from   ww  w  .  j  a  v  a 2  s  .c o m*/
            spreadsheet.getUI().getPage().open(cell.getHyperlink().getAddress(), "_new");
        }
    } else if (isHyperlinkFormulaCell(cell)) {
        String address = getHyperlinkFunctionCellAddress(cell);
        if (address.startsWith("#")) { // inter-sheet address
            navigateTo(cell, spreadsheet, address.substring(1));
        } else if (address.startsWith("[") && address.contains("]")) {
            // FIXME: for now we assume that the hyperlink points to the
            // current file. Should check file name against
            // address.substring(1, address.indexOf("]"));
            navigateTo(cell, spreadsheet, address.substring(address.indexOf("]") + 1));
        } else {
            spreadsheet.getUI().getPage().open(address, "_new");
        }
    }
}