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;

/**
 * <button class="btn" type="button">Save</button>
 * new Button(container, "Save") or new Button().setText("Save");
 */
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);
    }

    /**
     * <button class="btn" type="button" disabled>DisableBtn</button>
     * or <button class="btn disabled" type="button">DisableBtnCls</button>
     *
     * Example: Button disableButton = new Button().setText("DisableBtn");
     *          disableButton.isDisabled();
     *
     * @return true if element has attribute disabled or class disabled otherwise false
     */
    public boolean isDisabled() {
        String cls = getAttributeClass();
        return (cls != null && cls.contains("disabled")) || getAttribute("disabled") != null;
    }
}
@@ -231,58 +231,254 @@
  * %3C
-button class=%22btn%22 type=%22button%22%3ESave%3C/button%3E%0D%0A *
+p%3E%3Cb%3E%3Ci%3EUsed for finding element process (to generate xpath address)%3C/i%3E%3Cb%3E%3C/p%3E%0D%0A * %3Cp%3EExample:%3C/p%3E%0D%0A * %3Cpre%3E%0D%0A * %7B@code%0D%0A *  %3Cbutton class=%22btn%22 type=%22button%22%3ESave%3C/button%3E%0D%0A *%7D%0D%0A * %3C/pre%3E%0D%0A * %3Cp%3EIn Java write this:%3C/p%3E%0D%0A * %3Cpre%3E%0D%0A * %7B@code%0D%0A * 
  new
@@ -538,16 +538,34 @@
 ave%22);%0D%0A
+ *  %7D%0D%0A * %3C/pre%3E%0D%0A
  */%0D%0Apub
@@ -1555,16 +1555,48 @@
 %0A     * 
+%3Cpre%3E%0D%0A     *     %7B@code%0D%0A     *
 %3Cbutton 
@@ -1658,18 +1658,25 @@
 %0A     * 
-or
+         
  %3Cbutton
@@ -1731,24 +1731,49 @@
 s%3C/button%3E%0D%0A
+     * %7D%0D%0A     * %3C/pre%3E%0D%0A
      *%0D%0A    
@@ -1775,24 +1775,27 @@
 %0A     * 
+%3Cp%3E
 Example:
  Button 
@@ -1786,16 +1786,61 @@
 Example:
+%3C/p%3E%0D%0A     * %3Cpre%3E%0D%0A     *     %7B@code%0D%0A     *
  Button 
@@ -1908,16 +1908,18 @@
         
+  
 disableB
@@ -1937,32 +1937,49 @@
 abled();%0D%0A     *
+ %7D%0D%0A     * %3C/pre%3E
 %0D%0A     * @return

fix documentation Button