use of com.googlecode.gwt.test.internal.utils.PropertyContainer in project gwt-test-utils by gwt-test-utils.
the class JavaScriptObjectPatcher method elementToString.
private static String elementToString(Element elem) {
String tagName = JsoUtils.isXmlElement(elem) ? elem.getTagName() : elem.getTagName().toLowerCase();
// handle the particular case of <br> element
if ("br".equals(tagName)) {
return "<br>" + elem.getInnerText();
}
StringBuilder sb = new StringBuilder();
sb.append("<").append(tagName).append(" ");
PropertyContainer attrs = JsoUtils.getDomProperties(elem);
for (Map.Entry<String, Object> entry : attrs.entrySet()) {
// string attribute if the DOM element is disabled
if ("disabled".equals(entry.getKey())) {
Boolean disabled = (Boolean) entry.getValue();
if (disabled.booleanValue()) {
sb.append(entry.getKey()).append("=\"\" ");
}
} else if ("className".equals(entry.getKey())) {
// special treatment for "className", which is mapped with DOM
// standard
// property "class"
sb.append("class=\"").append(entry.getValue()).append("\" ");
} else if ("style".equals(entry.getKey())) {
String style = elem.getStyle().toString();
if (!"".equals(style)) {
sb.append("style=\"").append(elem.getStyle().toString()).append("\" ");
}
} else {
sb.append(entry.getKey()).append("=\"").append(entry.getValue()).append("\" ");
}
}
// remove the last space character
sb.replace(sb.length() - 1, sb.length(), "");
String innerHtml = elem.getInnerHTML();
if (JsoUtils.isXmlElement(elem) && innerHtml.trim().length() == 0) {
sb.append("/>");
} else {
sb.append(">").append(elem.getInnerHTML());
sb.append("</").append(tagName).append(">");
}
return sb.toString();
}
use of com.googlecode.gwt.test.internal.utils.PropertyContainer in project gwt-test-utils by gwt-test-utils.
the class JavaScriptObjects method getJsoProperties.
private static PropertyContainer getJsoProperties(JavaScriptObject o) {
PropertyContainer pc = GwtReflectionUtils.getPrivateFieldValue(o, JsoProperties.JSO_PROPERTIES);
if (pc == null) {
pc = PropertyContainer.newInstance(new HashMap<String, Object>());
GwtReflectionUtils.setPrivateFieldValue(o, JsoProperties.JSO_PROPERTIES, pc);
}
return pc;
}
use of com.googlecode.gwt.test.internal.utils.PropertyContainer in project gwt-test-utils by gwt-test-utils.
the class XMLParserImplPatcher method setAttribute.
@PatchMethod
static void setAttribute(JavaScriptObject o, String name, String value) {
PropertyContainer properties = JsoUtils.getDomProperties(o.<Element>cast());
properties.put(name, value);
}
Aggregations