Package org.zkoss.zss.ui.impl

Examples of org.zkoss.zss.ui.impl.JSONObj


    int w = right - left + 1;
    int h = bottom - top + 1;
   
    //check merge range;
   
    JSONObj jresult = new JSONObj();
    List rd = new ArrayList();
   
    jresult.setData("type","jump");
    jresult.setData("dir","jump");
    jresult.setData("left",left);
    jresult.setData("top",top);
    jresult.setData("width",w);
    jresult.setData("height",h);
    jresult.setData("data",rd);
   
   
   
    // prepare header
    JSONObj jheader;
    List theaders = null;
    List lheaders = null;
    boolean filltheader = false;
   
   
    if(!_hidecolhead){
      theaders = new ArrayList();
      jresult.setData("theader",theaders);
    }
   
    if(!_hiderowhead){
      lheaders = new ArrayList();
      jresult.setData("lheader",lheaders);
    }
   
    JSONObj jrow,jcell;
    //append row
    int re = top+h;
    int ce = left+w;
    for(int i=top;i<re;i++){
       jrow = new JSONObj();
       rd.add(jrow);
       prepareRowData(jrow,sheet,i);
       List cells = new ArrayList();
       jrow.setData("cells",cells);
       for(int j=left;j<ce;j++){
         jcell = new JSONObj();
         Cell cell = sheet.getCell(i,j);
         cells.add(jcell);
         prepareCellData(jcell,sheet,i,j);
         if(!_hidecolhead && !filltheader){
           jheader = new JSONObj();
           prepareTopHeaderData(jheader,j);
           theaders.add(jheader);
         }
       }
       filltheader = true;
       if(!_hiderowhead){
         jheader = new JSONObj();
         prepareLeftHeaderData(jheader,i);
         lheaders.add(jheader);
       }
    }
   
    _lastleft = left;
    _lastright = right;
    _lasttop = top;
    _lastbottom = bottom;
   
   
    //prepare top frozen cell
    int fzr = _spreadsheet.getRowfreeze();
    if(fzr>-1){
      JSONObj topFrozen = new JSONObj();
      jresult.setData("topfrozen",topFrozen);
     
      List tfrd = new ArrayList();
     
     
      topFrozen.setData("type","jump");
      topFrozen.setData("dir","jump");
      topFrozen.setData("left",left);
      topFrozen.setData("top",0);
      topFrozen.setData("width",w);
      topFrozen.setData("height",fzr+1);
      topFrozen.setData("data",tfrd);
     
      ce = left+w;
      for(int i=0;i<=fzr;i++){
         jrow = new JSONObj();
         tfrd.add(jrow);
         prepareRowData(jrow,sheet,i);
         List cells = new ArrayList();
         jrow.setData("cells",cells);
         for(int j=left;j<ce;j++){
           jcell = new JSONObj(); //cell
           Cell cell = sheet.getCell(i,j);
           cells.add(jcell);
           prepareCellData(jcell,sheet,i,j);
         }
      }
    }
   
   
    //prepare left frozen cell
    int fzc = _spreadsheet.getColumnfreeze();
    if(fzc>-1){
      JSONObj leftFrozen = new JSONObj();
      jresult.setData("leftfrozen",leftFrozen);
     
      List lfrd = new ArrayList();
     
     
      leftFrozen.setData("type","jump");
      leftFrozen.setData("dir","jump");
      leftFrozen.setData("left",0);
      leftFrozen.setData("top",top);
      leftFrozen.setData("width",fzc+1);
      leftFrozen.setData("height",h);
      leftFrozen.setData("data",lfrd);
     
      re = top+h;
      for(int i=top;i<re;i++){
         jrow = new JSONObj();
         lfrd.add(jrow);
         prepareRowData(jrow,sheet,i);
         List cells = new ArrayList();
         jrow.setData("cells",cells);
         for(int j=0;j<=fzc;j++){
           jcell = new JSONObj(); //cell
           Cell cell = sheet.getCell(i,j);
           cells.add(jcell);
           prepareCellData(jcell,sheet,i,j);
         }
      }
View Full Code Here


     *     { "index":1, "txt":"", "format":""; }
     *   ] }
     * ] }
     */

    JSONObj jresult = new JSONObj();
    List rd = new ArrayList();
   
    jresult.setData("type","neighbor");
    jresult.setData("dir","east");
    jresult.setData("width",fetchWidth);
    jresult.setData("height",blockBottom-blockTop+1);
    jresult.setData("data",rd);
    JSONObj jrow,jcell;
    JSONObj jheader;
    List headers = null;
    if(!_hidecolhead){
      headers = new ArrayList();
      jresult.setData("theader",headers);
    }
    boolean fillheader = false;
   
   
    //append row
    int cs = blockRight+1;
    int ce = cs+fetchWidth;
   
    for(int i=blockTop;i<=blockBottom;i++){
       jrow = new JSONObj();
       rd.add(jrow);
       prepareRowData(jrow,sheet,i);
       List cells = new ArrayList();

       jrow.setData("cells",cells);
       for(int j=cs;j<ce;j++){
         jcell = new JSONObj(); //cell
         Cell cell = sheet.getCell(i,j);
         cells.add(jcell);
         prepareCellData(jcell,sheet,i,j);
         if(!_hidecolhead && !fillheader){
           jheader = new JSONObj();
           prepareTopHeaderData(jheader,j);
           headers.add(jheader);
         }
        
       }
       fillheader = true;
    }
   
   
    _lastleft = blockLeft;
    _lastright = ce-1;
    _lasttop = blockTop;
    _lastbottom = blockBottom;
   
   
    //process frozen row data
    int fzr = _spreadsheet.getRowfreeze();
    if(fzr>-1){
      JSONObj topFrozen = new JSONObj();
      jresult.setData("topfrozen",topFrozen);
     
      List tfrd = new ArrayList();
     
      topFrozen.setData("type","neighbor");
      topFrozen.setData("dir","east");
      topFrozen.setData("width",fetchWidth);
      topFrozen.setData("height",fzr+1);
      topFrozen.setData("data",tfrd);
     
      for(int i=0;i<=fzr;i++){
         jrow = new JSONObj();
         tfrd.add(jrow);
         prepareRowData(jrow,sheet,i);
         List cells = new ArrayList();
         jrow.setData("cells",cells);
         for(int j=cs;j<ce;j++){
           jcell = new JSONObj(); //cell
           Cell cell = sheet.getCell(i,j);
           cells.add(jcell);
           prepareCellData(jcell,sheet,i,j);
         }
      }
View Full Code Here

 
  private String loadWest(Sheet sheet,String type,
      int blockLeft,int blockTop,int blockRight, int blockBottom,
      int fetchWidth) {
   
    JSONObj jresult = new JSONObj();
    List rd = new ArrayList();
   
    jresult.setData("type","neighbor");
    jresult.setData("dir","west");
    jresult.setData("width",fetchWidth);//increased cell size
    jresult.setData("height",blockBottom-blockTop+1);//increased cell size
    jresult.setData("data",rd);
    JSONObj jrow,jcell;
    JSONObj jheader;
    List headers = null;
    if(!_hidecolhead){
      headers = new ArrayList();
      jresult.setData("theader",headers);
    }
    boolean fillheader = false;
   
    //append row
    int cs = blockLeft-1;
    int ce = cs-fetchWidth;
    for(int i=blockTop;i<=blockBottom;i++){
       jrow = new JSONObj();
       rd.add(jrow);
       prepareRowData(jrow,sheet,i);
       List cells = new ArrayList();
       jrow.setData("cells",cells);
       for(int j=cs;j>ce;j--){
         jcell = new JSONObj();
         Cell cell = sheet.getCell(i,j);
         cells.add(jcell);
         prepareCellData(jcell,sheet,i,j);
        
         if(!_hidecolhead && !fillheader){
           jheader = new JSONObj();
           prepareTopHeaderData(jheader,j);
           headers.add(jheader);
         }
       }
       fillheader = true;
    }
   
    _lastleft = ce+1;
    _lastright = blockRight;
    _lasttop = blockTop;
    _lastbottom = blockBottom;
   
    //process frozen row data
    int fzr = _spreadsheet.getRowfreeze();
    if(fzr>-1){
      JSONObj topFrozen = new JSONObj();
      jresult.setData("topfrozen",topFrozen);
     
      List tfrd = new ArrayList();
     
      topFrozen.setData("type","neighbor");
      topFrozen.setData("dir","west");
      topFrozen.setData("width",fetchWidth);
      topFrozen.setData("height",fzr+1);
      topFrozen.setData("data",tfrd);
     
      for(int i=0;i<=fzr;i++){
         jrow = new JSONObj();
         tfrd.add(jrow);
         prepareRowData(jrow,sheet,i);
         List cells = new ArrayList();
         jrow.setData("cells",cells);
         for(int j=cs;j>ce;j--){
           jcell = new JSONObj(); //cell
           Cell cell = sheet.getCell(i,j);
           cells.add(jcell);
           prepareCellData(jcell,sheet,i,j);
         }
      }
View Full Code Here

 
  private String loadSouth(Sheet sheet,String type,
      int blockLeft,int blockTop,int blockRight, int blockBottom,
      int fetchHeight) {
   
    JSONObj jresult = new JSONObj();
    List rd = new ArrayList();
   
    jresult.setData("type","neighbor");
    jresult.setData("dir","south");
    jresult.setData("width",blockRight-blockLeft+1);
    jresult.setData("height",fetchHeight);
    jresult.setData("data",rd);
    JSONObj jrow,jcell;
    JSONObj jheader;
    List headers = null;
    if(!_hiderowhead){
      headers = new ArrayList();
      jresult.setData("lheader",headers);
    }
   
    int rs = blockBottom+1;
    int re = rs+fetchHeight;

    for(int i=rs;i<re;i++){
       jrow = new JSONObj();
       rd.add(jrow);
       prepareRowData(jrow,sheet,i);
       List cells = new ArrayList();
       jrow.setData("cells",cells);
       for(int j=blockLeft;j<=blockRight;j++){
         jcell = new JSONObj();
         Cell cell = sheet.getCell(i,j);
         cells.add(jcell);
         prepareCellData(jcell,sheet,i,j);
       }
       if(!_hiderowhead){
         jheader = new JSONObj();
         prepareLeftHeaderData(jheader,i);
         headers.add(jheader);
       }
    }
    _lastleft = blockLeft;
    _lastright = blockRight;
    _lasttop = blockTop;
    _lastbottom = re-1;
   
    //process frozen left
    int fzc = _spreadsheet.getColumnfreeze();
    if(fzc>-1){
      JSONObj leftFrozen = new JSONObj();
      jresult.setData("leftfrozen",leftFrozen);
     
      List lfrd = new ArrayList();
     
      leftFrozen.setData("type","neighbor");
      leftFrozen.setData("dir","south");
      leftFrozen.setData("width",fzc+1);
      leftFrozen.setData("height",fetchHeight);
      leftFrozen.setData("data",lfrd);
     
     
     
      rs = blockBottom+1;
      re = rs+fetchHeight;
     
      for(int i=rs;i<re;i++){
         jrow = new JSONObj();
         lfrd.add(jrow);
         prepareRowData(jrow,sheet,i);
         List cells = new ArrayList();
         jrow.setData("cells",cells);
         for(int j=0;j<=fzc;j++){
           jcell = new JSONObj(); //cell
           Cell cell = sheet.getCell(i,j);
           cells.add(jcell);
           prepareCellData(jcell,sheet,i,j);
         }
      }
View Full Code Here

  }
  private String loadNorth(Sheet sheet,String type,
      int blockLeft,int blockTop,int blockRight, int blockBottom,
      int fetchHeight) {

    JSONObj jresult = new JSONObj();
    List rd = new ArrayList();
   
    jresult.setData("type","neighbor");
    jresult.setData("dir","north");
    jresult.setData("width",blockRight-blockLeft+1);
    jresult.setData("height",fetchHeight);
    jresult.setData("data",rd);
    JSONObj jrow,jcell;
    JSONObj jheader;
    List headers = null;
    if(!_hiderowhead){
      headers = new ArrayList();
      jresult.setData("lheader",headers);
    }
    //append row
    int rs = blockTop-1;
    int re = rs-fetchHeight;
    for(int i=rs;i>re;i--){
       jrow = new JSONObj();
       rd.add(jrow);
       prepareRowData(jrow,sheet,i);
       List cells = new ArrayList();
       jrow.setData("cells",cells);
       for(int j=blockLeft;j<=blockRight;j++){
         jcell = new JSONObj();
         Cell cell = sheet.getCell(i,j);
         cells.add(jcell);
         prepareCellData(jcell,sheet,i,j);
       }
       if(!_hiderowhead){
         jheader = new JSONObj();
         prepareLeftHeaderData(jheader,i);
         headers.add(jheader);
       }
    }
    _lastleft = blockLeft;
    _lastright = blockRight;
    _lasttop = re+1;
    _lastbottom = blockBottom;
   
   
    //process frozen left
    int frc = _spreadsheet.getColumnfreeze();
    if(frc>-1){
      JSONObj leftFrozen = new JSONObj();
      jresult.setData("leftfrozen",leftFrozen);
     
      List lfrd = new ArrayList();
     
      leftFrozen.setData("type","neighbor");
      leftFrozen.setData("dir","north");
      leftFrozen.setData("width",frc+1);
      leftFrozen.setData("height",fetchHeight);
      leftFrozen.setData("data",lfrd);
     
     
     
      rs = blockTop-1;
      re = rs-fetchHeight;
     
      for(int i=rs;i>re;i--){
         jrow = new JSONObj();
         lfrd.add(jrow);
         prepareRowData(jrow,sheet,i);
         List cells = new ArrayList();
         jrow.setData("cells",cells);
         for(int j=0;j<=frc;j++){
           jcell = new JSONObj(); //cell
           Cell cell = sheet.getCell(i,j);
           cells.add(jcell);
           prepareCellData(jcell,sheet,i,j);
         }
      }
View Full Code Here

          || sel.getRight()>=this.getMaxcolumns() || sel.getBottom() >= this.getMaxrows()
          || sel.getLeft()>sel.getRight() || sel.getTop()>sel.getBottom()){
          throw new UiException("illegal selection : "+sel.toString());
      }
      _selectionRect.set(sel.getLeft(),sel.getTop(),sel.getRight(),sel.getBottom());
      JSONObj result = new JSONObj();
      result.setData("type","move");
      result.setData("left",sel.getLeft());
      result.setData("top",sel.getTop());
      result.setData("right",sel.getRight());
      result.setData("bottom",sel.getBottom());
     
      //TODO use command to a avoid use call focusTo in .invalidate() case;
      //smartUpdateValues("selection",new Object[]{"",Utils.getId(getSelectedSheet()),result.toString()});
      response("zssselection"+this.getUuid(),new AuSelection(this,result.toString()));
    }
  }
View Full Code Here

   * Sets the highlight rectangle or sets a null value to hide it.
   * @param highlight the highlight rect
   */
  public void setHighlight(Rect highlight){
    if(!Objects.equals(_highlightRect,highlight)){
      JSONObj result = new JSONObj();
      if(highlight==null){
        _highlightRect = null;
        result.setData("type","hide");
      }else{
        if(highlight.getLeft()<0 || highlight.getTop() < 0
            || highlight.getRight()>=this.getMaxcolumns() || highlight.getBottom() >= this.getMaxrows()
            || highlight.getLeft()>highlight.getRight() || highlight.getTop()>highlight.getBottom()){
            throw new UiException("illegal highlight : "+highlight.toString());
        }
        _highlightRect = (Rect)highlight.clone();
        result.setData("type","show");
        result.setData("left",_highlightRect.getLeft());
        result.setData("top",_highlightRect.getTop());
        result.setData("right",_highlightRect.getRight());
        result.setData("bottom",_highlightRect.getBottom());
      }
      response("zsshighlight",new AuHighlight(this,result.toString()));
    }
  }
View Full Code Here

      if(focus.getColumn()<0 || focus.getRow() < 0
          || focus.getColumn()>=this.getMaxcolumns() || focus.getRow() >= this.getMaxrows()){
          throw new UiException("illegal position : "+focus.toString());
      }
      _focusRect.set(focus.getColumn(),focus.getRow(),focus.getColumn(),focus.getRow());
      JSONObj result = new JSONObj();
      result.setData("type","move");
      result.setData("row",focus.getRow());
      result.setData("column",focus.getColumn());
     
      //TODO use command to a avoid use call focusTo in .invalidate() case;
      //smartUpdateValues("cellfocus",new Object[]{"",Utils.getId(getSelectedSheet()),result.toString()});
      response("zsscellfocus"+this.getUuid(),new AuCellFocus(this,result.toString()));
    }
  }
View Full Code Here

        Cell cell = sheet.getCell(row,col);
        //if(cell==null) continue;
        String text = (cell==null)?"":cell.getText();
       
       
        JSONObj result = new JSONObj();
        result.setData("r", row);
        result.setData("c", col);
        result.setData("type", "udcell");
       
        Format format = (cell==null)?null:cell.getFormat();
        boolean wrap = false;
       
        CellFormatHelper cfh = new CellFormatHelper(sheet,row,col,getMergeMatrixHelper(sheet));
        String st = cfh.getHtmlStyle();
        String ist = cfh.getInnerHtmlStyle();
        if (st != null && !"".equals(st)){
          result.setData("st", st);// style of text cell.
        }
        if (ist != null && !"".equals(ist)){
          result.setData("ist", ist);// inner style of text cell
        }
        if (format!=null && format.isTextWrap()){
          wrap = true;
          result.setData("wrap", true);
        }
        if (cfh.hasRightBorder()){
          result.setData("rbo",true);
        }
        TextHAlign textHAlign = (cell==null)?null:cell.getTextHAlign();
        if (textHAlign != null) {
          if (textHAlign.equals(TextHAlign.RIGHT)) {
            result.setData("hal","r");
          } else if (textHAlign.equals(TextHAlign.CENTER)) {
            result.setData("hal","c");
          }
        }
        text = Utils.escapeCellText(text,wrap,wrap);
        result.setData("val", text);
        responseUpdateCell(row+"_"+col+"_"+_updateCellId.last(),"",sheetId,result.toString());
      }
    }
  }
View Full Code Here

   * for example after user click a outside button or menu item.
   */
  public void focus(){
    //retrieve focus should work when spreadsheet init or after invalidate.
    //so I use response to implement it.
    JSONObj result = new JSONObj();
    result.setData("type", "retrive");
    response("zssfocus"+this.getUuid(),new AuRetrieveFocus(this,result.toString()));
  }
View Full Code Here

TOP

Related Classes of org.zkoss.zss.ui.impl.JSONObj

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.