Package org.zkoss.zss.ui.au.in

Source Code of org.zkoss.zss.ui.au.in.StopEditingCommand

/* StopEditingCommand.java

{{IS_NOTE
  Purpose:
   
  Description:
   
  History:
    Dec 18, 2007 12:10:40 PM     2007, Created by Dennis.Chen
}}IS_NOTE

Copyright (C) 2007 Potix Corporation. All Rights Reserved.

{{IS_RIGHT
  This program is distributed under Lesser GPL Version 2.1 in the hope that
  it will be useful, but WITHOUT ANY WARRANTY.
}}IS_RIGHT
*/
package org.zkoss.zss.ui.au.in;


import java.util.Map;

import org.zkoss.lang.Objects;
import org.zkoss.zk.au.AuRequest;
import org.zkoss.zk.mesg.MZk;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.UiException;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zss.model.Worksheet;
import org.zkoss.zss.ui.Spreadsheet;
import org.zkoss.zss.ui.event.CellEvent;
import org.zkoss.zss.ui.event.StopEditingEvent;
import org.zkoss.zss.ui.impl.Utils;


/**
* A Command (client to server) for handling user(client) stop editing a cell
* @author Dennis.Chen
*
*/
public class StopEditingCommand implements Command {
 
  public void process(AuRequest request) {
    final Component comp = request.getComponent();
    if (comp == null)
      throw new UiException(MZk.ILLEGAL_REQUEST_COMPONENT_REQUIRED, this);
    final Map data = (Map)request.getData();
    if (data == null || data.size() != 6)
      throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA,
        new Object[] {Objects.toString(data), this});
    String token = (String) data.get("token");
    String sheetId = (String) data.get("sheetId");
    int row = (Integer) data.get("row");
    int col = (Integer) data.get("col");
    String value = (String) data.get("value");
    String type = (String) data.get("type");
   
    Worksheet sheet = ((Spreadsheet) comp).getSelectedSheet();
    if (!Utils.getSheetUuid(sheet).equals(sheetId))
      return;
   
   
    CellEvent event = new StopEditingEvent(org.zkoss.zss.ui.event.Events.ON_STOP_EDITING, comp, sheet, row, col, value);
    Events.postEvent(event);
    Events.postEvent(new Event("onStopEditingImpl", comp, new Object[] {token, event, type}));
  }
}
TOP

Related Classes of org.zkoss.zss.ui.au.in.StopEditingCommand

TOP
Copyright © 2018 www.massapi.com. 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.