All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dragome.forms.bindings.client.binding.TransitionBindingBuilder Maven / Gradle / Ivy

There is a newer version: 0.96-beta4
Show newest version
package com.dragome.forms.bindings.client.binding;

import com.dragome.forms.bindings.client.value.ValueModel;
import com.dragome.forms.bindings.extra.user.client.Command;

/**
 * Created by IntelliJ IDEA.
 * User: andrew
 * Date: Apr 13, 2010
 * Time: 12:19:55 PM
 * To change this template use File | Settings | File Templates.
 */
public class TransitionBindingBuilder
{
	private BindingContainer bindingContainer;
	private ValueModel model;

	public TransitionBindingBuilder(BindingContainer bindingContainer, ValueModel model)
	{
		this.bindingContainer= bindingContainer;
		this.model= model;
	}

	public CommandBinder to(T triggerValue)
	{
		return new CommandBinder(new TransitionToBinding(triggerValue, model.getValue()));
	}

	public CommandBinder from(T triggerValue)
	{
		return new CommandBinder(new TransitionFromBinding(triggerValue, model.getValue()));
	}

	public class CommandBinder
	{
		private TransitionBindingSupport binding;

		public CommandBinder(TransitionBindingSupport binding)
		{
			this.binding= binding;
		}

		public void invoke(Command command)
		{
			binding.setCommand(command);
			bindingContainer.registerDisposable(model.addValueChangeHandler(binding));
		}

	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy