Git Product home page Git Product logo

stepper's Introduction

Field that allows stepping through values via given up/down controls, the keyboard, or the mouse wheel. Supports client-side limits for all value types.

Implementations for integer, float and date values are provided.

Getting started

Build project: ./gradlew build

Run demo application: ./gradlew demo:vaadinRun

Usage

Example:

final IntStepper stepper = new IntStepper();
stepper.setValue(1);
stepper.setImmediate(true);

stepper.addListener(new Property.ValueChangeListener() {

	public void valueChange(ValueChangeEvent event) {
		stepper.getWindow().showNotification(
			new Date() + " " + event.getProperty().getValue());
	}
});

License

Code is licensed under Apache 2.0.

stepper's People

Contributors

mwisnicki avatar ollitietavainenvaadin avatar ripla avatar vlna avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

stepper's Issues

Duplicate stepper.scss lines in addons.scss when updating theme with vaadin maven plugin

When updating my theme with the vaadin maven plugin I get duplicate imports of the stepper.scss in the addons.scss file, one entry contains double //.

/* This file is automatically managed and will be overwritten from time to time. */
/* Do not manually edit this file. */

/* Provided by stepper-2.4.0.jar */
@import "../../..//VAADIN/addons/stepper/stepper.scss";

/* Provided by stepper-2.4.0.jar */
@import "../../../VAADIN/addons/stepper/stepper.scss";

/* Provided by vaadin-spreadsheet-2.0.1.jar */
@import "../../../VAADIN/addons/spreadsheet/spreadsheet.scss";

/* Import and include this mixin into your project theme to include the addon themes */
@mixin addons {
	@include stepper;
	@include stepper;
	@include spreadsheet;
}

The reason for this is that the stepper MANIFEST.MF contains 3 entries for the stepper.scss

Vaadin-Stylesheets: VAADIN/addons/stepper/stepper.scss,/VAADIN/addons/
 stepper/stepper.scss,/VAADIN/addons/stepper/stepper.scss

It should only contain one entry

Vaadin-Stylesheets: VAADIN/addons/stepper/stepper.scss

Jrebel configuration in stepper.jar

Could you remove rebel.xml file from stepper.jar?

When I start Jetty with Jrebel I'm getting this error:

JRebel: Error! Invalid 'dir' defined in class path of rebel.xml (jar:file:/home/xyz/.m2/repository/org/vaadin/addons/stepper/1.1.0/stepper-1.1.0.jar!/rebel.xml): Directory '/Users/ripla/Documents/workspaces/community/Stepper/build/classes' does not exist

JRebel: Error! Invalid 'dir' defined in web link of rebel.xml (jar:file:/home/xyz/.m2/repository/org/vaadin/addons/stepper/1.1.0/stepper-1.1.0.jar!/rebel.xml): Directory '/Users/ripla/Documents/workspaces/community/Stepper/WebContent' does not exist

Server side validation caching problem

invalid values:

I use the stepper with server side validation, i.e. i allow invalid values, check those on the server, and correct them to be inside the valid range. i.e. range=5..250 ,

Now the user enters 2 (or "abc" or any other invalid value), i correct it on the server side by setValue(5). the 5 is then correctly transmitted to the browser and displayed.
Everything just fine and nice so far.

However, when the user then enters an invalid value again, and the server side corrects it again to "5". this second time the corrects is not displayed The setValue(5) does not seem to reach the client side.

setValue(x) does start to talk to the client side again as soon as the x is no longer 5.

i assume some caching prevents me from setting the same value (here: 5) twice.

DataSource issue

First manually entered value disappears when IntStepper is bound to a datasource that has a default value.
Steps to reproduce:

Create a new Vaadin project for 7.2.3
Add the dependency to the ivy.xml:
<dependency org="org.vaadin.addons" name="stepper" rev="2.1.2" />
Create a pojo with default value:

public class TestItem
{
    private Integer testValue = 10;

    public Integer getTestValue()
    {
        return testValue;
    }

    public void setTestValue(Integer testValue)
    {
        this.testValue = testValue;
    }
}

Create IntStepper and bind it to the pojo:

TestItem dataSource = new TestItem();
FieldGroup fieldGroup = new FieldGroup();
fieldGroup.setItemDataSource(new BeanItem<Object>(dataSource));
IntStepper testStepper = new IntStepper();
fieldGroup.bind(testStepper, "testValue");
layout.addComponent(testStepper);

Start server, attempt to enter '100' (gets replaced with '10'), attempt to enter '100' again (stays).
If the field isn't bound or the pojo doesn't have a default value even the first manual setting works.

Configuring the Granularity of Value Change Events

Since Vaadin 8 migration, if I use a Stepper (manual input allowed) in a window with a button and a key shortcut, when the user set a value manually and use the shortcut to validate, the stepper value is wrong (initial value).

Could it be possible to have a "ValueChangeMode" like TextField component to control this behavior ? Or any other way to achieve this ?
There may be a workaround I did not find ?

The current behavior seems to correspond to the "ValueChangeMode.BLUR" and I'm looking for the "ValueChangeMode.EAGER". I think the "setImmediate" method did the trick before migration.

Here is an example to illustrate the issue:

public class StepperDialog {
    private final UI parentWindow;
    private final Window stepperWindow;
    private IntStepper stepper;

    public StepperDialog(UI parentWindow) {
        this.parentWindow = parentWindow;
        this.stepperWindow = createWindow();
    }

    public void show() {
        parentWindow.addWindow(stepperWindow);
        stepper.focus();
    }

    private void hide() {
        parentWindow.removeWindow(stepperWindow);
    }

    private Window createWindow() {
        // Create window
        Window window = new Window("StepperDialog");
        window.setModal(true);
        window.setWidth("250px");
        window.setHeight("175px");

        // Root window layout
        VerticalLayout rootLayout = new VerticalLayout();
        window.setContent(rootLayout);

        // Add basic Integer stepper
        stepper = new IntStepper("Stepper");
        stepper.setMinValue(1);
        stepper.setValue(1);
        rootLayout.addComponent(stepper);

        // Add ok and cancel buttons with shortcut
        Button okButton = new Button("OK", event -> validate());
        Button cancelButton = new Button("CANCEL", event -> hide());
        okButton.setClickShortcut(ShortcutAction.KeyCode.ENTER);
        cancelButton.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
        HorizontalLayout buttons = new HorizontalLayout(okButton, cancelButton);
        rootLayout.addComponent(buttons);

        return window;
    }

    private void validate() {
        Integer value = stepper.getValue();
        System.out.println("value=" + value);
        /**
         * Here, the value is correct if the user click on button and incorrect
         * if he uses the "ENTER" key shortcut.
         */
        hide();
    }

}

IE 10 does not load widgetset containing stepper2.1

As soon as my self compiled widgetset contains the stepper add on, my vaadin application no longer loads in internet explorer (10).

The relevant error as seen in the IE dev console is ".../VAADIN/widgetsets/....Widgetset/undefined.cache.js GET 404",
that means, it tries to fetch an "undefined" cache.js, which of course is unavailable.

Changing the 'user agent" setting for my widgetset to include ie10 did not help, and the error disappears as soon as i remove stepper from the class path.

Loading the same URL from chrome or firefox works fine.

set(Min | Max)Value(xx) resets the textBox value to some old value.

  • Update value for one box
  • Update value for second box
    • First box gets old value even though shouldn't update
package com.example.failing_steps;

import javax.servlet.annotation.WebServlet;

import org.vaadin.risto.stepper.IntStepper;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
@Theme("failing_steps")
public class Failing_stepsUI extends UI {

    @WebServlet(value = "/*", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = Failing_stepsUI.class, widgetset = "com.example.failing_steps.widgetset.Failing_stepsWidgetset")
    public static class Servlet extends VaadinServlet {
    }

    private VerticalLayout layout;

    @Override
    protected void init(VaadinRequest request) {
        layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);

        final IntStepper min = new IntStepper();
        min.setValue(2);
        min.setStepAmount(1);
        min.setImmediate(true);

        final IntStepper max = new IntStepper();
        max.setValue(30);
        max.setStepAmount(1);
        max.setImmediate(true);

        ValueChangeListener minChangeListener = new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {

                Integer minValue = (Integer) min.getValue();
                max.setMinValue(minValue + 1);
            }
        };

        ValueChangeListener maxChangeListener = new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                Integer maxValue = (Integer) max.getValue();
                min.setMinValue(maxValue + 1);
            }
        };
        min.addValueChangeListener(minChangeListener);
        max.addValueChangeListener(maxChangeListener);

        layout.addComponent(max);
        layout.addComponent(min);
    }

    private void addText(String text) {
        layout.addComponent(new Label(text));
    }
}

Enable stepping acceleration

When the user pushed arrow down and keeps it pushed, the values change at a set pace (150ms). The value change should accelerate over time for better usability.

Unable to decrease float stepper

I have Steppers in a table as follow:

Table options = new Table();
        options.addContainerProperty(Tool.translate("general.name"),
                String.class, null);
        options.addContainerProperty(Tool.translate("level.name"),
                FloatStepper.class, null);
       ...
                FloatStepper stepper = new FloatStepper();
                stepper.setManualInputAllowed(false);
                stepper.setMinValue(0F);
                stepper.setStepAmount(0.5F);
                stepper.setMouseWheelEnabled(false);
                stepper.setImmediate(true);
                stepper.addValueChangeListener(listener -> {
                });
                options.addItem(new Object[]{Tool.translate(skill.getName()),
                    stepper}, skill.getName());
     ...

They display well but don't behave as expected:

  • Steps are in 1.0F increments instead of the 0.5F configured.
  • The down arrow doesn't decrease the stepper.

Event reaches server only on page refresh

While the widget steps through the values correctly and shows it on the client the event listener which is registered to the widget never receives the event. On page refresh the event reaches the server side for handling it and showing the result (for example a notification). The event needs to go to the server side event listener right away and behave exactly the same way as vaadin's own widgets/

Stepper doesn't update the client side value after server round trip.

package com.example.failing_steps;

import javax.servlet.annotation.WebServlet;
Clicking the up arrow and having the server change the value back down leaves the wrong value on the client side.
Client side value does change when the user types a value into the field that is too "large"

import org.vaadin.risto.stepper.IntStepper;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings("serial")
@Theme("failing_steps")
public class Failing_stepsUI extends UI {

    @WebServlet(value = "/*", asyncSupported = true)
    @VaadinServletConfiguration(productionMode = false, ui = Failing_stepsUI.class, widgetset = "com.example.failing_steps.widgetset.Failing_stepsWidgetset")
    public static class Servlet extends VaadinServlet {
    }

    private VerticalLayout layout;

    @Override
    protected void init(VaadinRequest request) {
        layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);

        final IntStepper stepper = new IntStepper();
        stepper.setValue(2);
        stepper.setMinValue(1);
        stepper.setStepAmount(1);
        stepper.setWidth("45px");
        stepper.setImmediate(true);

        stepper.addValueChangeListener(new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                if (stepper.getValue() >= 3) {
                    addText("Value is " + stepper.getValue());
                    stepper.setValue(2);
                    addText("Set value to " + stepper.getValue());
                }
            }
        });
        layout.addComponent(stepper);
    }

    private void addText(String text){
        layout.addComponent(new Label(text));
    }
}

Exception Occurs when the stepper is attached to a valuechangeevent

I created a vaadin table where one of the columns have the intstepper control on it. On value change by way of clicking on the up or the down icon I get an exception message.

java.lang.IllegalArgumentException: The server RPC interface org.vaadin.risto.stepper.widgetset.client.StepperRpc could not be found
at com.vaadin.terminal.gwt.server.ServerRpcMethodInvocation.findClass(ServerRpcMethodInvocation.java:52)
at com.vaadin.terminal.gwt.server.ServerRpcMethodInvocation.(ServerRpcMethodInvocation.java:38)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.parseServerRpcInvocation(AbstractCommunicationManager.java:1808)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.parseInvocation(AbstractCommunicationManager.java:1772)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.parseInvocations(AbstractCommunicationManager.java:1740)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleBurst(AbstractCommunicationManager.java:1598)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1543)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleUidlRequest(AbstractCommunicationManager.java:577)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:461)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:350)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
at org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
at org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
at org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.felix.http.proxy.ProxyServlet.service(ProxyServlet.java:60)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: org.vaadin.risto.stepper.widgetset.client.StepperRpc
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.vaadin.terminal.gwt.server.ServerRpcMethodInvocation.findClass(ServerRpcMethodInvocation.java:45)
... 37 more

Using IntStepper with Vaadin Wizards

Good morning.

I'm new at Vaadin and I'm implementin a webapp. I've recently discovered the Wizards and your Stepper plugins, and I want to use them in conjunction: Within a WizardStep, I wanna place some Steppers, IntStepper for the time being.

The stepper seem to be working fine, but whenever I press an Up or Down arrow, an exception is thrown:


mar 04, 2015 11:18:36 AM com.vaadin.server.DefaultErrorHandler doDefault
GRAVE:
java.lang.NoSuchMethodError: com.vaadin.ui.ConnectorTracker.getDiffState(Lcom/vaadin/server/ClientConnector;)Lorg/json/JSONObject;
at org.vaadin.risto.stepper.AbstractStepper$1.valueChange(AbstractStepper.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:291)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:184)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:92)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1408)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:350)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Unknown Source)

Initially I thought that org.json jar was needed, so I added it to my ivy.xml file. Afterwards, I removed that dependency as there wasn't any change/improvement or difference between using it or not using it. EDIT: I need org.json package, as Vaadin threw me an exception during initialisation so as to load existing persisted session.

This is my source code:

package com.ingartek.cavwebapp.view.administrador;

import java.io.Serializable;

import org.vaadin.risto.stepper.IntStepper;
import org.vaadin.teemu.wizards.WizardStep;

import com.ingartek.cavwebapp.model.Conductor;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.VerticalLayout;

public class WizardStep1 implements WizardStep, Serializable {

private static final long serialVersionUID = 79251609422893709L;

@Override
public String getCaption() {
    return "Parámetros";
}

@Override
public Component getContent() {

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);

    final IntStepper maxTravelTime = new IntStepper();
    maxTravelTime.setCaption("Tiempo máx. de viaje");
    maxTravelTime.setDescription("Representa el tiempo máximo de viaje de un trabajador.");
    maxTravelTime.setValue(1);
    maxTravelTime.setStepAmount(1);
    maxTravelTime.setMaxValue(100);
    maxTravelTime.setMinValue(1);
    maxTravelTime.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = -5342847264866656960L;

        @Override
        public void valueChange(ValueChangeEvent event) {

            Integer value = (Integer) event.getProperty().getValue();
            System.out.println("Valor nuevo maxTravelTime: " + value);

        }

    });

    final IntStepper maxPickupTime = new IntStepper();
    maxPickupTime.setCaption("Tiempo máx. de recogida de trabajadores");
    maxPickupTime.setDescription("Representa el tiempo máximo desde que se recoge a un trabajador hasta que se recoge al siguiente.");
    maxPickupTime.setValue(1);
    maxPickupTime.setStepAmount(1);
    maxPickupTime.setMaxValue(100);
    maxPickupTime.setMinValue(1);
    maxPickupTime.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = -5342847264866656960L;

        @Override
        public void valueChange(ValueChangeEvent event) {

            Integer value = (Integer) event.getProperty().getValue();
            System.out.println("Valor nuevo maxPickupTime: " + value);

        }

    });

    final IntStepper maxWaitTime = new IntStepper();
    maxWaitTime.setCaption("Tiempo máx. de espera");
    maxWaitTime.setDescription("Representa el tiempo máximo de espera de un trabajador, desde que le dejan en cocheras hasta que empieza a trabajar.");
    maxWaitTime.setValue(1);
    maxWaitTime.setStepAmount(1);
    maxWaitTime.setMaxValue(100);
    maxWaitTime.setMinValue(1);
    maxWaitTime.addValueChangeListener(new ValueChangeListener() {

        private static final long serialVersionUID = -5342847264866656960L;

        @Override
        public void valueChange(ValueChangeEvent event) {

            Integer value = (Integer) event.getProperty().getValue();
            System.out.println("Valor nuevo maxWaitTime: " + value);

        }

    });

    layout.addComponent(maxTravelTime);
    layout.addComponent(maxPickupTime);
    layout.addComponent(maxWaitTime);

    return layout;

}

@Override
public boolean onAdvance() {
    // TODO Auto-generated method stub
    return false;
}

@Override
public boolean onBack() {
    // TODO Auto-generated method stub
    return false;
}

public static long getSerialversionuid() {
    return serialVersionUID;
}

@Override
public boolean equals(Object other) {

    if(other==null)
        return false;

    if( !(other instanceof Conductor) )
        return false;

    return true;

}

@Override
public int hashCode() {

    return (int) serialVersionUID;
}

}

Any suggestion?

Thank you for your contribution!

Client-side update issue

Thanks for your cool Stepper component. I think they are really useful.
Now I found an issue when programmatically updating the IntStepper component. Here is the code for checking that:

    final IntStepper intStepper = new IntStepper("testIntStepper");
    addComponent(intStepper);
    intStepper.setImmediate(true);
    intStepper.setValue(4);
    intStepper.addValueChangeListener(new ValueChangeListener() {
          private static final long serialVersionUID = 1L;
          @Override
          public void valueChange(ValueChangeEvent event)
          {
            int value = (Integer) event.getProperty().getValue();
            if (value >= 5)
            {
              intStepper.setValue(4);
            }
          }
        });

This is a simplified example and shall do the following: If the value is set above 4 is shall be set back to this max. value. (In reality the behaviour is more complex.) While this works properly when entering the value by keyboard it does not work when pressing the 'up' button with your mouse: The value can be increased unbounded.

I think I found out what the problem is:

  • UpDownControls.onClick calls stepper.increaseValue()
  • VAbstractStepper:
    public void increaseValue() {
        String oldValue = textBox.getValue();

        if (isChangeable() && isValidForType(oldValue)) {
            try {
                String newValue = getIncreasedValue(oldValue);
                if (isSmallerThanMax(newValue)) {
                    textBox.setValue(newValue);

                    valueUpdateTimer.schedule(updateDelay);
                    valueUpdateTimer.setValue(newValue);
                }
            } catch (Exception e) {
                valueUpdateTimer.cancel();
                GWT.log("Exception when increasing value", e);
            }
        }
    }
  • calls valueUpdateTimer.setValue and when timeout elapses:
    @Override
    public void run() {
        stepper.updateValueToServer(value);
    }
  • VAbstractStepper.updateValueToServer is called which just calls fireEvent
    public void updateValueToServer(String newValue) {
        fireEvent(new StepperValueChangeEvent(newValue));
    }
  • The event is propagated to the server where my listener calls intStepper.setValue(4);
  • This value is sent to the connector which calls then
getWidget().setValue(getState().value);
  • Now, VAbstractStepper.setValue checks in isValueValid for a real value difference (!safeEquals):
    public void setValue(String newValue) {
        if (isValueValid(newValue)) {
            textBox.setValue(newValue);
            this.value = newValue;
        }
    }

(My assumption:) Since both values are identical the UI does not get updated. Hence the value reset implemented in my listener gets lost.
The problem is, that the value did not get updated when calling fireEvent!
The fix is rather simple: Just update the 'value' member in the updateValueToServer method.

Add support for custom date format

Hi,

it would be great if we could define a custom date format for the DateStepper (ex: yyyy-MM-dd) because actually it uses only DateFormat.SHORT.

Thanks,

Daniel

Add client-side input filtering

When creating an IntStepper one would expect that the user is only able to input digit characters, however, it is possible to enter any character, even alphabetic chars.

The Stepper should check the input on the client side and only allow valid chars to be entered.

Declarative format support

Hi
The declarative format binding fails because of java type erasure, since all steppers are generic classes.
Vaadin tries to invoke setter by type, but because of java type erasure it finds Object instead of actual Integer/BigDecimal/Float type and then passes String to
setMinValue,setMaxValue and setStepAmount methods.

Would you please format the value (if ti's String) passed to each generic method to actual type ?
Thanks.

Here is the my usage of declarative format with stepper field :

<!DOCTYPE html>
<html>
<head lang="en">
    <meta name="package-mapping" content="stepper:org.vaadin.risto.stepper"/>
</head>
<body>
<v-form-layout>
    <stepper-int-stepper id="maxResults" caption="Max number of results"
                         max-value="500"
                         min-value="10"
                         invalid-allowed="false"
                         required="true"
                         null-value-allowed="false"
                         step-amount="10"/>

</v-form-layout>


</body>
</html>

Format for FloatStepper

Hi guys,

First of all: thanks for all the work you've done!

It would be nice to be able to set the decimal format of the FloatStepper, basically like with the DateStepper.

I could work on that, but I had some trouble importing the project in Intellij Idea (related to Gradle). If you could provide some hints about which IDE and settings you're using, I'll retry.

Kind regards,
Markus

Valo support ?

Support for consistent styling under Valo with reference to $v-font-size & $v-line-height

Stepping continues when loosing focus

  1. Click in a Stepper field
  2. Hold UP
  3. Click out of the field, while still holding UP

Expected: Stepper stops counting up numbers
Actual: Stepper continues until field gets focused again and UP or DOWN is pressed

Misplaced custom icons

I've used the setIncreaseIcon() and setDecreaseIcon() methods to change default icons that way:

maxTravelTime.setWidth(65, Unit.PERCENTAGE); maxTravelTime.setIncreaseIcon(FontAwesome.CHEVRON_UP); maxTravelTime.setDecreaseIcon(FontAwesome.CHEVRON_DOWN);

But, the desired view isn't desired, as icons are shown in the following line:

stepper1

It should be displayed that way:

stepper2

Don't you think so?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.