burrito.client.crud.input.BooleanCrudInputField.java Source code

Java tutorial

Introduction

Here is the source code for burrito.client.crud.input.BooleanCrudInputField.java

Source

/**
 * Copyright 2011 Henric Persson (henric.persson@gmail.com)
 * 
 * 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 burrito.client.crud.input;

import burrito.client.crud.generic.CrudField;
import burrito.client.crud.generic.fields.BooleanField;

import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Widget;

@SuppressWarnings("rawtypes")
public class BooleanCrudInputField implements CrudInputField {

    private BooleanField field;
    private CheckBox widget;

    public BooleanCrudInputField(BooleanField field) {
        this.field = field;
        this.widget = new CheckBox();
        if (field.getValue() != null) {
            widget.setValue((Boolean) field.getValue());
        }
    }

    public CrudField getCrudField() {
        field.setValue(widget.getValue());
        return field;
    }

    public Widget getDisplayWidget() {
        return widget;
    }

    public Object getValue() {
        return widget.getValue();
    }

    public void load(Object value) {
        widget.setValue((Boolean) value);
    }
}