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

com.jwebmp.plugins.bootstrap.spinner.BSNumberSpinner Maven / Gradle / Ivy

There is a newer version: 0.66.0.1
Show newest version
package com.jwebmp.plugins.bootstrap.spinner;

import com.jwebmp.core.base.html.Button;
import com.jwebmp.core.base.html.Span;
import com.jwebmp.plugins.bootstrap.forms.controls.BSFormNumberInput;
import com.jwebmp.plugins.bootstrap.forms.groups.sets.BSComponentInputGroupOptions;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class BSNumberSpinner>
		extends BSFormNumberInput
{
	private List before = new ArrayList<>();
	private List after = new ArrayList<>();

	/**
	 * Constructs a number spinner
	 */
	public BSNumberSpinner()
	{
		addClass("number-spinner");

		Span lower = new Span();
		lower.addClass("input_group_btn");
		Button lowerButton = new Button();
		lowerButton.addClass("btn btn-default");
		Span lowerIcon = new Span();
		lowerIcon.addClass("fa fa-angle-down");

		lower.add(lowerButton);
		lowerButton.add(lowerIcon);
		lowerButton.addAttribute("data-dir", "dwn");
		before.add(lower);

		Span upper = new Span();
		upper.addClass("input_group_btn");
		Button upperButton = new Button();
		upperButton.addClass("btn btn-default");
		upperButton.addAttribute("data-dir", "up");
		Span upperIcon = new Span();
		upperIcon.addClass("fa fa-angle-up");

		upper.add(upperButton);
		upperButton.add(upperIcon);
		after.add(upper);

	}

	@Override
	public void init()
	{
		if (!isInitialized())
		{
			for (Span addon : getBefore())
			{
				addon.addClass(BSComponentInputGroupOptions.Input_Group_Addon);
				getParent().add(addon);
			}
			for (Span addon : getBefore())
			{
				addon.addClass(BSComponentInputGroupOptions.Input_Group_Addon);
				getParent().add(addon);
			}
		}
		super.init();
	}

	/**
	 * Returns this before list
	 *
	 * @return
	 */
	public List getBefore()
	{
		return before;
	}

	/**
	 * Sets the before list of spans
	 *
	 * @param before
	 *
	 * @return
	 */
	public J setBefore(List before)
	{
		this.before = before;
		return (J) this;
	}

	@Override
	public boolean equals(Object o)
	{
		if (this == o)
		{
			return true;
		}
		if (!(o instanceof BSNumberSpinner))
		{
			return false;
		}
		if (!super.equals(o))
		{
			return false;
		}
		BSNumberSpinner that = (BSNumberSpinner) o;
		return Objects.equals(getBefore(), that.getBefore()) && Objects.equals(getAfter(), that.getAfter());
	}

	@Override
	public int hashCode()
	{
		return Objects.hash(super.hashCode(), getBefore(), getAfter());
	}

	/**
	 * Returns the after span list
	 *
	 * @return
	 */
	public List getAfter()
	{
		return after;
	}

	/**
	 * Sets the after list
	 *
	 * @param after
	 *
	 * @return
	 */
	public J setAfter(List after)
	{
		this.after = after;
		return (J) this;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy