Attributes attributes) throws SAXException {
structureStack.push(qName);
if ("fx:define".equals(qName)) {
// nothing here
} else if ("fx:include".equals(qName)) {
IncludeValueProperty p = FXGraphFactory.eINSTANCE
.createIncludeValueProperty();
for (int i = 0; i < attributes.getLength(); i++) {
String propertyQName = attributes.getQName(i);
String value = attributes.getValue(i);
if ("fx:id".equals(propertyQName)) {
p.setName(value);
} else if ("source".equals(propertyQName)) {
ComponentDefinition cd = FXGraphFactory.eINSTANCE
.createComponentDefinition();
cd.setName(value);
p.setSource(cd);
}
}
} else if ("fx:script".equals(qName)) {
for (int i = 0; i < attributes.getLength(); i++) {
String propertyQName = attributes.getQName(i);
String value = attributes.getValue(i);
if ("source".equals(propertyQName)) {
Script s = createScript(value, null);
model.getComponentDef().getScripts().add(s);
}
}
} else if ("fx:reference".equals(qName)) {
for (int i = 0; i < attributes.getLength(); i++) {
String propertyQName = attributes.getQName(i);
String value = attributes.getValue(i);
if ("source".equals(propertyQName)) {
Element e = createElementWithJVMType("idref " + value); // TODO
// this
// is
// really
// dirty
elementStack.peek().getDefaultChildren().add(e);
}
}
} else if (!"children".equals(localName)) {
if (Character.isLowerCase(localName.charAt(0))) {
if (isSpecial(localName)) {
boolean alreadyCreated = false;
for (Property p : elementStack.peek().getProperties()) {
if (localName.equals(p.getName())) {
alreadyCreated = true;
break;
}
}
if (!alreadyCreated) {
Property p = createProperty(localName,
FXGraphFactory.eINSTANCE
.createMapValueProperty());
elementStack.peek().getProperties().add(p);
}
} else {
if (!isContainer(localName)) {
thePropertyIDontWantToForget = localName;
}
}
} else {
if (!localName.contains(".")) {
if (checkConstant(localName, attributes)) {
ConstValueProperty c = createConstValueProperty(
localName, attributes);
boolean found = false;
for (Property p : elementStack.peek()
.getProperties()) {
if (p.getName().equals(getStructuralParent())) {
found = true;
p.setValue(c);
}
}
if (!found) {
Property p = createProperty(
getStructuralParent(), c);
elementStack.peek().getProperties().add(p);
if (getStructuralParent().equals(
thePropertyIDontWantToForget)) {
thePropertyIDontWantToForget = null;
}
}
} else {
Element e = createElement(localName, attributes);
// root element
if (model.getComponentDef().getRootNode() == null) {
model.getComponentDef().setRootNode(e);
} else {
// Factory values
if (elementStack.peek().getFactory() != null) {
// is it a constant or an element
if (attributes.getLength() == 1
&& "fx:value".equals(attributes
.getQName(0))) {
SimpleValueProperty sp = FXGraphFactory.eINSTANCE
.createSimpleValueProperty();
sp.setStringValue(attributes
.getValue(0));
elementStack.peek().getValues().add(sp);
} else {
elementStack.peek().getValues().add(e);
}
}
// child elements
else if ("children"
.equals(getStructuralParent())) {
elementStack.peek().getDefaultChildren()
.add(e);
} else if (isContainer(getStructuralParent())) {
Element parent = elementStack.peek();
Property p = null;
for (Property existingP : parent
.getProperties()) {
if (getStructuralParent().equals(
existingP.getName())) {
p = existingP;
break;
}
}
if (p == null) {
p = createProperty(
getStructuralParent(),
FXGraphFactory.eINSTANCE
.createListValueProperty());
}
if (p.getValue() instanceof ListValueProperty) {
ListValueProperty list = (ListValueProperty) p
.getValue();
list.getValue().add(e);
} else if ((p.getValue() instanceof ListValueProperty)) {
System.err.println("TODO");
}
parent.getProperties().add(p);
} else if ("fx:define"
.equals(getStructuralParent())) {