* Returns the current collection of property descriptors.
*
* @return all valid descriptors.
*/
private IPropertyDescriptor[] createPropertyDescriptors() {
CMNamedNodeMap attrMap = null;
CMElementDeclaration ed = getDeclaration();
if (ed != null) {
attrMap = ed.getAttributes();
CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrMap);
List nodes = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument()).getAvailableContent((Element) fNode, ed, ModelQuery.INCLUDE_ATTRIBUTES);
for (int k = 0; k < nodes.size(); k++) {
CMNode cmnode = (CMNode) nodes.get(k);
if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
allAttributes.put(cmnode);
}
}
attrMap = allAttributes;
}
List descriptorList = new ArrayList();
List names = new ArrayList();
IPropertyDescriptor descriptor;
CMAttributeDeclaration attrDecl = null;
// add descriptors for existing attributes
NamedNodeMap attributes = fNode.getAttributes();
if (attributes != null) {
for (int i = 0; i < attributes.getLength(); i++) {
Attr attr = (Attr) attributes.item(i);
// if metainfo is present for this attribute, use the
// CMAttributeDeclaration to derive a descriptor
if (attrMap != null) {
String attrName = attr.getName();
if (fCaseSensitive) {
attrDecl = (CMAttributeDeclaration) attrMap.getNamedItem(attrName);
}
else {
attrDecl = null;
for (int j = 0; j < attrMap.getLength(); j++) {
if (!fCaseSensitive && attrMap.item(j).getNodeName().equalsIgnoreCase(attrName)) {
attrDecl = (CMAttributeDeclaration) attrMap.item(j);
break;
}
}
}
}
// be consistent: if there's metainfo, use *that* as the
// descriptor ID
descriptor = null;
if (attrDecl != null) {
String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
if (!names.contains(attrName)) {
descriptor = createPropertyDescriptor(attrDecl, attr);
if (descriptor != null)
names.add(attrName);
}
}
else {
if (!names.contains(attr.getName())) {
descriptor = createDefaultPropertyDescriptor(attr.getName());
if (descriptor != null)
names.add(attr.getName());
}
}
if (descriptor != null) {
descriptorList.add(descriptor);
}
}
}
// add descriptors from the metainfo that are not yet listed
if (attrMap != null) {
for (int i = 0; i < attrMap.getLength(); i++) {
attrDecl = (CMAttributeDeclaration) attrMap.item(i);
String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
if (!names.contains(attrName)) {
IPropertyDescriptor holdDescriptor = createPropertyDescriptor(attrDecl, null);
if (holdDescriptor != null) {
names.add(attrName);