package edu.colorado.csdms.wmt.client.ui.cell;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.ui.TextBox;

import edu.colorado.csdms.wmt.client.data.ParameterJSO;

/**
 * Displays an editable text box in a {@link ValueCell}. It's initialized with
 * the default value of a "string" parameter type.
 * 
 * @author Mark Piper (mark.piper@colorado.edu)
 */
public class TextCell extends TextBox {

  private ValueCell parent;
  private ParameterJSO parameter;
  
  public TextCell(ValueCell parent) {

    this.parent = parent;
    this.parameter = this.parent.getParameter();
    
    this.addKeyUpHandler(new TextEditHandler());
    this.setStyleName("wmt-TextBoxen");
    this.setText(parameter.getValue().getDefault());
  }

  /**
   * The handler for keyboard events in a TextCell.
   */
  public class TextEditHandler implements KeyUpHandler {
    @Override
    public void onKeyUp(KeyUpEvent event) {
      GWT.log("(onKeyUp:text)");
      TextCell cell = (TextCell) event.getSource();
      parent.setParameterValue(cell.getText());
    }
  }
}

@@ -299,15 +299,14 @@
 %0A * 
-Display
+Create
 s an
@@ -352,79 +352,77 @@
 l%7D. 
-It's initialized with%0A * the default value of a %22string%22 parameter type
+%7B@link KeyUpHandler%7D%0A * events are handled in %7B@link TextCellHandler%7D
 .%0A *
@@ -581,16 +581,193 @@
 ter;%0A  %0A
+  /**%0A   * Makes a %7B@link TextCell%7D initialized with the default value of a %22string%22%0A   * parameter type.%0A   * %0A   * @param parent the parent of the TextCell, a ValueCell%0A   */%0A
   public
@@ -906,28 +906,28 @@
 ler(new Text
-Edit
+Cell
 Handler());%0A
@@ -1111,12 +1111,12 @@
 Text
-Edit
+Cell
 Hand

Rename event handler, add docstrings