installTableEditors((TableItem) targetObject);
}
// x:DataContext
if (loadData.getDataContext() == null) {
Attribute dataContextAttribute = element
.getAttribute(IConstants.XAML_DATA_CONTEXT);
if (dataContextAttribute != null) {
IProperty property = metaclass
.findProperty(IConstants.XAML_DATA_CONTEXT);
Widget composite = (Widget) UserData.getWidget(targetObject);
DocumentObject documentObject = dataContextAttribute
.getChildren()[0];
if (IConstants.XAML_STATICRESOURCES.equals(documentObject
.getName())
|| IConstants.XAML_DYNAMICRESOURCES
.equals(documentObject.getName())) {
String key = documentObject.getContent();
property.setValue(composite, new StaticResourceBinding(
composite, key));
} else if (IConstants.XAML_BINDING.equals(documentObject
.getName())) {
Object object = doCreate(targetObject,
(Element) documentObject, null, EMPTY_MAP);
property.setValue(composite, object);
} else {
LoggerManager.log(new UnsupportedOperationException(
documentObject.getName()));
}
}
}
HashSet<String> done = new HashSet<String>();
Attribute nameAttr = element.getAttribute(IConstants.XAML_X_NAME);
if (nameAttr == null) {
nameAttr = element.getAttribute(IConstants.XWT_X_NAMESPACE,
IConstants.XAML_X_NAME);
}
if (nameAttr != null && UserData.getWidget(targetObject) != null) {
String value = nameAttr.getContent();
loadData.inject(targetObject, value);
nameScoped.addNamedObject(value, targetObject);
done.add(IConstants.XAML_X_NAME);
}
for (String attrName : element.attributeNames()) {
if (IConstants.XWT_X_NAMESPACE.equals(element
.getAttribute(attrName).getNamespace())) {
continue;
} else if (delayedAttributes != null
&& isDelayedProperty(attrName.toLowerCase(), metaclass
.getType()))
delayedAttributes.add(attrName);
else {
if (!done.contains(attrName)) {
initAttribute(metaclass, targetObject, element, null,
attrName);
done.add(attrName);
}
}
}
for (String namespace : element.attributeNamespaces()) {
if (IConstants.XWT_X_NAMESPACE.equals(namespace)) {
for (String attrName : element.attributeNames(namespace)) {
if ("class".equalsIgnoreCase(attrName)
|| IConstants.XAML_STYLE.equalsIgnoreCase(attrName)) {
continue; // done before
} else if (IConstants.XAML_X_NAME
.equalsIgnoreCase(attrName)) {
nameScoped
.addNamedObject(element.getAttribute(namespace,
attrName).getContent(), targetObject);
done.add(attrName);
} else if (IConstants.XAML_DATA_CONTEXT
.equalsIgnoreCase(attrName)) {
continue; // done before
} else if (IConstants.XAML_X_ARRAY
.equalsIgnoreCase(attrName)) {
IProperty property = metaclass.findProperty(attrName);
Class<?> type = property.getType();
Object value = getArrayProperty(type, targetObject,
element, attrName);
if (value != null) {
property.setValue(targetObject, value);
}
} else if (IConstants.XAML_RESOURCES
.equalsIgnoreCase(attrName)) {
continue;
} else {
if (!done.contains(attrName)) {
initAttribute(metaclass, targetObject, element,
namespace, attrName);
done.add(attrName);
}
}
}
continue;
}
for (String attrName : element.attributeNames(namespace)) {
if (IConstants.XAML_X_NAME.equalsIgnoreCase(attrName)
&& (targetObject instanceof Widget)) {
continue;
}
if (!done.contains(attrName)) {
initAttribute(metaclass, targetObject, element, namespace,
attrName);
done.add(attrName);
}
}
}
for (String attrName : element.attributeNames()) {
if (IConstants.XAML_X_NAME.equalsIgnoreCase(attrName)
&& UserData.getWidget(targetObject) != null) {
continue;
}
if (!done.contains(attrName)
&& !delayedAttributes.contains(attrName)) {
initAttribute(metaclass, targetObject, element, null, attrName);
done.add(attrName);
}
}
//
// handle foreigner namespace
//
for (String namespace : element.attributeNamespaces()) {
if (XWT.isXWTNamespace(namespace)) {
continue;
}
INamespaceHandler namespaceHandler = loader
.getNamespaceHandler(namespace);
if (namespaceHandler != null) {
for (String attrName : element.attributeNames(namespace)) {
Attribute attribute = element.getAttribute(namespace,
attrName);
Widget widget = UserData.getWidget(loadData
.getCurrentWidget());
namespaceHandler.handleAttribute(widget, targetObject,
attrName, attribute.getContent());
}
}
}
}