Example usage for org.apache.poi.ss.usermodel Comment isVisible

List of usage examples for org.apache.poi.ss.usermodel Comment isVisible

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Comment isVisible.

Prototype

boolean isVisible();

Source Link

Document

Returns whether this comment is visible.

Usage

From source file:com.vaadin.addon.spreadsheet.action.ShowHideCellCommentAction.java

License:Open Source License

@Override
public boolean isApplicableForSelection(Spreadsheet spreadsheet, SelectionChangeEvent event) {
    if (!spreadsheet.getActiveSheet().getProtect()) {
        if (event.getCellRangeAddresses().size() == 0 && event.getIndividualSelectedCells().size() == 0) {
            CellReference cr = event.getSelectedCellReference();
            Comment cellComment = spreadsheet.getActiveSheet().getCellComment(cr.getRow(), cr.getCol());
            if (cellComment != null) {
                if (cellComment.isVisible()) {
                    setCaption("Hide comment");
                } else {
                    setCaption("Show comment");
                }//  w  ww.  j  av a 2s  .  com
                return true;
            }
        }
    }
    return false;
}

From source file:com.vaadin.addon.spreadsheet.action.ShowHideCellCommentAction.java

License:Open Source License

@Override
public void executeActionOnSelection(Spreadsheet spreadsheet, SelectionChangeEvent event) {
    CellReference cr = event.getSelectedCellReference();
    Comment cellComment = spreadsheet.getActiveSheet().getCellComment(cr.getRow(), cr.getCol());
    cellComment.setVisible(!cellComment.isVisible());
    Sheet sheet = spreadsheet.getActiveSheet();
    Row row = sheet.getRow(cr.getRow());
    if (row == null) {
        row = sheet.createRow(cr.getRow());
    }/*  w  w w  .j a va 2 s  . co m*/
    Cell cell = spreadsheet.getCell(cr);
    if (cell == null) {
        cell = row.createCell(cr.getCol());
    }
    spreadsheet.refreshCells(cell);
}

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

License:Open Source License

private void loadCellComments(int r1, int c1, int r2, int c2) {
    Sheet sheet = getActiveSheet();// w w w . ja  va2  s. co m
    for (int r = r1 - 1; r < r2; r++) {
        Row row = sheet.getRow(r);
        if (row != null && row.getZeroHeight()) {
            continue;
        }
        for (int c = c1 - 1; c < c2; c++) {
            if (sheet.isColumnHidden(c)) {
                continue;
            }

            int c_one_based = c + 1;
            int row_one_based = r + 1;

            MergedRegion region = mergedRegionContainer.getMergedRegion(c_one_based, row_one_based);
            // do not add comments that are "below" merged regions.
            // client side handles cases where comment "moves" (because
            // shifting etc.) from merged cell into basic or vice versa.
            if (region == null || region.col1 == c_one_based && region.row1 == row_one_based) {
                Comment comment = sheet.getCellComment(r, c);
                String key = SpreadsheetUtil.toKey(c_one_based, row_one_based);
                if (comment != null) {
                    // by default comments are shown when mouse is over the
                    // red
                    // triangle on the cell's top right corner. the comment
                    // position is calculated so that it is completely
                    // visible.
                    getState().cellComments.put(key, comment.getString().getString());
                    getState().cellCommentAuthors.put(key, comment.getAuthor());
                    if (comment.isVisible()) {
                        getState().visibleCellComments.add(key);
                    }
                }
                if (isMarkedAsInvalidFormula(c_one_based, row_one_based)) {
                    getState().invalidFormulaCells.add(key);
                }

            } else {
                c = region.col2 - 1;
            }
        }
    }
}

From source file:de.enerko.reports2.engine.CommentDefinition.java

License:Apache License

public CommentDefinition(final Comment comment) {
    this(comment.getString().getString(), comment.getAuthor(), comment.getColumn(), comment.getRow(), -1, -1,
            comment.isVisible());
}