Package org.zkoss.zss.app.zul.ctrl

Examples of org.zkoss.zss.app.zul.ctrl.WorkbookCtrl


  public void onClick$exportHtml() {
    getDesktopWorkbenchContext().getWorkbenchCtrl().openExportHtmlDialog(null);
  }
 
  public void onClick$exportExcel() {
    WorkbookCtrl bookCtrl = getDesktopWorkbenchContext().getWorkbookCtrl();
    ByteArrayOutputStream out = bookCtrl.exportToExcel();
    Filedownload.save(out.toByteArray(), "application/file", bookCtrl.getBookName());
  }
View Full Code Here


    }
    removeNonexistentFocus(currentFocus, newFocus);
  }
 
  private void removeNonexistentFocus(LinkedHashSet<String> currentFocus, LinkedHashSet<String> newFocus) {
    WorkbookCtrl bookCtrl = getDesktopWorkbenchContext().getWorkbookCtrl();
    for (String ref : currentFocus) {
      if (!newFocus.contains(ref)) {
        bookCtrl.removeEditorFocus(ref);
        addedFocusNames.remove(ref);
      }
    }
  }
View Full Code Here

    }
    return val;
  }
 
  private void cacheFormulaEditingInfo() {
    WorkbookCtrl bookCtrl = getDesktopWorkbenchContext().getWorkbookCtrl();
    formulaRow = bookCtrl.getSelection().getTop();
    formulaColumn = bookCtrl.getSelection().getLeft();
    formulaCell = Utils.getCell(bookCtrl.getSelectedSheet(), formulaRow, formulaColumn);
    formulaSheet = bookCtrl.getSelectedSheet();
    formulaText = Utils.getCellText(formulaSheet, formulaCell);
    formulaEdit = Utils.getEditText(formulaCell);
  }
View Full Code Here

      return true;
    return false;
  }
 
  public void onChanging(InputEvent event) {
    WorkbookCtrl bookCtrl = getDesktopWorkbenchContext().getWorkbookCtrl();
    newEdit = event.getValue();
    if (isComposingFormula(newEdit)) {
      //if (editExistingFormula && allowAppendCellReference(newEdit))
      //  editExistingFormula = allowAppendCellReference(newEdit);
      bookCtrl.escapeAndUpdateText(formulaCell, newEdit);
      if (isStartEditingFormula(newEdit))
        cacheFormulaEditingInfo();
      generateCellFocus(newEdit);
    else if (currentEditcell != null) {
      final int left = bookCtrl.getSelection().getLeft();
      final int top = bookCtrl.getSelection().getTop();
      final Worksheet sheet = bookCtrl.getSelectedSheet();
      currentEditcell = Utils.getOrCreateCell(sheet, top, left);
      bookCtrl.escapeAndUpdateText(currentEditcell, newEdit);
    }
  }
View Full Code Here

    return editLabel != null && editLabel.length() > 0 &&
        Separator.contains(editLabel.charAt(editLabel.length() - 1));
  }

  public void onCancel() {
    WorkbookCtrl bookCtrl = getDesktopWorkbenchContext().getWorkbookCtrl();
    focusOut = true;
    recoverEditorText();
    recoverCellText();
    endEditingFormula(false);
    int row = bookCtrl.getSelection().getTop();
    int col = bookCtrl.getSelection().getLeft();
    bookCtrl.focusTo(row, col, true);
  }
View Full Code Here

    int col = bookCtrl.getSelection().getLeft();
    bookCtrl.focusTo(row, col, true);
  }
 
  public void onFocus() {
    WorkbookCtrl bookCtrl = getDesktopWorkbenchContext().getWorkbookCtrl();
    Worksheet sheet = bookCtrl.getSelectedSheet();
    if (sheet == null) { //no sheet, no operation
      return;
    }
    bookCtrl.reGainFocus();

    //TODO: why need it ?
    //newEdit = null;

    everFocusCell = false;
    everTab = null;
    focusOut = false;
    int left = bookCtrl.getSelection().getLeft();
    int top = bookCtrl.getSelection().getTop();
    currentEditcell = Utils.getCell(sheet, top, left);
   
    if (currentEditcell != null) {
      oldEdit = Ranges.range(sheet, top, left).getEditText();
      oldText = Utils.getCellText(sheet, currentEditcell); //escaped HTML to show cell value
      if (!isComposingFormula(newEdit))
        bookCtrl.escapeAndUpdateText(currentEditcell, oldEdit);

      if (!editExistingFormula && isComposingFormula(oldEdit) && addedFocusNames.size() == 0) {
        editExistingFormula = true;
        cacheFormulaEditingInfo();
        generateCellFocus(oldEdit);
      }
    }
    bookCtrl.clearClipbook();
  }
View Full Code Here

  public void onChange(Event event) {
    newEdit = ((InputEvent)event).getValue(); //remember the changed value
  }
 
  private void handleCellText() {
    WorkbookCtrl bookCtrl = getDesktopWorkbenchContext().getWorkbookCtrl();
    if (newEdit == null) { //no change
      recoverCellText(); //recover cell text
    } else if (currentEditcell != null){
      if (!isComposingFormula(newEdit))
        Utils.setEditText(bookCtrl.getSelectedSheet(),
            currentEditcell.getRowIndex(), currentEditcell.getColumnIndex(), newEdit);
    }
  }
View Full Code Here

            currentEditcell.getRowIndex(), currentEditcell.getColumnIndex(), newEdit);
    }
  }
 
  public void onBlur() {
    WorkbookCtrl bookCtrl = getDesktopWorkbenchContext().getWorkbookCtrl();
    if (focusOut) { //onChange, onOK, or onCancel already done everything!
      return;
    }
    if (editExistingFormula) {
      if (!allowAppendCellReference(newEdit)) {
        endEditingFormula(false);
      }
      editExistingFormula = false;
    }
    focusOut = true;
   
    handleCellText();
   
    Position pos = bookCtrl.getCellFocus();
    int row = pos.getRow();
    int col = pos.getColumn();
    int oldrow = currentEditcell == null ? -1 : currentEditcell.getRowIndex();
    int oldcol = currentEditcell == null ? -1 : currentEditcell.getColumnIndex();
    final boolean focusChanged = (row != oldrow || col != oldcol); //user click directly to a different cell
    if (!focusChanged) {
      if (everTab != null) { //Tab key
        final Worksheet sheet = bookCtrl.getSelectedSheet();
        if (everTab.booleanValue()) { //shift + Tab
          col = col - 1;
          if (col < 0) {
            col = 0;
          } else {
            final CellRangeAddress merged = sheet != null ? ((SheetCtrl)sheet).getMerged(row, col) : null;
            if (merged != null) {
              col = merged.getFirstColumn();
            }
          }
        } else { //Tab
          final CellRangeAddress merged = sheet != null ? ((SheetCtrl)sheet).getMerged(row, col) : null;
          col = merged == null ? col + 1 : merged.getLastColumn() + 1;
          if (bookCtrl.getMaxcolumns() <= col) {
            col = bookCtrl.getMaxcolumns() - 1;
            final CellRangeAddress newmerged = sheet != null ? ((SheetCtrl)sheet).getMerged(row, col) : null;
            if (newmerged != null) {
              col = newmerged.getFirstColumn();
            }
          }
        }
        bookCtrl.focusTo(row, col, true);
      } else if (everFocusCell) { //click on the same cell, shall enter edit mode, something like press F2
        //TODO click on the same cell, shall enter edit mode, something like press F2
      }
    }
  }
View Full Code Here

 
  private void recoverEditorText() {
    setText(oldEdit);
  }
  private void recoverCellText() {
    WorkbookCtrl bookCtrl = getDesktopWorkbenchContext().getWorkbookCtrl();
    if (oldText != null && currentEditcell != null) {
      //already escape, simply update
      bookCtrl.updateText(currentEditcell, oldText);
      bookCtrl.escapeAndUpdateText(formulaCell, formulaText != null ? formulaText : oldText);
      if (formulaEdit != null) {
        Utils.setEditText(formulaCell, formulaEdit);
      }
    }
  }
View Full Code Here

  public void onOK() {
    if (formulaCell != null) {
      endEditingFormula(true);
    }
    WorkbookCtrl bookCtrl  = getDesktopWorkbenchContext().getWorkbookCtrl();   
    focusOut = true;
    handleCellText();
   
    //move cell focus
    Position pos = bookCtrl.getCellFocus();
    int row = pos.getRow() + 1;
    int col = pos.getColumn();
    if (bookCtrl.getMaxrows() <= row) {
      row = bookCtrl.getMaxrows() - 1;
    }
    bookCtrl.focusTo(row, col, true);
  }
View Full Code Here

TOP

Related Classes of org.zkoss.zss.app.zul.ctrl.WorkbookCtrl

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.