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;

/**
 * <p><b><i>Used for finding element process (to generate xpath address)</i><b></p>
 * <p>Example:</p>
 * <pre>
 * {@code
 *  <button class="btn" type="button">Save</button>
 *}
 * </pre>
 * <p>In Java write this:</p>
 * <pre>
 * {@code
 *  new Button(container, "Save") or new Button().setText("Save");
 *  }
 * </pre>
 */
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);
    }

    /**
     * <pre>
     *     {@code
     *<button class="btn" type="button" disabled>DisableBtn</button>
     *           <button class="btn disabled" type="button">DisableBtnCls</button>
     * }
     * </pre>
     *
     * <p>Example:</p>
     * <pre>
     *     {@code
     * Button disableButton = new Button().setText("DisableBtn");
     *            disableButton.isDisabled();
     * }
     * </pre>
     * @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;
    }
}
@@ -1251,24 +1251,445 @@
   * 
-@param container
+%3Cpre%3E%0D%0A     * %7B@code%0D%0A     * %3Cform class=%22panel%22%3E%0D%0A     *          %3Cbutton class=%22btn%22 type=%22button%22%3ESave%3C/button%3E%0D%0A     *        %3C/form%3E%0D%0A     * %7D%0D%0A     * %3C/pre%3E%0D%0A     * %3Cp%3EIn Java appears like this:%3C/p%3E%0D%0A     * %3Cpre%3E%0D%0A     * %7B@code%0D%0A     * Form panelForm = new Form().setClasses(%22panel%22);%0D%0A     *        Button saveButton = new Button(panelForm);%0D%0A     * %7D%0D%0A     * %3C/pre%3E%0D%0A     * @param container is component which contains the button
 %0D%0A  

fix documentation Button