public int compare(Object o1, Object o2) { return ((CMAttributeDeclaration) o1).getAttrName().compareTo(((CMAttributeDeclaration) o2).getAttrName()); } };
protected String getKeyName(CMNode original) { CMAttributeDeclaration adecl = getDecl(original); if (adecl == null) return null; return adecl.getAttrName(); }
public String getAttrName() { return getSelf().getAttrName(); }
private String[] _getValidFixedStrings(CMAttributeDeclaration attrDecl, CMDataType helper) { String attributeName = attrDecl.getAttrName(); List values = new ArrayList(1); String impliedValue = helper.getImpliedValue(); if (impliedValue != null) { values.add(impliedValue); } boolean checkIfCurrentValueIsIncluded = ((fNode.getAttributes() != null) && (fNode.getAttributes().getNamedItem(attributeName) != null) && (fNode.getAttributes().getNamedItem(attributeName).getNodeValue() != null)); if (checkIfCurrentValueIsIncluded) { String currentValue = null; currentValue = fNode.getAttributes().getNamedItem(attributeName).getNodeValue(); if (!currentValue.equals(impliedValue)) { values.add(currentValue); } } String[] validStrings = new String[values.size()]; validStrings = (String[]) values.toArray(validStrings); return validStrings; }
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; }
/** * Creates a property descriptor for an attribute with ENUMERATED values - * if the value does not exist, an editable combo box is returned - if the * value exists but is not one in the enumerated list of value, a combo * box featuring the current and correct values is returned - if the value * exists and it is a valid value, a combo box featuring the correct * values with the current one visible is returned */ private IPropertyDescriptor createEnumeratedPropertyDescriptor(CMAttributeDeclaration attrDecl, CMDataType valuesHelper) { // the displayName MUST be set EnumeratedStringPropertyDescriptor descriptor = new EnumeratedStringPropertyDescriptor(attrDecl.getAttrName(), attrDecl.getAttrName(), _getValidStrings(attrDecl, valuesHelper)); descriptor.setCategory(getCategory(attrDecl)); descriptor.setDescription(attrDecl.getAttrName()); if ((attrDecl.getUsage() != CMAttributeDeclaration.REQUIRED) && fSetExpertFilter) { descriptor.setFilterFlags(new String[]{IPropertySheetEntry.FILTER_ID_EXPERT}); } return descriptor; }
/** * This method returns true if all of the following conditions are met: * (1) value type is ENUM, * (2) only one value is defined in the enumeration, * (3) the value has same name to the attribute name. */ public static boolean isBooleanAttr(CMAttributeDeclaration adec) { CMDataType attrtype = adec.getAttrType(); if (attrtype == null) return false; if (attrtype.getDataTypeName() != CMDataType.ENUM) return false; String[] values = attrtype.getEnumeratedValues(); if (values.length != 1) return false; return values[0].equals(adec.getAttrName()); }
/** */ 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())); } }
public String getValue(CMAttributeDeclaration ad, NamespaceTable namespaceTable) { String value = null; if (isXSIType(ad)) { List list = getQualifiedXSITypes(ad, namespaceTable); value = list.size() > 0 ? (String)list.get(0) : null; } // shameless hack // if (value == null) { if (ad.getAttrName().equals("xml:lang")) //$NON-NLS-1$ { value = "EN"; //$NON-NLS-1$ } } if (value == null) { CMDataType dataType = ad.getAttrType(); if (dataType != null) { value = getValue(dataType); } } return value; }
String requiredAttrName = ((CMAttributeDeclaration) requiredAttrs.get(i)).getAttrName(); boolean found = false; for (int j = 0; j < currentAttrs.getLength(); j++) {
String requiredAttrName = ((CMAttributeDeclaration) requiredAttrs.get(i)).getAttrName(); boolean found = false; for (int j = 0; j < currentAttrs.getLength(); j++) {
name = sortedAttrs[i].getAttrName(); length = name.length(); pos = attrInfo.length();
private String[] _getValidStrings(CMAttributeDeclaration attrDecl, CMDataType valuesHelper) { String attributeName = attrDecl.getAttrName(); List values = new ArrayList(1); boolean currentValueKnown = false;
protected CMNode createBuddySystem(CMNode original) { CMAttributeDeclaration adecl = getDecl(original); if (adecl == null) return null; CMAttributeDeclaration buddy = null; if (buddyAttrs != null) { buddy = (CMAttributeDeclaration) buddyAttrs.getNamedItem(adecl.getAttrName()); } return new CMAttributeDeclarationBuddySystem(adecl, buddy, isXHTML()); }
/** * 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()); } } } }
private void checkRequiredAttributes(IDOMElement element, CMNamedNodeMap attrMap, IReporter reporter, IFile file, IStructuredDocument document, IStructuredDocumentRegion documentRegion) { Iterator it = attrMap.iterator(); CMAttributeDeclaration attr = null; while (it.hasNext()) { attr = (CMAttributeDeclaration) it.next(); if (attr.getUsage() == CMAttributeDeclaration.REQUIRED) { Attr a = element.getAttributeNode(attr.getAttrName()); if (a == null) { String msgText = NLS.bind(JSPCoreMessages.JSPDirectiveValidator_5, attr.getAttrName()); LocalizedMessage message = new LocalizedMessage(fSeverityMissingRequiredAttribute, msgText, file); int start = element.getStartOffset(); int length = element.getStartEndOffset() - start; int lineNo = document.getLineOfOffset(start); message.setLineNo(lineNo); message.setOffset(start); message.setLength(length); reporter.addMessage(fMessageOriginator, message); } } } }
public Command getUpdateValueCommand(String newValue) { switch (kind) { case KIND_ATTR_TEXT : case KIND_ELEMENT_ATTR : { // note intentional fall-thru!! return new UpdateAttributeValueCommand(parent, attribute.getNodeName(), newValue, true); } case KIND_ELEMENT_CMATTRIBUTE : { final CMAttributeDeclaration ad = (CMAttributeDeclaration) cmNode; return new UpdateAttributeValueCommand(parent, ad.getAttrName(), newValue, true); } case KIND_ELEMENT_TEXT : { return new UpdateTextValueCommand(parent, newValue); } } return null; }
@Override protected void doCollect(IDOMElement target, String name, IFile file, INgBindingCollector collector) { String tagName = target.getTagName(); int index = name.lastIndexOf('.'); if (index != -1) { String part = name.substring(0, index); if (ATTR_PROP.equals(part)) { // completion for attributes CMElementDeclaration eltDecl = CMNodeUtil.getElementDeclaration(target); if (eltDecl != null) { Iterator it = eltDecl.getAttributes().iterator(); CMAttributeDeclaration attr = null; while (it.hasNext()) { attr = (CMAttributeDeclaration) it.next(); collector.collect(name, part + "." + attr.getAttrName(), null, this); } } } } else { DomElementSchemaRegistry.INSTANCE.collectProperty(tagName, DomElementSchemaRegistry.INSTANCE.getMappedPropName(name), this, collector); collector.collect(name, ATTR_PROP, formatAttr(ATTR_PROP), this); collector.collect(name, CLASS_PROP, formatAttr(CLASS_PROP), this); } // style already exists } }
/** * 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; }
for (int i = 0; i < fRequiredAttrs.size(); i++) { CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) fRequiredAttrs.get(i); String requiredAttributeName = attrDecl.getAttrName(); String defaultValue = attrDecl.getDefaultValue(); if (defaultValue == null) {