use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDComplexTypeDefinitionAdapter method getText.
public String getText() {
XSDComplexTypeDefinition xsdComplexTypeDefinition = (XSDComplexTypeDefinition) target;
StringBuffer result = new StringBuffer();
// $NON-NLS-1$
result.append(xsdComplexTypeDefinition.getName() == null ? "local type" : xsdComplexTypeDefinition.getName());
XSDTypeDefinition baseTypeDefinition = xsdComplexTypeDefinition.getBaseTypeDefinition();
if (baseTypeDefinition != null && baseTypeDefinition != xsdComplexTypeDefinition.getContent() && baseTypeDefinition.getName() != null && !XSDConstants.isURType(baseTypeDefinition)) {
try {
String qName = baseTypeDefinition.getQName(xsdComplexTypeDefinition);
// $NON-NLS-1$
result.append(" : ");
result.append(qName);
} catch (Exception e) {
return result.toString();
}
}
return result.toString();
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDSchemaAdapter method getComplexTypes.
/**
* @param schema
* @return
*/
public List getComplexTypes(XSDSchema schema, boolean showFromIncludes) {
List allTypes = schema.getTypeDefinitions();
List list = new ArrayList();
for (Iterator i = allTypes.iterator(); i.hasNext(); ) {
XSDTypeDefinition td = (XSDTypeDefinition) i.next();
if (td instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) td;
if (shouldShowComponent(ct, schema, showFromIncludes)) {
list.add(ct);
}
}
}
List adapterList = new ArrayList();
populateAdapterList(list, adapterList);
return adapterList;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDSimpleContentAdapter method getTopContainer.
public IADTObject getTopContainer() {
XSDConcreteComponent c = getXSDSimpleTypeContent().getContainer();
if (c instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) c;
Adapter adapter = XSDAdapterFactory.getInstance().adapt(ct);
if (adapter instanceof IADTObject)
return (IADTObject) adapter;
}
return null;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class AddXSDComplexTypeDefinitionCommand method execute.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#execute()
*/
public void execute() {
try {
beginRecording(parent.getElement());
XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory();
XSDComplexTypeDefinition complexType = factory.createXSDComplexTypeDefinition();
addedXSDConcreteComponent = complexType;
// $NON-NLS-1$
String newName = getNewName(nameToAdd == null ? "NewComplexType" : nameToAdd, parent.getSchema());
complexType.setName(newName);
if (parent instanceof XSDSchema) {
try {
XSDSchema xsdSchema = (XSDSchema) parent;
ensureSchemaElement(xsdSchema);
// $NON-NLS-1$
Text textNode = xsdSchema.getDocument().createTextNode("\n");
xsdSchema.getElement().appendChild(textNode);
xsdSchema.getContents().add(complexType);
} catch (Exception e) {
}
} else if (parent instanceof XSDElementDeclaration) {
((XSDElementDeclaration) parent).setAnonymousTypeDefinition(complexType);
formatChild(parent.getElement());
}
createdComplexType = complexType;
} finally {
endRecording();
}
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class AddXSDModelGroupAction method run.
public void run() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
XSDConcreteComponent xsdComponent = (XSDConcreteComponent) ((XSDBaseAdapter) selection).getTarget();
AddXSDModelGroupCommand command = null;
if (xsdComponent instanceof XSDElementDeclaration) {
XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) xsdComponent;
command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdElementDeclaration, xsdCompositor);
getCommandStack().execute(command);
} else if (xsdComponent instanceof XSDModelGroup) {
XSDModelGroup xsdModelGroup = (XSDModelGroup) xsdComponent;
command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdModelGroup, xsdCompositor);
getCommandStack().execute(command);
} else if (xsdComponent instanceof XSDComplexTypeDefinition || xsdComponent instanceof XSDModelGroupDefinition) {
command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdComponent, xsdCompositor);
getCommandStack().execute(command);
}
if (command != null) {
Adapter adapter = XSDAdapterFactory.getInstance().adapt(command.getAddedComponent());
if (adapter != null)
provider.setSelection(new StructuredSelection(adapter));
}
}
}
Aggregations