Search in sources :

Example 56 with XSDComplexTypeDefinition

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();
}
Also used : XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 57 with XSDComplexTypeDefinition

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;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 58 with XSDComplexTypeDefinition

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;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) Adapter(org.eclipse.emf.common.notify.Adapter) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition)

Example 59 with XSDComplexTypeDefinition

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();
    }
}
Also used : XSDFactory(org.eclipse.xsd.XSDFactory) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) Text(org.w3c.dom.Text) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 60 with XSDComplexTypeDefinition

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));
        }
    }
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) AddXSDModelGroupCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDModelGroupCommand) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) Adapter(org.eclipse.emf.common.notify.Adapter) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition)

Aggregations

XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)162 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)93 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)76 XSDParticle (org.eclipse.xsd.XSDParticle)75 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)66 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)53 ArrayList (java.util.ArrayList)43 XSDSchema (org.eclipse.xsd.XSDSchema)37 Test (org.junit.Test)37 EList (org.eclipse.emf.common.util.EList)25 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)25 XSDFactory (org.eclipse.xsd.XSDFactory)23 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)21 XSDTerm (org.eclipse.xsd.XSDTerm)21 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)20 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)20 Iterator (java.util.Iterator)19 List (java.util.List)19 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)16