private static void collectUsedReferences (HashSet<DesignComponent> referencedComponents, DesignComponent component) { ComponentDescriptor descriptor = component.getComponentDescriptor (); Collection<PropertyDescriptor> propertyDescriptors = descriptor.getPropertyDescriptors (); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { if (! propertyDescriptor.isUseForSerialization ()) continue; PropertyValue propertyValue = component.readProperty (propertyDescriptor.getName ()); Debug.collectAllComponentReferences (propertyValue, referencedComponents); } }
private static void saveComponent (Document xml, Node parentNode, DesignComponent component) { ComponentDescriptor descriptor = component.getComponentDescriptor (); Node node = xml.createElement (COMPONENT_NODE); parentNode.appendChild (node); setAttribute (xml, node, COMPONENTID_ATTR, Long.toString (component.getComponentID ())); setAttribute (xml, node, TYPEID_ATTR, component.getType ().getEncoded ()); Collection<PropertyDescriptor> propertyDescriptors = descriptor.getPropertyDescriptors (); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { if (! propertyDescriptor.isUseForSerialization ()) continue; String propertyName = propertyDescriptor.getName (); if (component.isDefaultValue (propertyName)) continue; PropertyValue propertyValue = component.readProperty (propertyName); String serialized = propertyValue.serialize (); Node propertyNode = xml.createElement (PROPERTY_NODE); node.appendChild (propertyNode); setAttribute (xml, propertyNode, NAME_ATTR, propertyDescriptor.getName ()); setAttribute (xml, propertyNode, TYPEID_ATTR, propertyDescriptor.getType ().getEncoded ()); setAttribute (xml, propertyNode, VALUE_ATTR, serialized); } for (DesignComponent child : component.getComponents ()) saveComponent (xml, node, child); }
setAttribute (document, propertyNode, XMLComponentDescriptor.ALLOW_NULL, Boolean.toString (propertyDescriptor.isAllowNull ())); setAttribute (document, propertyNode, XMLComponentDescriptor.ALLOW_USER_CODE, Boolean.toString (propertyDescriptor.isAllowUserCode ())); setAttribute (document, propertyNode, XMLComponentDescriptor.USE_FOR_SERIALIZATION_ATTR, Boolean.toString (propertyDescriptor.isUseForSerialization ())); setAttribute (document, propertyNode, XMLComponentDescriptor.READ_ONLY_ATTR, Boolean.toString (propertyDescriptor.isReadOnly ())); rootNode.appendChild (propertyNode);