package com.extjs.selenium.form;

import com.sdl.selenium.web.WebLocator;
import org.apache.log4j.Logger;

public class DisplayField extends TextField {
    private static final Logger logger = Logger.getLogger(DisplayField.class);

    public DisplayField() {
        setClassName("DisplayField");
        setBaseCls("x-form-display-field");
    }

    public DisplayField(WebLocator container) {
        this();
        setContainer(container);
    }

    public DisplayField(WebLocator container, String label) {
        this(container);
        setLabel(label);
    }

    public DisplayField(String name, WebLocator container) {
        this(container);
        setName(name);
    }

    public String getItemPath(boolean disabled) {
        String selector = getBasePathSelector();
        if(selector != null && selector.length() > 0){
            selector = "//*["+ selector +"]";
        } else {
            selector = "//*";
        }
        return selector;
    }

    public boolean setValue(String value) {
        // TODO find better way (maybe extending Field not text field directly)
        logger.warn("can't set Value in display field");
        return false;
    }


    public String getValue() {
        String value = "";
        if(ready()){
            value = getHtmlText();
        } else {
            logger.warn("getValue : field is not ready for use: " + toString());
        }
        return value;
    }
}

@@ -25,17 +25,19 @@
 um.form;
-%0A
+%0D%0A%0D
 %0Aimport 
@@ -68,16 +68,17 @@
 Locator;
+%0D
 %0Aimport 
@@ -101,17 +101,19 @@
 .Logger;
-%0A
+%0D%0A%0D
 %0Apublic 
@@ -150,16 +150,17 @@
 tField %7B
+%0D
 %0A    pri
@@ -230,17 +230,19 @@
 .class);
-%0A
+%0D%0A%0D
 %0A    pub
@@ -257,24 +257,25 @@
 layField() %7B
+%0D
 %0A        set
@@ -296,24 +296,25 @@
 playField%22);
+%0D
 %0A        set
@@ -345,23 +345,48 @@
 field%22);
+%0D%0A        setTag(%22*%22);%0D
 %0A    %7D
-%0A
+%0D%0A%0D
 %0A    pub
@@ -417,32 +417,33 @@
 tor container) %7B
+%0D
 %0A        this();
@@ -442,16 +442,17 @@
  this();
+%0D
 %0A       
@@ -476,23 +476,26 @@
 tainer);
+%0D
 %0A    %7D
-%0A
+%0D%0A%0D
 %0A    pub
@@ -548,16 +548,17 @@
 label) %7B
+%0D
 %0A       
@@ -566,32 +566,33 @@
 this(container);
+%0D
 %0A        setLabe
@@ -600,23 +600,26 @@
 (label);
+%0D
 %0A    %7D
-%0A
+%0D%0A%0D
 %0A    pub
@@ -671,16 +671,17 @@
 ainer) %7B
+%0D
 %0A       
@@ -697,16 +697,17 @@
 tainer);
+%0D
 %0A       
@@ -725,304 +725,18 @@
 me);
-%0A    %7D%0A%0A    public String getItemPath(boolean disabled) %7B%0A        String selector = getBasePathSelector();%0A        if(selector != null && selector.length() %3E 0)%7B%0A            selector = %22//*%5B%22+ selector +%22%5D%22;%0A        %7D else %7B%0A            selector = %22//*%22;%0A        %7D%0A        return selector;%0A    %7D%0A
+%0D%0A    %7D%0D%0A%0D
 %0A   
@@ -775,16 +775,17 @@
 value) %7B
+%0D
 %0A       
@@ -856,16 +856,17 @@
 irectly)
+%0D
 %0A       
@@ -914,16 +914,17 @@
 field%22);
+%0D
 %0A       
@@ -941,16 +941,20 @@
 lse;
+%0D
 %0A    %7D
-%0A%0A
+%0D%0A%0D%0A%0D
 %0A   
@@ -980,16 +980,17 @@
 alue() %7B
+%0D
 %0A       
@@ -1008,16 +1008,17 @@
 ue = %22%22;
+%0D
 %0A       
@@ -1030,16 +1030,17 @@
 eady())%7B
+%0D
 %0A       
@@ -1066,16 +1066,17 @@
 lText();
+%0D
 %0A       
@@ -1084,16 +1084,17 @@
 %7D else %7B
+%0D
 %0A       
@@ -1166,16 +1166,17 @@
 ring());
+%0D
 %0A       
@@ -1177,16 +1177,17 @@
        %7D
+%0D
 %0A       
@@ -1204,13 +1204,16 @@
 lue;
+%0D
 %0A    %7D
+%0D
 %0A%7D
+%0D
 %0A

add tag in DeployTesty