eu.future.earth.gwt.client.DateBox Maven / Gradle / Ivy
/*
* Copyright 2007 Future Earth, [email protected]
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package eu.future.earth.gwt.client;
import java.util.Date;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.logical.shared.HasValueChangeHandlers;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Composite;
public class DateBox extends Composite implements KeyUpHandler, HasValueChangeHandlers {
public final static String DEFAULT_DATE_FORMAT = "dd-MM-yyyy";
private DateBoxInternal edit = null;
public DateBox() {
this(DEFAULT_DATE_FORMAT);
}
public DateBox(String format) {
super();
edit = new DateBoxInternal(DEFAULT_DATE_FORMAT);
initWidget(edit);
edit.addKeyUpHandler(this);
}
@Override
public void addStyleName(String style) {
edit.addStyleName(style);
}
@Override
public String getStyleName() {
return edit.getStyleName();
}
@Override
public void setStyleName(String style) {
edit.setStyleName(style);
}
@Override
public void setStylePrimaryName(String style) {
edit.setStylePrimaryName(style);
}
public void setEnabled(boolean newState) {
edit.setEnabled(newState);
}
public void setValue(Date newValue) {
edit.setDate(newValue);
}
public Date getValue() {
return edit.getDate();
}
public String getFormat() {
return edit.getFormat();
}
public void setFormat(String format) {
edit.setFormat(format);
}
public void onKeyUp(KeyUpEvent event) {
ValueChangeEvent.fire(this, edit.getDate());
}
public HandlerRegistration addValueChangeHandler(ValueChangeHandler handler) {
return addHandler(handler, ValueChangeEvent.getType());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy