use of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType in project webtools.sourceediting by eclipse.
the class BaseNodeActionManager method contributeTextNodeActions.
protected void contributeTextNodeActions(IMenuManager menu, Element parentElement, CMElementDeclaration parentEd, int index) {
if ((parentEd == null) || isTextAllowed(parentEd)) {
CMDataType dataType = parentEd != null ? parentEd.getDataType() : null;
contributeAction(menu, createAddPCDataAction(parentElement, dataType, index));
contributeAction(menu, createAddCDataSectionAction(parentElement, index));
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType in project webtools.sourceediting by eclipse.
the class XSLContentModelGenerator method generateRequiredAttribute.
/**
* @param ownerNode
* @param attrDecl
* @param buffer
*/
public void generateRequiredAttribute(Node ownerNode, CMAttributeDeclaration attrDecl, StringBuffer buffer) {
if ((attrDecl == null) || (buffer == null)) {
return;
}
// attribute name
String attributeName = getRequiredName(ownerNode, attrDecl);
CMDataType attrType = attrDecl.getAttrType();
String defaultValue = null;
// = sign
// $NON-NLS-1$
buffer.append(attributeName + "=");
// attribute value
if (attrType != null) {
// insert any value that is implied
if ((attrType.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE) && (attrType.getImpliedValue() != null)) {
defaultValue = attrType.getImpliedValue();
} else // first value
if ((attrType.getEnumeratedValues() != null) && (attrType.getEnumeratedValues().length > 0)) {
defaultValue = attrType.getEnumeratedValues()[0];
}
}
char attrQuote = '\"';
// Found a double quote, wrap the attribute in single quotes
if (defaultValue != null && defaultValue.indexOf(attrQuote) >= 0) {
attrQuote = '\'';
}
buffer.append(attrQuote);
// $NON-NLS-1$
buffer.append(((defaultValue != null) ? defaultValue : ""));
buffer.append(attrQuote);
return;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType in project webtools.sourceediting by eclipse.
the class CMPrinter method visitCMElementDeclaration.
public void visitCMElementDeclaration(CMElementDeclaration ed) {
if (!visitedElements.contains(ed)) {
visitedElements.add(ed);
// $NON-NLS-1$
fStringBuffer.append(indent + "<CMElementDeclaration");
printAttributes(fStringBuffer, ed);
// $NON-NLS-1$
fStringBuffer.append(">\n");
incrementIndent();
printProperties(fStringBuffer, ed);
CMNamedNodeMap nodeMap = ed.getAttributes();
int size = nodeMap.getLength();
for (int i = 0; i < size; i++) {
visitCMNode(nodeMap.item(i));
}
visitCMNode(ed.getContent());
CMDataType dataType = ed.getDataType();
if (dataType != null)
visitCMNode(dataType);
decrementIndent();
// $NON-NLS-1$
fStringBuffer.append(indent + "</CMElementDeclaration>\n");
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType in project webtools.sourceediting by eclipse.
the class XMLPropertySource method getValidValues.
private String[] getValidValues(CMAttributeDeclaration attrDecl) {
if (attrDecl == null) {
return new String[0];
}
String[] validValues = null;
CMDataType attrType = attrDecl.getAttrType();
if (attrType != null) {
validValues = _getValidStrings(attrDecl, attrType);
if (fSortEnumeratedValues) {
Arrays.sort(validValues);
}
}
if (validValues == null) {
validValues = new String[0];
}
return validValues;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMDataType in project webtools.sourceediting by eclipse.
the class XMLPropertySource method createPropertyDescriptor.
protected IPropertyDescriptor createPropertyDescriptor(CMAttributeDeclaration attrDecl, Attr attr) {
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, attr);
} else if (((attrDecl.getUsage() == CMAttributeDeclaration.FIXED) || (attrType.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED)) && (attrType.getImpliedValue() != null)) {
descriptor = createFixedPropertyDescriptor(attrDecl, attrType, attr);
} else {
// plain text
descriptor = createTextPropertyDescriptor(attrDecl, attr);
}
} else {
// no extra information given
descriptor = createTextPropertyDescriptor(attrDecl, attr);
}
return descriptor;
}
Aggregations