-
Notifications
You must be signed in to change notification settings - Fork 263
DOM Property Descriptors
DOM property descriptors describe type attributes, allow you to easily edit object attributes in property editors, and can be specified in constructors or annotations in the type definition file.
As part of their definition, a data model's types have attributes, which can be considered properties of objects of these types. Applications often have property editor controls to modify these object properties. Property descriptors are metadata for class properties that describe these attributes/properties.
Controls like property editors get all the information they need to edit properties from property descriptors. The DOM uses property descriptor classes to describe properties of DOM types: their attributes and child node types. After you create these descriptors, it's easy to implement property editing in your application using ATF property editing control components, such as PropertyEditor
and GridPropertyEditor
. For information on using properties in general, see the Property Editing in ATF section.
Property descriptor objects are added to DOM metadata: the DomNodeType
for a type.
In .NET, property descriptors add metadata to class properties for controls, such as property editors. DOM property descriptors are custom descriptors that describe properties of DomNode
s — the nodes' attributes and their children's nodes. You can create descriptors for properties to enable editing DOM nodes' properties in your application.
Information provided by a property descriptor can include such items as the display name of a property, descriptive text for tooltips, or the editor control used to edit that property. Creating a property descriptor allows viewing and editing a property in a property editor control with very little coding effort. Conversely, if information is not provided about a property in a property descriptor, the property is not visible in property editors.
The .NET System.ComponentModel
namespace defines the basic PropertyDescriptor
and PropertyDescriptorCollection
classes. ATF extends this PropertyDescriptor
to provide an abstract Sce.Atf.Dom.PropertyDescriptor
class that is itself extended to describe attributes and children of DomNode
objects. ATF's PropertyEditor
, shown in the figure, and GridPropertyEditor
components both use property descriptors for the information they need to display and edit properties.
ATF extends its abstract class Sce.Atf.Dom.PropertyDescriptor
to define property descriptors for these items:
- Attributes:
DomNode
attributes map directly to properties. TheAttributePropertyDescriptor
class defines attribute descriptors. - Child nodes. A
DomNode
can have child nodes, and these nodes can be associated with property descriptors in theChildPropertyDescriptor
class. - Child attributes: Child attributes are the same as regular attributes, but are defined on a child node and include the child metadata
ChildInfo
. TheChildAttributePropertyDescriptor
class defines these descriptors.
AttributePropertyDescriptor
is the most commonly used of the three. ChildAttributePropertyDescriptor
is used in certain circumstances; for an example, see Specifying Property Descriptors in Constructors. ChildPropertyDescriptor
is rarely used.
You can create DOM property descriptors in two ways:
- Construct the descriptors, usually in the schema loader, after the schema is loaded. For details, see Specifying Property Descriptors in Constructors.
- Add annotations to the XML Schema type definition file. For information on creating these annotations, see Specifying Property Descriptors in Annotations.
Applications can specify property descriptors by constructing them, typically in the schema loader's OnSchemaSetLoaded()
method. For example, the ATF DOM Tree Editor Sample defines descriptors for the attributes "AnimationTransform" and "AnimalKinds" of "UIAnimationType" in this way:
UISchema.UIAnimationType.Type.SetTag(
new PropertyDescriptorCollection(
new PropertyDescriptor[] {
new AttributePropertyDescriptor(
Localizer.Localize("Animation transform"),
UISchema.UIAnimationType.AnimationTransformAttribute,
null,
Localizer.Localize("Animation transform"),
false,
new NumericMatrixEditor(typeof(float), 3, 3)),
new AttributePropertyDescriptor(
Localizer.Localize("Animal kinds"),
UISchema.UIAnimationType.AnimalKindsAttribute,
null,
Localizer.Localize("Kinds of animal to animate"),
false,
new CollectionEditor()),
}));
The property descriptor AttributePropertyDescriptor
is used here, because "AnimationTransform" and "AnimalKinds" are attributes of "UIAnimationType". As a result, the PropertyEditor
component displays properties for these attributes when a "UIAnimationType" object type is selected.
There are several forms of the constructor for AttributePropertyDescriptor
, and these forms specify various information about the attribute, such as its name in the property editor and the type of value editor to use for the attribute. For more details on using AttributePropertyDescriptor
in the ATF Simple DOM Editor Sample, see Using the DOM.
Note that property descriptors are added to the UISchema.UIAnimationType.Type
DomNodeType
object with the NamedMetadata.SetTag()
method. For more information on this and related methods, see NamedMetadata Tag Methods.
You can also define property descriptors on attributes for types of objects that are children of nodes, but you use ChildAttributePropertyDescriptor
instead. For a description of how the ATF DOM Tree Editor Sample does this, see Type Tag Property Descriptors.
You can also define property descriptors in annotations in the XML Schema using the <xs:annotation>
and <xs:appinfo>
tags. The advantage of doing this over specifying property descriptors in constructors is that all the type's information is in one place. Changing annotations doesn't require rebuilding the application either.
Here's an example from the ATF Timeline Editor Sample's timeline.xsd
type definition file:
<xs:complexType name="eventType">
<xs:annotation>
<xs:appinfo>
<scea.dom.editors.attribute name="start" displayName="Start" description="Start Time" />
<scea.dom.editors.attribute name="description" displayName="Description" description="Event description" />
</xs:appinfo>
</xs:annotation>
<xs:attribute name="start" type="xs:float"/>
<xs:attribute name="description" type="xs:string"/>
</xs:complexType>
These annotations create property descriptors for the "start" and "description" attributes. Note that annotations are specified in addition to the attributes' definitions in <xs:attribute>
tags at the end.
Using annotations requires special support from the schema loader to parse the annotations, typically in the XmlSchemaTypeLoader.ParseAnnotations()
method. For a detailed description of how the ATF Timeline Editor Sample supports annotations, see XML Schema Annotations.
You can define your own types of annotations for whatever additional information you want to add to a type. You would also need to add support for this type of annotation, usually by overriding XmlSchemaTypeLoader.ParseAnnotations()
.
For example, the ATF Timeline Editor Sample's timeline.xsd
type definition file has a "scea.dom.editors" annotation for "groupType":
<xs:complexType name="groupType">
<xs:annotation>
<xs:appinfo>
<scea.dom.editors menuText="Group" description="Group" image="TimelineEditorSample.Resources.group.png" category="Timelines" />
<scea.dom.editors.attribute name="name" displayName="Name" description="Name" />
<scea.dom.editors.attribute name="expanded" displayName="Expanded" description="Whether Group is Expanded" />
</xs:appinfo>
</xs:annotation>
...
The TimelineEditor sample overrides XmlSchemaTypeLoader.ParseAnnotations()
, and this override method gets information from the annotation to create palette items. Note that this annotation applies to the entire type — not an attribute of the type. For details on how it handles this annotation, see Annotation Parsing in Timeline Editor Programming Discussion.
- What is the DOM For: Overview of the DOM's features and advantages.
- It All Starts With Data: Defining application data models with types, especially using XML Schema.
-
DomNodes and DOM Metadata Classes: The fundamental
DomNode
class and its type metadata classes, such asDomNodeType
. Application data resides in a tree ofDomNode
s. - Type Loaders: Loading the type definition file into the application to use the file's data types and create type metadata class objects.
-
DOM Adapters: DOM adapters allow adapting
DomNode
s to other types and monitor events in theDomNode
tree to validate data. - DOM Property Descriptors: DOM property descriptors make it easy to use property editors on application data and are stored in type metadata.
- Using DOM Metadata for Palettes and Other Items: Type metadata can hold all sorts of data, such as palette object information.
-
DOM Persistence: Persisting application data using classes to write the
DomNode
tree to XML and read it back to aDomNode
tree. - DOM Debugging: ATF tools to facilitate debugging DOM code.
- DOM Use in Simple DOM Editor: Explains how the ATF Simple DOM Editor Sample uses the DOM.
- Home
- Getting Started
- Features & Benefits
- Requirements & Dependencies
- Gallery
- Technology & Samples
- Adoption
- News
- Release Notes
- ATF Community
- Searching Documentation
- Using Documentation
- Videos
- Tutorials
- How To
- Programmer's Guide
- Reference
- Code Samples
- Documentation Files
© 2014-2015, Sony Computer Entertainment America LLC