Package org.zkoss.xel

Examples of org.zkoss.xel.XelContext


    //notify all changed cells
    notifyCellChanges(book, all);
  }

  public static CellValue evaluate(Book book, Cell cell) {
    final XelContext old = XelContextHolder.getXelContext();
    try {
      final VariableResolver resolver = BookHelper.getVariableResolver(book);
      final FunctionMapper mapper = BookHelper.getFunctionMapper(book);
      final XelContext ctx = new SimpleXelContext(resolver, mapper);
      ctx.setAttribute("zkoss.zss.CellType", Object.class);
      XelContextHolder.setXelContext(ctx);
      final CellValue cv = book.getFormulaEvaluator().evaluate(cell);
      //set back into Cell formula record(update value and cachedFormulaResultType)
      setCellValue(cell, cv);
      return cv;
View Full Code Here


    }
    return false;
  }
 
  private static CellValue evaluateFormula(Book book, int sheetIndex, String formula) {
    final XelContext old = XelContextHolder.getXelContext();
    try {
      final VariableResolver resolver = BookHelper.getVariableResolver(book);
      final FunctionMapper mapper = BookHelper.getFunctionMapper(book);
      final XelContext ctx = new SimpleXelContext(resolver, mapper);
      ctx.setAttribute("zkoss.zss.CellType", Object.class);
      XelContextHolder.setXelContext(ctx);
      final CellValue cv = book.getFormulaEvaluator().evaluateFormula(sheetIndex, formula);
      return cv;
    } finally {
      XelContextHolder.setXelContext(old);
View Full Code Here

      XelContextHolder.setXelContext(old);
    }
  }

  private static ValueEval evaluateFormulaValueEval(Book book, int sheetIndex, String formula, boolean ignoreDereference) {
    final XelContext old = XelContextHolder.getXelContext();
    try {
      final VariableResolver resolver = BookHelper.getVariableResolver(book);
      final FunctionMapper mapper = BookHelper.getFunctionMapper(book);
      final XelContext ctx = new SimpleXelContext(resolver, mapper);
      ctx.setAttribute("zkoss.zss.CellType", Object.class);
      XelContextHolder.setXelContext(ctx);
      return book.getFormulaEvaluator().evaluateFormulaValueEval(sheetIndex, formula, ignoreDereference);
    } finally {
      XelContextHolder.setXelContext(old);
    }
View Full Code Here

    }
    return opResult;
  }
 
  protected CellRefImpl prepareSrcRef(OperationEvaluationContext ec) {
    final XelContext ctx = XelContextHolder.getXelContext();
    CellRefImpl srcRef = null;
    boolean isOld = false;
    final String srcSheetName = ec.getSheetName();
    final int srcRow = ec.getRowIndex();
    final int srcCol = ec.getColumnIndex();
    final RefBook srcRefBook = BookHelper.getOrCreateRefBook(_book);
    final RefSheet srcRefSheet = srcRefBook.getOrCreateRefSheet(srcSheetName);
    if (ctx != null) {
      final String srcRefKey = srcRefBook.getBookName()+"]"+srcSheetName+"!"+new CellReference(srcRow, srcCol).formatAsString();
      final Object[] refs = (Object[]) ctx.getAttribute(srcRefKey);
      if (refs != null) {
        srcRef = (CellRefImpl) refs[0];
        isOld = ((Boolean)refs[1]).booleanValue();
      } else {
        srcRef = (CellRefImpl) srcRefSheet.getRef(srcRow, srcCol, srcRow, srcCol);
        if (srcRef == null) { // a new evaluated one
          srcRef = (CellRefImpl) srcRefSheet.getOrCreateRef(srcRow, srcCol, srcRow, srcCol);
        } else {
          isOld = !srcRef.getPrecedents().isEmpty();
        }
        ctx.setAttribute(srcRefKey, new Object[] {srcRef, Boolean.valueOf(isOld)});
      }
      if (isOld) { //an old src ref, no need to add dependency
        return null;
      }
    } else {
View Full Code Here

TOP

Related Classes of org.zkoss.xel.XelContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.