use of org.eclipse.xsd.XSDAttributeDeclaration in project webtools.sourceediting by eclipse.
the class XSDVisitor method visitSchema.
public void visitSchema(XSDSchema schema) {
this.schema = schema;
for (Iterator iterator = schema.getAttributeDeclarations().iterator(); iterator.hasNext(); ) {
XSDAttributeDeclaration attr = (XSDAttributeDeclaration) iterator.next();
visitAttributeDeclaration(attr);
}
for (Iterator iterator = schema.getTypeDefinitions().iterator(); iterator.hasNext(); ) {
XSDTypeDefinition type = (XSDTypeDefinition) iterator.next();
visitTypeDefinition(type);
}
for (Iterator iterator = schema.getElementDeclarations().iterator(); iterator.hasNext(); ) {
XSDElementDeclaration element = (XSDElementDeclaration) iterator.next();
visitElementDeclaration(element);
}
for (Iterator iterator = schema.getIdentityConstraintDefinitions().iterator(); iterator.hasNext(); ) {
XSDIdentityConstraintDefinition identityConstraint = (XSDIdentityConstraintDefinition) iterator.next();
visitIdentityConstraintDefinition(identityConstraint);
}
for (Iterator iterator = schema.getModelGroupDefinitions().iterator(); iterator.hasNext(); ) {
XSDModelGroupDefinition modelGroup = (XSDModelGroupDefinition) iterator.next();
visitModelGroupDefinition(modelGroup);
}
for (Iterator iterator = schema.getAttributeGroupDefinitions().iterator(); iterator.hasNext(); ) {
XSDAttributeGroupDefinition attributeGroup = (XSDAttributeGroupDefinition) iterator.next();
visitAttributeGroupDefinition(attributeGroup);
}
for (Iterator iterator = schema.getNotationDeclarations().iterator(); iterator.hasNext(); ) {
XSDNotationDeclaration element = (XSDNotationDeclaration) iterator.next();
visitNotationDeclaration(element);
}
}
use of org.eclipse.xsd.XSDAttributeDeclaration in project webtools.sourceediting by eclipse.
the class TypesHelper method getGlobalAttributes.
public java.util.List getGlobalAttributes() {
Vector items = new Vector();
if (xsdSchema != null) {
updateExternalImportGlobals();
if (xsdSchema.getAttributeDeclarations() != null) {
Iterator i = xsdSchema.getAttributeDeclarations().iterator();
while (i.hasNext()) {
XSDAttributeDeclaration attributeDeclaration = (XSDAttributeDeclaration) i.next();
if (attributeDeclaration.getTargetNamespace() == null || (attributeDeclaration.getTargetNamespace() != null && !attributeDeclaration.getTargetNamespace().equals(XSDConstants.SCHEMA_INSTANCE_URI_2001))) {
String name = attributeDeclaration.getQName(xsdSchema);
if (name != null) {
items.add(name);
}
}
}
}
// items = addExternalImportedAttributes(items);
items = (Vector) sortList(items);
}
return items;
}
use of org.eclipse.xsd.XSDAttributeDeclaration in project webtools.sourceediting by eclipse.
the class AddXSDAttributeDeclarationAction method run.
public void run() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
selection = ((XSDBaseAdapter) selection).getTarget();
if (selection instanceof XSDAttributeDeclaration) {
selection = ((XSDAttributeDeclaration) selection).getContainer();
}
}
AddXSDAttributeDeclarationCommand command = null;
if (selection instanceof XSDComplexTypeDefinition) {
command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, (XSDComplexTypeDefinition) selection);
command.setReference(isReference);
getCommandStack().execute(command);
} else if (selection instanceof XSDAttributeUse) {
XSDAttributeUse xsdAttributeUse = (XSDAttributeUse) selection;
XSDConcreteComponent parent = null;
XSDComplexTypeDefinition ct = null;
XSDAttributeGroupDefinition group = null;
for (parent = xsdAttributeUse.getContainer(); parent != null; ) {
if (parent instanceof XSDComplexTypeDefinition) {
ct = (XSDComplexTypeDefinition) parent;
break;
} else if (parent instanceof XSDAttributeGroupDefinition) {
group = (XSDAttributeGroupDefinition) parent;
break;
}
parent = parent.getContainer();
}
if (ct != null) {
XSDAttributeUse sel = (XSDAttributeUse) selection;
int index = ct.getAttributeContents().indexOf(sel);
command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, ct, getId(), index);
command.setReference(isReference);
getCommandStack().execute(command);
} else if (group != null) {
XSDAttributeUse sel = (XSDAttributeUse) selection;
int index = group.eContents().indexOf(sel);
command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, group, getId(), index);
command.setReference(isReference);
getCommandStack().execute(command);
}
} else if (selection instanceof XSDAttributeGroupDefinition) {
command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, (XSDAttributeGroupDefinition) selection);
command.setReference(isReference);
getCommandStack().execute(command);
} else if (selection instanceof XSDSchema) {
command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, (XSDSchema) selection);
getCommandStack().execute(command);
}
if (command != null) {
addedComponent = command.getAddedComponent();
Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent);
selectAddedComponent(adapter);
}
}
use of org.eclipse.xsd.XSDAttributeDeclaration in project webtools.sourceediting by eclipse.
the class AddExtensionsComponentDialog method buildInput.
private static List buildInput(XSDSchema xsdSchema) {
if (xsdSchema == null)
return null;
List elements = xsdSchema.getElementDeclarations();
List attributes = xsdSchema.getAttributeDeclarations();
String targetNamespace = xsdSchema.getTargetNamespace();
// For safety purpose: We don't append 'attributes' to 'elements'
// ArrayStoreException(or similar one) may occur
List allItems = new ArrayList(attributes.size() + elements.size());
{
// only add non-imported elements here. (trung)
for (int i = 0; i < elements.size(); i++) {
XSDElementDeclaration currentElement = (XSDElementDeclaration) elements.get(i);
if (currentElement.getTargetNamespace() != null) {
if (currentElement.getTargetNamespace().equals(targetNamespace))
allItems.add(currentElement);
} else {
if (targetNamespace == null)
allItems.add(currentElement);
}
}
// only add non-imported elements here. (trung)
for (int i = 0; i < attributes.size(); i++) {
XSDAttributeDeclaration currentAttribute = (XSDAttributeDeclaration) attributes.get(i);
if (currentAttribute.getTargetNamespace() != null) {
if (currentAttribute.isGlobal() && currentAttribute.getTargetNamespace().equals(targetNamespace))
allItems.add(currentAttribute);
} else {
if (targetNamespace == null)
allItems.add(currentAttribute);
}
}
}
return allItems;
}
use of org.eclipse.xsd.XSDAttributeDeclaration in project webtools.sourceediting by eclipse.
the class AddXSDAttributeGroupDefinitionCommand method updateNames.
private void updateNames(XSDComplexTypeDefinition ct) {
Iterator iter = ct.getAttributeContents().iterator();
while (iter.hasNext()) {
Object obj = iter.next();
if (obj instanceof XSDAttributeUse) {
XSDAttributeUse use = (XSDAttributeUse) obj;
XSDAttributeDeclaration attr = use.getAttributeDeclaration();
String attrName = attr.getName();
if (attrName != null) {
names.add(attrName);
}
}
}
}
Aggregations