Package org.zkoss.zk.ui

Examples of org.zkoss.zk.ui.UiException


    }
   
   
    public void removeColumns(Sheet sheet,int col,int size){
      if(size<=0){
        throw new UiException("size must > 0 : "+size);
      }else if(col<0){
        throw new UiException("column must >= 0 : "+col);
      }
      if(col>=_maxColumns){
        return;
      }
     
View Full Code Here


    }
   
   
    public void removeRows(Sheet sheet,int row,int size){
      if(size<=0){
        throw new UiException("size must > 0 : "+size);
      }else if(row<0){
        throw new UiException("row must >= 0 : "+row);
      }
      if(row>=_maxRows){
        return;
      }
      if(row+size>_maxRows){
View Full Code Here

    StringWriter out = new StringWriter();
    try {
      ((SpreadsheetCtrl)ss.getExtraCtrl()).getWidgetHandler().renderHttp(out);
      return out.toString();
    } catch (IOException e) {
      throw new UiException(e);
    }
  }
View Full Code Here

        oleft = otop = oright = obottom = -1;
      }
     
      if(type != SSDataEvent.MERGE_DELETE){
        if(right<left){
          throw new UiException("right < left : "+right+"<"+left +", type:"+type+", dir:"+dir);
        }
        if(bottom<top){
          throw new UiException("bottom < top : "+bottom+"<"+top +", type:"+type+", dir:"+dir);
        }
      }
      if(type == SSDataEvent.MERGE_DELETE){
        if(oright<oleft){
          throw new UiException("orig right < orig left : "+oright+"<"+oleft +", type:"+type+", dir:"+dir);
        }
        if(obottom<otop){
          throw new UiException("orig bottom < orig top : "+obottom+"<"+otop +", type:"+type+", dir:"+dir);
        }
      }
     
      log.debug("SSData Type:"+type+"\n Range - \tl:"+left+",t:"+top+",r:"+right+",b:"+bottom);
     
      if(SSDataEvent.CONTENTS_CHANGE == type){
        updateCell(sheet,rng.getLeft(),rng.getTop(),rng.getRight(),rng.getBottom());
      }else if(SSDataEvent.RANGE_INSERT == type){
        _updateCellId.next();
        if(top==-1){
          if(left<0) throw new UiException("Unsupported: insert column a index:"+left);
          ((ExtraCtrl)getExtraCtrl()).insertColumns(sheet,left,right-left+1);
        }else if(left==-1){
          if(top<0) throw new UiException("Unsupported: insert row a index:"+top);
          ((ExtraCtrl)getExtraCtrl()).insertRows(sheet,top,bottom-top+1);
        }else{
          log.error("unknow range when RANGE_INSERT");
        }
      }else if(SSDataEvent.RANGE_DELETE == type){
        _updateCellId.next();
        if(top==-1){
          if(left<0) throw new UiException("Unsupported: delete column a index:"+left);
          ((ExtraCtrl)getExtraCtrl()).removeColumns(sheet,left,right-left+1);
        }else if(left==-1){
          if(top<0) throw new UiException("Unsupported: delete row a index:"+top);
          ((ExtraCtrl)getExtraCtrl()).removeRows(sheet,top,bottom-top+1);
        }else{
          log.error("unknow range when RANGE_DELETE");
        }
      }else if(SSDataEvent.MERGE_CHANGE == type){
        log.debug("Orig Range\tl:"+oleft+",t:"+otop+",r:"+oright+",b:"+obottom);
        if(left<0 || top <0){
          throw new UiException("Unsupported: update merge at :"+left+","+top);
        }
        if(oleft<0 || otop <0){
          throw new UiException("Unsupported: update merge at :"+oleft+","+otop);
        }
        ((ExtraCtrl)getExtraCtrl()).updateMergeCell(sheet, left, top, right, bottom, oleft, otop, oright, obottom);
      }else if(SSDataEvent.MERGE_ADD == type){
        if(left<0 || top <0){
          throw new UiException("Unsupported: add merge at :"+left+","+top);
        }
        ((ExtraCtrl)getExtraCtrl()).addMergeCell(sheet, left, top, right, bottom);
      }else if(SSDataEvent.MERGE_DELETE == type){
        log.debug("Orig Range\tl:"+oleft+",t:"+otop+",r:"+oright+",b:"+obottom);
        if(oleft<0 || otop <0){
          throw new UiException("Unsupported: delete merge at :"+oleft+","+otop);
        }
        ((ExtraCtrl)getExtraCtrl()).deleteMergeCell(sheet, oleft, otop, oright, obottom);
      }else if(SSDataEvent.SIZE_CHANGE == type){
        Size size = event.getSize();
        if(top==-1){
View Full Code Here

   * @return the book model of this spread sheet.
   */
  public Book getBook() {
    if (_book == null) {
      if (_src == null) {
        throw new UiException("Must specify the src of the spreadsheet to create a new book");
      }
      try {
        Importer importer = _importer;
        if(importer == null){
          importer = new ExcelImporter();
        }

        if(importer instanceof ExcelImporter){
          URL url = null;
         
          if(_src.startsWith("/")){//try to load by application context.
            File file = new File(Executions.getCurrent().getDesktop().getWebApp().getRealPath(_src));
            if(file.exists()){
              url = file.toURI().toURL();
            }
          }
          if(url==null){//try to load from class loader
            url = new ClassLocator().getResource(_src);
          }
          if(url==null){//try to load from file
            File f = new File(_src);
            if(f.exists()){
              url = f.toURI().toURL();
            }
          }
         
          if(url==null){
            throw new UiException("resource for "+_src+" not found.");
          }

          _book = ((ExcelImporter)importer).imports(url);
        }else{
          _book = importer.imports(_src);
View Full Code Here

   * @return #{@link Sheet}
   */
  public Sheet getSelectedSheet(){
    if(_selectedSheet==null){
      if(_selectedSheetId==null){
        if(getBook().getSheets().size()==0) throw new UiException("sheet size of given book is zero");
        _selectedSheet = (Sheet)getBook().getSheets().get(0);
        _selectedSheetId = Utils.getId(_selectedSheet);
      }else{
        _selectedSheet = ((BookImpl)getBook()).lookupSheetById(_selectedSheetId);
        if(_selectedSheet==null){
          throw new UiException("can not find sheet by id : "+_selectedSheetId);
        }
      }
      doSheetSelected(_selectedSheet);
    }
    return _selectedSheet;
View Full Code Here

   */
  public void setSelectedSheet(String name) {
    if (_selectedSheet==null || !_selectedSheet.getName().equals(name)) {
      Sheet sheet = getBook().lookupSheet(name);
      if(sheet==null){
        throw new UiException("No such sheet : "+name);
      }
     
      if(_selectedSheet!=null) doSheetClean(_selectedSheet);
      _selectedSheet = sheet;
      _selectedSheetId = Utils.getId(_selectedSheet);
View Full Code Here

   * Default : 40.
   * @param maxrows the maximum row number
   */
  public void setMaxrows(int maxrows) {
    if (maxrows < 1) {
      throw new UiException("maxrow must be greater than 0: " + maxrows);
    }
    if(_maxRows != maxrows) {
      _maxRows = maxrows;
      JSONObj result = new JSONObj();
      result.setData("maxrow", _maxRows);
View Full Code Here

   * the minimal value of maxcols must large than 0;
   * @param maxcols the maximum column
   */
  public void setMaxcolumns(int maxcols) {
    if (maxcols < 1) {
      throw new UiException("maxcolumn must be greater than 0: " + maxcols);
    }
   
    if(_maxColumns != maxcols) {
      _maxColumns = maxcols;
      JSONObj result = new JSONObj();
View Full Code Here

  public void setSelection(Rect sel){
    if(!Objects.equals(_selectionRect,sel)){
      if(sel.getLeft()<0 || sel.getTop() < 0
          || 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());
View Full Code Here

TOP

Related Classes of org.zkoss.zk.ui.UiException

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.