/*
 * #%L
 * GwtMaterial
 * %%
 * Copyright (C) 2015 - 2016 GwtMaterialDesign
 * %%
 * 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.
 * #L%
 */
package gwt.material.design.client.ui;

import com.google.gwt.dom.client.Element;
import com.google.gwt.uibinder.client.UiConstructor;
import gwt.material.design.client.base.NumberBox;
import gwt.material.design.client.base.NumberBox.NumberHandler;
import gwt.material.design.client.constants.InputType;

//@formatter:off

/**
 * Material Number Box is the base class for other numeric input boxes, such as {@link MaterialIntegerBox} and
 * {@link MaterialDoubleBox}.
 *
 * @author paulux84
 * @see <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/#!forms">Material MaterialNumberBox</a>
 */
//@formatter:on
public class MaterialNumberBox<T> extends MaterialValueBox<T> {

    @UiConstructor
    public MaterialNumberBox() {
        initValueBox(new NumberBox<T>(new NumberHandler<T>(this)));
        setType(InputType.NUMBER);
    }

    /**
     * Set step attribute to input element.
     *
     * @param step "any" or number like for example 1 or 2.5 or 100, etc...
     */
    public void setStep(String step) {
        valueBoxBase.getElement().setAttribute("step", step);
    }

    public String getStep() {
        return valueBoxBase.getElement().getAttribute("step");
    }

    public void setMin(String min) {
        valueBoxBase.getElement().setAttribute("min", min);
    }

    public String getMin() {
        return valueBoxBase.getElement().getAttribute("min");
    }

    public void setMax(String max) {
        valueBoxBase.getElement().setAttribute("max", max);
    }

    public String getMax() {
        return valueBoxBase.getElement().getAttribute("max");
    }

    @Override
    public String getText() {
        return valueBoxBase.getText();
    }

    /**
     * Returns the value parsed natively by the browser.
     *
     * @return the value set on the component, or NaN if none is set
     */
    public double getValueAsNumber() {
        return getValueAsNumber(valueBoxBase.getElement());
    }

    /**
     * Native call to element.valueAsNumber.
     */
    protected native double getValueAsNumber(Element el)/*-{
        return el.valueAsNumber;
    }-*/;

}

@@ -1340,33 +1340,17 @@
     
-@UiConstructor%0A    public
+protected
  Mat
@@ -1403,17 +1403,16 @@
 mberBox%3C
-T
 %3E(new Nu
@@ -1423,17 +1423,16 @@
 Handler%3C
-T
 %3E(this))
@@ -2313,32 +2313,466 @@
 tText();%0A    %7D%0A%0A
+    /**%0A     * This is expected to be overridden in the inherited classes.%0A     */%0A    @Override%0A    public T getValue() %7B%0A        throw new RuntimeException(%22MaterialNumberBox#getValue should not be called directly, %22 +%0A            %22please make sure you are not using the MaterialNumberBox directly. See MaterialIntegerBox, %22 +%0A            %22MaterialDoubleBox, MaterialFloatBox, MaterialLongBox for correct implementations.%22);%0A    %7D%0A%0A
     /**%0A     * R

Resolve a stack overflow issue with MaterialNumberBox#getValue.