Search in sources :

Example 41 with XSDModelGroupDefinition

use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.

the class XSDCommonUIUtils method getModelGroup.

public static XSDModelGroup getModelGroup(XSDComplexTypeDefinition cType) {
    XSDParticle particle = cType.getComplexType();
    if (particle == null || particle.eContainer() != cType)
        return null;
    Object particleContent = particle.getContent();
    XSDModelGroup group = null;
    if (particleContent instanceof XSDModelGroupDefinition)
        group = ((XSDModelGroupDefinition) particleContent).getResolvedModelGroupDefinition().getModelGroup();
    else if (particleContent instanceof XSDModelGroup)
        group = (XSDModelGroup) particleContent;
    if (group == null)
        return null;
    if (group.getContents().isEmpty() || group.eResource() != cType.eResource()) {
        XSDComplexTypeContent content = cType.getContent();
        if (content instanceof XSDParticle)
            group = (XSDModelGroup) ((XSDParticle) content).getContent();
    }
    return group;
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDComplexTypeContent(org.eclipse.xsd.XSDComplexTypeContent) EObject(org.eclipse.emf.ecore.EObject) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 42 with XSDModelGroupDefinition

use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.

the class XSDModelGroupDefinitionSection method setInput.

public void setInput(IWorkbenchPart part, ISelection selection) {
    super.setInput(part, selection);
    init();
    relayout();
    if (isReference) {
        TypesHelper helper = new TypesHelper(xsdSchema);
        List items = new ArrayList();
        items = helper.getModelGroups();
        if (input instanceof XSDModelGroupDefinition) {
            XSDModelGroupDefinition group = (XSDModelGroupDefinition) input;
            XSDConcreteComponent parent = group.getContainer();
            while (parent != null) {
                if (parent instanceof XSDModelGroupDefinition) {
                    items.remove(((XSDModelGroupDefinition) parent).getQName());
                    break;
                }
                parent = parent.getContainer();
            }
        }
        // $NON-NLS-1$
        items.add(0, "");
        componentNameCombo.setItems((String[]) items.toArray(new String[0]));
    }
}
Also used : TypesHelper(org.eclipse.wst.xsd.ui.internal.util.TypesHelper) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition)

Example 43 with XSDModelGroupDefinition

use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.

the class XSDModelGroupDefinitionSection method doWidgetSelected.

public void doWidgetSelected(SelectionEvent e) {
    if (e.widget == componentNameCombo) {
        String newValue = componentNameCombo.getText();
        if (input instanceof XSDNamedComponent) {
            XSDNamedComponent namedComponent = (XSDNamedComponent) input;
            Element element = namedComponent.getElement();
            if (namedComponent instanceof XSDModelGroupDefinition) {
                element.setAttribute(XSDConstants.REF_ATTRIBUTE, newValue);
                XSDDirectivesManager.removeUnusedXSDImports(namedComponent.getSchema());
            }
        }
    }
    super.doWidgetSelected(e);
}
Also used : XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) Element(org.w3c.dom.Element) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition)

Aggregations

XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)43 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)19 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)18 List (java.util.List)15 ArrayList (java.util.ArrayList)13 Iterator (java.util.Iterator)12 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)11 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)11 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)11 XSDParticle (org.eclipse.xsd.XSDParticle)10 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)10 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)9 XSDSchema (org.eclipse.xsd.XSDSchema)9 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)8 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)7 XSDRedefine (org.eclipse.xsd.XSDRedefine)6 XSDWildcard (org.eclipse.xsd.XSDWildcard)6 Adapter (org.eclipse.emf.common.notify.Adapter)5 EObject (org.eclipse.emf.ecore.EObject)4 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)4