private IPropertyDescriptor createTextPropertyDescriptor(CMAttributeDeclaration attrDecl) { TextPropertyDescriptor descriptor = new TextPropertyDescriptor(attrDecl.getAttrName(), attrDecl.getAttrName()); descriptor.setCategory(getCategory(attrDecl)); descriptor.setDescription(attrDecl.getAttrName()); if ((attrDecl.getUsage() != CMAttributeDeclaration.REQUIRED) && fSetExpertFilter) { descriptor.setFilterFlags(new String[]{IPropertySheetEntry.FILTER_ID_EXPERT}); } return descriptor; }
public String getDefaultValue() { return getSelf().getDefaultValue(); }
/** */ private boolean isBooleanAttr(Attr attr) { if (attr == null) return false; CMAttributeDeclaration decl = CMNodeUtil.getAttributeDeclaration(attr); if (decl == null) return false; CMDataType type = decl.getAttrType(); if (type == null) return false; String values[] = type.getEnumeratedValues(); if (values == null) return false; return (values.length == 1 && values[0].equals(decl.getAttrName())); } }
private String getCategory(CMAttributeDeclaration attrDecl) { if (attrDecl != null) { if (attrDecl.supports("category")) { //$NON-NLS-1$ return (String) attrDecl.getProperty("category"); //$NON-NLS-1$ } if (fShouldDeriveCategories && (attrDecl.getAttrType() != null) && (attrDecl.getAttrType().getNodeName() != null) && (attrDecl.getAttrType().getNodeName().length() > 0)) { return attrDecl.getAttrType().getDataTypeName(); } } return CATEGORY_ATTRIBUTES; }
public boolean isXSIType(CMAttributeDeclaration ad) { boolean result = false; if (ad.getNodeName().equals("type")) //$NON-NLS-1$ { CMDocument cmDocument = (CMDocument)ad.getProperty("CMDocument"); //$NON-NLS-1$ if (cmDocument != null) { String namespaceName = (String)cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI"); //$NON-NLS-1$ if (namespaceName != null && namespaceName.equals("http://www.w3.org/2001/XMLSchema-instance")) //$NON-NLS-1$ { result = true; } } } return result; }
public int compare(Object o1, Object o2) { return ((CMAttributeDeclaration) o1).getAttrName().compareTo(((CMAttributeDeclaration) o2).getAttrName()); } };
else { for (int i = 0; i < requiredAttrs.size(); i++) { String requiredAttrName = ((CMAttributeDeclaration) requiredAttrs.get(i)).getAttrName(); boolean found = false; for (int j = 0; j < currentAttrs.getLength(); j++) { for (int i = insertAttrs.size() - 1; i >= 0; i--) { CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) insertAttrs.get(i); String requiredAttributeName = attrDecl.getAttrName(); String defaultValue = attrDecl.getDefaultValue(); if (defaultValue == null) defaultValue = ""; //$NON-NLS-1$
/** * Add required attributes and default values, if set, to the created tag element * * To customize the attributes that get added, use TagCreationInfo metadata * * This method is provided as a utility for clients. It is not used by default * * @param element * @param creationData */ protected final void ensureRequiredAttrs(final Element element, final CreationData creationData) { CMElementDeclaration ed = CMUtil.getTLDElementDeclaration(creationData.getUri(), creationData.getTagName(), creationData.getModel().getDocument().getStructuredDocument()); if (ed != null) { for (Iterator it=ed.getAttributes().iterator();it.hasNext();){ CMAttributeDeclaration attr = (CMAttributeDeclaration)it.next(); if (attr.getUsage() == CMAttributeDeclaration.REQUIRED && element.getAttribute(attr.getAttrName()) == null) { element.setAttribute(attr.getAttrName(), attr.getDefaultValue()); } } } }
public void visitCMAttributeDeclaration(CMAttributeDeclaration ad) { if (alwaysVisit || buildPolicy == BUILD_ALL_CONTENT || ad.getUsage() == CMAttributeDeclaration.REQUIRED) { createAttributeNode(ad); } }
/** * Creates a property descriptor for an attribute with a FIXED value - if * the value does not exist, an editable combo box is returned - if the * value exists but is not the fixed/default value, a combo box featuring * the current and correct value is returned - if the value exists and it * is the fixed/default value, no cell editor is provided "locking" the * value in */ private IPropertyDescriptor createFixedPropertyDescriptor(CMAttributeDeclaration attrDecl, CMDataType helper) { // the displayName MUST be set EnumeratedStringPropertyDescriptor descriptor = new EnumeratedStringPropertyDescriptor(attrDecl.getNodeName(), attrDecl.getNodeName(), _getValidFixedStrings(attrDecl, helper)); descriptor.setCategory(getCategory(attrDecl)); descriptor.setDescription(attrDecl.getAttrName()); return descriptor; }
CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) elementDecl.getAttributes().getNamedItem(attrName); if (attrDecl != null) { if ((attrDecl.getAttrType() != null) && (CMDataType.ID.equals(attrDecl.getAttrType().getDataTypeName()))) { idTypedAttribute = attr; else if ((attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) && (requiredAttribute == null)) {
public boolean isValidEmptyValue(CMAttributeDeclaration ad) { boolean result = true; CMDataType dataType = ad.getAttrType(); if (dataType != null) { String propertyValue = (String)dataType.getProperty("isValidEmptyValue"); //$NON-NLS-1$ if (propertyValue != null && propertyValue.equals("false")) //$NON-NLS-1$ { result = false; } } return result; }
if (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) { isRequired = XMLRelevanceConstants.R_REQUIRED; proposedText = getRequiredText(node, attrDecl); proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), attrDecl.getNodeName().length() + 2, attrImage,
public String getName() { String result = null; switch (kind) { case KIND_ATTR_TEXT : { result = "value"; break; } case KIND_ELEMENT_ATTR : { result = attribute.getName(); break; } case KIND_ELEMENT_CMATTRIBUTE : { CMAttributeDeclaration ad = (CMAttributeDeclaration) cmNode; result = ad.getNodeName(); break; } case KIND_ELEMENT_TEXT : { result = "text value"; break; } } return result != null ? result : ""; }
public List getQualifiedXSITypes(CMAttributeDeclaration ad, NamespaceTable table) { List list = new Vector(); List xsiTypes = (List)ad.getProperty("XSITypes"); //$NON-NLS-1$ if (xsiTypes != null && xsiTypes.size() > 0) { for (Iterator i = xsiTypes.iterator(); i.hasNext(); ) { String uriQualifiedName = (String)i.next(); String[] components = DOMNamespaceHelper.getURIQualifiedNameComponents(uriQualifiedName); String prefix = table.getPrefixForURI(components[0] != null ? components[0] : ""); //$NON-NLS-1$ String typeName = (prefix != null && prefix.length() > 0) ? prefix + ":" + components[1] : //$NON-NLS-1$ components[1]; list.add(typeName); } } return list; } }
protected String getKeyName(CMNode original) { CMAttributeDeclaration adecl = getDecl(original); if (adecl == null) return null; return adecl.getAttrName(); }
else { for (int i = 0; i < requiredAttrs.size(); i++) { String requiredAttrName = ((CMAttributeDeclaration) requiredAttrs.get(i)).getAttrName(); boolean found = false; for (int j = 0; j < currentAttrs.getLength(); j++) { for (int i = insertAttrs.size() - 1; i >= 0; i--) { CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) insertAttrs.get(i); String requiredAttributeName = attrDecl.getAttrName(); String defaultValue = attrDecl.getDefaultValue(); if (defaultValue == null) defaultValue = ""; //$NON-NLS-1$
public void generateAttribute(CMAttributeDeclaration attrDecl, StringBuffer buffer) { if ((attrDecl == null) || (buffer == null)) { return; } int usage = attrDecl.getUsage(); if (usage == CMAttributeDeclaration.REQUIRED) { buffer.append(" "); //$NON-NLS-1$ generateRequiredAttribute(null, attrDecl, buffer); // todo pass // ownerNode as // 1st param } return; }
for (int i = 0; i < attrMap.getLength(); i++) { attrDecl = (CMAttributeDeclaration) attrMap.item(i); String attrName = attrDecl.getAttrName(); if (!declaredNames.contains(attrName)) { declaredNames.add(attrName); boolean sameName = (fCaseSensitive && fDescriptors[j].getId().equals(attrDecl.getNodeName())) || (!fCaseSensitive && attrDecl.getNodeName().equals(fDescriptors[j].getId().toString())); if (sameName) { String[] validValues = getValidValues(attrDecl); for (int i = 0; i < attrMap.getLength(); i++) { attrDecl = (CMAttributeDeclaration) attrMap.item(i); String attrName = attrDecl.getAttrName(); if (fCaseSensitive) { if (!descriptorNames.contains(attrName)) {
protected IPropertyDescriptor createPropertyDescriptor(CMAttributeDeclaration attrDecl) { IPropertyDescriptor descriptor = null; CMDataType attrType = attrDecl.getAttrType(); if (attrType != null) { // handle declarations that provide FIXED/ENUMERATED values if ((attrType.getEnumeratedValues() != null) && (attrType.getEnumeratedValues().length > 0)) { descriptor = createEnumeratedPropertyDescriptor(attrDecl, attrType); } else if (((attrDecl.getUsage() == CMAttributeDeclaration.FIXED) || (attrType.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED)) && (attrType.getImpliedValue() != null)) { descriptor = createFixedPropertyDescriptor(attrDecl, attrType); } else { // plain text descriptor = createTextPropertyDescriptor(attrDecl); } } else { // no extra information given descriptor = createTextPropertyDescriptor(attrDecl); } return descriptor; }