/** * Writes a property value. * @param propertyName the property name * @param propertyValue the property value */ public void writeProperty(String propertyName, PropertyValue propertyValue) { assert document.getTransactionManager().isWriteAccess(); assert propertyValue != null : "Null property value"; // NOI18N assert componentDescriptor != null; PropertyValue oldValue = properties.get(propertyName); assert oldValue != null : "Missing old value in " + this + "." + propertyName; // NOI18N if (oldValue == propertyValue) return; PropertyDescriptor propertyDescriptor = componentDescriptor.getPropertyDescriptor(propertyName); assert propertyDescriptor != null : "Missing property descriptor in " + this + "." + propertyName; // NOI18N assert ! propertyDescriptor.isReadOnly() : "Cannot write read-only property " + this + "." + propertyName; // NOI18N // TODO - allow writing during deserialization assert propertyValue.isCompatible(propertyDescriptor); properties.put(propertyName, propertyValue); document.getTransactionManager().writePropertyHappened(this, propertyName, oldValue, propertyValue); }
@Override public boolean isAcceptable (ComponentProducer producer, AcceptSuggestion suggestion) { if (getComponent().getComponentDescriptor().getPropertyDescriptor(DisplayableCD.PROP_COMMANDS).isReadOnly()) return false; DescriptorRegistry registry = getComponent().getDocument().getDescriptorRegistry(); return registry.isInHierarchy(CommandCD.TYPEID, producer.getMainComponentTypeID ()); }
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);