Package org.zkoss.xel

Examples of org.zkoss.xel.VariableResolver


   * Spring libraries in the classpath
   */
  public Object resolveVariable(String name) {
    Object o = null;
    for (final Iterator it = _variableResolvers.iterator(); it.hasNext();) {
      VariableResolver resolver = (VariableResolver) it.next();
      o = resolver.resolveVariable(name);
      if (o != null) {
        return o;
      }
    }
    return o;
View Full Code Here


   * @param component
   *            target component
   */
  public static void setSelfContextComponent(Component component) {
    final Execution exec = Executions.getCurrent();
    final VariableResolver vresolver = exec.getVariableResolver();
    ((ExecutionResolver) vresolver).setSelf(component);
  }
View Full Code Here

   *
   * @returns component
   */
  public static Component getSelfContextComponent() {
    final Execution exec = Executions.getCurrent();
    final VariableResolver vresolver = exec.getVariableResolver();
    return (Component) ((ExecutionResolver) vresolver).getSelf();
  }
View Full Code Here

  //Internal Use Only. Called when formula in a cell is to be removed.
  public void remove(XelContext ctx)
  throws XelException {
    if (_type == TokenType.OPERAND && _subtype == TokenSubtype.VAR) { //refer to a variable
      final VariableResolver resolver = ctx.getVariableResolver();
      final Reference ref =
        (Reference) resolver.resolveVariable("zkoss.ss.Ref");
      final BookImpl book = (BookImpl) ref.getSheet().getBook();
      book.removeVariable((String)_value, ref);
    }
   
    //scan thru kid tokens
View Full Code Here

        final Cell cell = it.hasNext() ? (Cell) it.next() : null;
        return cell != null ? cell.getResult() : null;
      } else if (_subtype == TokenSubtype.RANGE) { //refer to a range
        return (Range) _value;
      } else if (_subtype == TokenSubtype.VAR) { //refer to a variable
        final VariableResolver resolver = ctx.getVariableResolver();
/*        final Reference ref =
          (Reference) resolver.resolveVariable("zkoss.ss.Ref");
        final Book book = ref.getSheet().getBook();
        //lookup NameRange first
        Object x = book.lookupNameRange((String)_value);
View Full Code Here

  private String getCellPrintString(Cell cell, boolean absrow, boolean abscol, XelContext ctx) {
    if (cell == null) { //no such cell
      return SSError.REF.toString();
    }
    final StringBuffer sb = new StringBuffer(32);
    final VariableResolver resolver = ctx.getVariableResolver();
    final Reference ref = (Reference) resolver.resolveVariable("zkoss.ss.Ref");
    final Sheet orgsheet = ref.getSheet();
    final Book orgbook = orgsheet.getBook();
   
    final Sheet sheet = cell.getSheet();
    final Book book = sheet.getBook();
View Full Code Here

  private String getRangePrintString(Range rng, XelContext ctx) {
    if (rng == null) { //no such cell
      return SSError.REF.toString();
    }
    final StringBuffer sb = new StringBuffer(32);
    final VariableResolver resolver = ctx.getVariableResolver();
    final Reference ref = (Reference) resolver.resolveVariable("zkoss.ss.Ref");
    final Sheet orgsheet = ref.getSheet();
    final Book orgbook = orgsheet.getBook();
   
    final Sheet sheet = rng.getSheet();
    final Sheet sheetTo = rng.getSheetTo();
View Full Code Here

    Cell cellC1 = _sheet1.setCellEditText(0, 2, "=bankAccount3"); //C1
    Cell cellD1 = _sheet1.setCellEditText(0, 3, "=SUM(A1:C1)"); //D1
    Cell cellE1 = _sheet1.setCellEditText(0, 4, "=bankAccount1 + bankAccount2 + bankAccount3"); //E1
   
    Map varmap = new HashMap();
    VariableResolver resolver = new SimpleResolver(varmap);
    _book.addVariableResolver(resolver);

    varmap.put("bankAccount1", new Double(1d));
    varmap.put("bankAccount2", new Double(10d));
    varmap.put("bankAccount3", new Double(100d));
View Full Code Here

    Cell cellC1 = _sheet1.setCellEditText(0, 2, "=account.acc3"); //C1
    Cell cellD1 = _sheet1.setCellEditText(0, 3, "=SUM(A1:C1)"); //D1
    Cell cellE1 = _sheet1.setCellEditText(0, 4, "=account.acc1 + account.acc2 + account.acc3"); //E1
   
    Map varmap = new HashMap();
    VariableResolver resolver = new SimpleResolver(varmap);
    _book.addVariableResolver(resolver);

    varmap.put("account", new MyAccount());
   
    assertValue(2d, ((Number)cellA1.getResult()).doubleValue(), 0d);
View Full Code Here

 
  //--VariableResolver--//
  public Object resolveVariable(String name)
  throws XelException {
    for (final Iterator it = _resolvers.iterator(); it.hasNext();) {
      final VariableResolver resolver = (VariableResolver) it.next();
      final Object result = resolver.resolveVariable(name);
      if (result != null) return result;
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of org.zkoss.xel.VariableResolver

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.