}
public void eventOccured(GUIEvent event) {
try {
if (event.getName().equals("add")) {
Document document = userObject.element.getOwnerDocument();
if (dataModel.getValue("mode").equals("common")) {
TableRow[] entries = (TableRow[]) dialog.getDataModel().getValue("property");
for (int i = 0; i < entries.length; i++) {
WidgetInfo.PropertyEntry entry = ((PropertyEntryTableRow) entries[i]).getEntry();
Element propertyNode = null;
if (entry.propertyName.equals("anchor")) {
propertyNode = document.createElement("anchor");
AnchorEditor anchorEditor = new AnchorEditor(dialog, propertyNode, userObject);
anchorEditor.show();
} else {
if (entry.propertyName.equals("layout")) {
propertyNode = document.createElement("layout");
} else {
propertyNode = document.createElement("property");
propertyNode.setAttribute("name", entry.propertyName);
}
propertyNode.setAttribute("type", entry.propertyType);
new PropertyTableRow(userObject, entry.defaultValue, propertyNode)
.getPropertyAdapter()
.toDOM(
entry.defaultValue,
propertyNode);
Object value = null;
if (entry.propertyName.equals("layout")) {
value = LayoutFactory.getInstance().constructLayout(userObject.widget, propertyNode);
} else {
value = PropertyFactory.getInstance().constructProperty(propertyNode);
}
PropertyTableRow row = new PropertyTableRow(userObject, value, propertyNode);
userObject.widget.setProperty(entry.propertyName, value);
WidgetTree.revalidate(userObject.widget);
userObject.tableModel.addRow(row);
userObject.element.appendChild(propertyNode);
Builder.markModified();
}
}
} else {
String name = (String) dataModel.getValue("name"), type = null;
Element propertyNode = document.createElement("property");
propertyNode.setAttribute("name", name);
switch (((Integer) dataModel.getValue("type.index")).intValue()) {
case IDX_ISTRING :
type = "istring";
break;
case IDX_STRING :
type = "string";
break;
case IDX_INT :
type = "int";
break;
case IDX_FLOAT :
type = "float";
break;
case IDX_DOUBLE :
type = "double";
break;
case IDX_BOOL :
type = "bool";
break;
}
propertyNode.setAttribute("type", type);
propertyNode.appendChild(document.createTextNode((String) dataModel.getValue("value")));
Object value = PropertyFactory.getInstance().constructProperty(propertyNode);
PropertyTableRow row = new PropertyTableRow(userObject, value, propertyNode);
userObject.widget.setProperty(name, value);
WidgetTree.revalidate(userObject.widget);