/** * Creates a new component descriptor and stores it into xml file and add it into global descriptor registry. * After you add all custom component descriptors, then call <code>ComponentSerializationSupport.refresh</code> to refresh the registry. * @param projectType the project type * @param typeDescriptor the type descriptor * @param paletteDescriptor the palette descriptor * @param properties the list of declared properties * @param presenters the list of presenter serializers */ public static void serialize (String projectType, TypeDescriptor typeDescriptor, PaletteDescriptor paletteDescriptor, List<PropertyDescriptor> properties, List<PresenterSerializer> presenters) { assert projectType != null && typeDescriptor != null && properties != null && presenters != null; serializeComponentDescriptor (projectType, typeDescriptor, null, properties, presenters); if (typeDescriptor.isCanInstantiate ()) serializeComponentProducer (projectType, typeDescriptor.getThisType (), paletteDescriptor); }
/** * Creates a new raw component using a component descriptor with specified typeid. * <p> * Note: It does not add the component into a tree, you have to do it manually. * <p> * Note: it just allocates the component, it does not do any post-initializion. * @param componentType the component typeid * @return the new raw component */ public DesignComponent createRawComponent (TypeID componentType) { assert Debug.isFriend (DesignDocument.class, "createComponent") || Debug.isFriend ("org.netbeans.modules.vmd.io.DocumentLoad", "loadDocumentCore"); // NOI18N assert transactionManager.isWriteAccess (); ComponentDescriptor componentDescriptor = descriptorRegistry.getComponentDescriptor (componentType); assert componentDescriptor != null : "Missing component descriptor for " + componentType; // NOI18N assert componentDescriptor.getTypeDescriptor ().isCanInstantiate (); DesignComponent component = new DesignComponent (this, componentIDCounter ++, componentDescriptor); uid2components.put (component.getComponentID (), new TimedWeakReference (component)); getListenerManager ().notifyComponentCreated (component); return component; }
setAttribute (document, typeNode, XMLComponentDescriptor.THIS_TYPEID_ATTR, typeDescriptor.getThisType ().toString ()); setAttribute (document, typeNode, XMLComponentDescriptor.CAN_DERIVE_ATTR, Boolean.toString (typeDescriptor.isCanDerive ())); setAttribute (document, typeNode, XMLComponentDescriptor.CAN_INSTANTIATE_ATTR, Boolean.toString (typeDescriptor.isCanInstantiate ())); rootNode.appendChild (typeNode);