Package com.extjs.gxt.ui.client.binding

Source Code of com.extjs.gxt.ui.client.binding.TimeFieldBinding

/*
* Sencha GXT 2.3.1 - Sencha for GWT
* Copyright(c) 2007-2013, Sencha, Inc.
* licensing@sencha.com
*
* http://www.sencha.com/products/gxt/license/
*/
package com.extjs.gxt.ui.client.binding;

import java.util.Date;

import com.extjs.gxt.ui.client.widget.form.Time;
import com.extjs.gxt.ui.client.widget.form.TimeField;

/**
* A specialized binding that automatically handles data conversion when dates
* are bound to a time field.
*
* @see TimeField
*/
public class TimeFieldBinding extends FieldBinding {

  protected TimeField timeField;

  /**
   * Creates a new time field binding instance.
   *
   * @param field the time field
   * @param property the property name
   */
  public TimeFieldBinding(TimeField field, String property) {
    super(field, property);
    this.timeField = field;
  }

  @Override
  protected Object onConvertFieldValue(Object value) {
    if (value == null) {
      return null;
    }
    Time time = (Time) value;
    return time.getDate();
  }

  @Override
  protected Object onConvertModelValue(Object value) {
    if (value == null) {
      return null;
    }
    Date date = (Date) value;
    return timeField.findModel(date);
  }

}
TOP

Related Classes of com.extjs.gxt.ui.client.binding.TimeFieldBinding

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.