package com.sdl.bootstrap.button;

import com.sdl.selenium.web.SearchType;
import com.sdl.selenium.web.WebLocator;
import com.sdl.selenium.web.button.IButton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Button extends WebLocator implements IButton {
    private static final Logger logger = LoggerFactory.getLogger(Button.class);

    private String iconCls;

    public String getIconCls() {
        return iconCls;
    }

    public <T extends Button> T setIconCls(final String iconCls) {
        this.iconCls = iconCls;
        String key = "icon-cls";
        setElPathSuffix(key, applyTemplate(key, iconCls));
        return (T) this;
    }

    public Button() {
        setClassName("Button");
        setBaseCls("btn");
        setTag("button");
        setTemplate("icon-cls", "count(.//*[contains(@class, '%s')]) > 0");
    }

    /**
     * @param container
     */
    public Button(WebLocator container) {
        this();
        setContainer(container);
    }

    public Button(WebLocator container, String text) {
        this(container);
        setText(text);
        setSearchTextType(SearchType.EQUALS);
    }

    public boolean isDisabled() {
        String cls = getAttributeClass();
        return (cls != null && cls.contains("disabled")) || getAttribute("disabled") != null;
    }
}
@@ -218,16 +218,145 @@
 ory;%0D%0A%0D%0A
+/**%0D%0A * %3Cbutton class=%22btn%22 type=%22button%22%3ESave%3C/button%3E%0D%0A * new Button(container, %22Save%22) or new Button().setText(%22Save%22);%0D%0A */%0D%0A
 public c
@@ -1317,32 +1317,424 @@
 ALS);%0D%0A    %7D%0D%0A%0D%0A
+    /**%0D%0A     * %3Cbutton class=%22btn%22 type=%22button%22 disabled%3EDisableBtn%3C/button%3E%0D%0A     * or %3Cbutton class=%22btn disabled%22 type=%22button%22%3EDisableBtnCls%3C/button%3E%0D%0A     *%0D%0A     * Example: Button disableButton = new Button().setText(%22DisableBtn%22);%0D%0A     *          disableButton.isDisabled();%0D%0A     *%0D%0A     * @return true if element has attribute disabled or class disabled otherwise false%0D%0A     */%0D%0A
     public boole

add documentation Button