Search in sources :

Example 41 with XSDConcreteComponent

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

the class XSDModelGroupDefinitionAdapter method getTopContainer.

public IADTObject getTopContainer() {
    XSDModelGroupDefinition group = getXSDModelGroupDefinition();
    XSDConcreteComponent container = group.getContainer();
    if (container instanceof XSDSchema || container instanceof XSDRedefine)
        return this;
    else
        return getGlobalXSDContainer(group);
}
Also used : XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 42 with XSDConcreteComponent

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

the class CreateElementAction method run.

/*
   * @see IAction#run()
   */
public void run() {
    beginRecording(getDescription());
    final Element child = createAndAddNewChildElement();
    endRecording();
    if (selectionProvider != null) {
        final XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(child);
        // selectionProvider.setSelection(new StructuredSelection(comp));
        Runnable runnable = new Runnable() {

            public void run() {
                if (comp instanceof XSDAttributeDeclaration) {
                    if (((XSDAttributeDeclaration) comp).getContainer() instanceof XSDAttributeUse) {
                        if (comp.getContainer().getContainer() instanceof XSDAttributeGroupDefinition) {
                            selectionProvider.setSelection(new StructuredSelection(comp.getContainer()));
                        } else if (comp.getContainer().getContainer() instanceof XSDComplexTypeDefinition) {
                            if (XSDDOMHelper.inputEquals(child, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true)) {
                                selectionProvider.setSelection(new StructuredSelection(comp.getContainer()));
                            } else {
                                selectionProvider.setSelection(new StructuredSelection(comp));
                            }
                        } else {
                            selectionProvider.setSelection(new StructuredSelection(comp));
                        }
                    } else {
                        selectionProvider.setSelection(new StructuredSelection(comp));
                    }
                } else {
                    selectionProvider.setSelection(new StructuredSelection(comp));
                }
                if (comp instanceof XSDNamedComponent) {
                    if (sourceContext instanceof AbstractEditPartViewer) {
                    // AbstractEditPartViewer viewer = (AbstractEditPartViewer)sourceContext;
                    // Object obj = viewer.getSelectedEditParts().get(0);
                    // if (obj instanceof GraphicalEditPart)
                    // {
                    // if (obj instanceof ElementDeclarationEditPart)
                    // {
                    // XSDElementDeclaration elem = ((ElementDeclarationEditPart)obj).getXSDElementDeclaration();
                    // if (!elem.isElementDeclarationReference())
                    // {
                    // ((ElementDeclarationEditPart)obj).doEditName();
                    // }
                    // }
                    // else if (obj instanceof ModelGroupDefinitionEditPart)
                    // {
                    // XSDModelGroupDefinition group = ((ModelGroupDefinitionEditPart)obj).getXSDModelGroupDefinition();
                    // if (!group.isModelGroupDefinitionReference())
                    // {
                    // ((ModelGroupDefinitionEditPart)obj).doEditName();
                    // }
                    // }
                    // else if (obj instanceof ComplexTypeDefinitionEditPart)
                    // {
                    // XSDComplexTypeDefinition ct = ((ComplexTypeDefinitionEditPart)obj).getXSDComplexTypeDefinition();
                    // if (ct.getName() != null)
                    // {
                    // ((ComplexTypeDefinitionEditPart)obj).doEditName();
                    // }
                    // }
                    // else if (obj instanceof TopLevelComponentEditPart)
                    // {
                    // ((TopLevelComponentEditPart)obj).doEditName();
                    // }
                    // }
                    }
                }
            }
        };
        Display.getDefault().timerExec(50, runnable);
    }
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) Element(org.w3c.dom.Element) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) AbstractEditPartViewer(org.eclipse.gef.ui.parts.AbstractEditPartViewer) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 43 with XSDConcreteComponent

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

the class XSDHyperlinkTargetLocator method caseXSDElementDeclaration.

/*
   * (non-Javadoc)
   * 
   * @see org.eclipse.xsd.util.XSDSwitch#caseXSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration)
   */
public Object caseXSDElementDeclaration(XSDElementDeclaration elementDeclaration) {
    XSDConcreteComponent target = null;
    if (elementDeclaration.isElementDeclarationReference()) {
        target = elementDeclaration.getResolvedElementDeclaration();
    } else {
        XSDConcreteComponent typeDefinition = null;
        if (elementDeclaration.getAnonymousTypeDefinition() == null) {
            typeDefinition = elementDeclaration.getTypeDefinition();
        }
        XSDConcreteComponent substitutionGroupAffiliation = elementDeclaration.getSubstitutionGroupAffiliation();
        if (typeDefinition != null && substitutionGroupAffiliation != null) {
            if (XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE.equals(attributeName)) {
                target = substitutionGroupAffiliation;
            } else {
                target = typeDefinition;
            }
        } else {
            target = typeDefinition != null ? typeDefinition : substitutionGroupAffiliation;
        }
        if (isFromSchemaForSchema(target)) {
            target = null;
        }
    }
    return target;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent)

Example 44 with XSDConcreteComponent

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

the class XSDHyperlinkTargetLocator method caseXSDTypeDefinition.

/*
   * (non-Javadoc)
   * 
   * @see org.eclipse.xsd.util.XSDSwitch#caseXSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)
   */
public Object caseXSDTypeDefinition(XSDTypeDefinition typeDefinition) {
    XSDConcreteComponent target = null;
    XSDTypeDefinition baseType = typeDefinition.getBaseType();
    if (baseType != null) {
        target = baseType;
    }
    if (isFromSchemaForSchema(target)) {
        target = null;
    }
    return target;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 45 with XSDConcreteComponent

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

the class XSDHyperlinkTargetLocator method caseXSDSimpleTypeDefinition.

public Object caseXSDSimpleTypeDefinition(XSDSimpleTypeDefinition typeDefinition) {
    XSDConcreteComponent target = null;
    // Simple types can be one of: atomic, list or union.
    XSDVariety variety = typeDefinition.getVariety();
    int varietyType = variety.getValue();
    switch(varietyType) {
        case XSDVariety.ATOMIC:
            {
                target = typeDefinition.getBaseTypeDefinition();
            }
            break;
        case XSDVariety.LIST:
            {
                target = typeDefinition.getItemTypeDefinition();
            }
            break;
        case XSDVariety.UNION:
            {
                List memberTypes = typeDefinition.getMemberTypeDefinitions();
                if (memberTypes != null && memberTypes.size() > 0) {
                    // ISSUE: What if there are more than one type?
                    // This could be a case for multiple hyperlinks at the same
                    // location.
                    target = (XSDConcreteComponent) memberTypes.get(0);
                }
            }
            break;
    }
    if (isFromSchemaForSchema(target)) {
        target = null;
    }
    return target;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) List(java.util.List) XSDVariety(org.eclipse.xsd.XSDVariety)

Aggregations

XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)88 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)30 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)25 XSDSchema (org.eclipse.xsd.XSDSchema)23 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)18 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)18 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)17 Adapter (org.eclipse.emf.common.notify.Adapter)15 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)15 XSDParticle (org.eclipse.xsd.XSDParticle)13 Iterator (java.util.Iterator)12 ArrayList (java.util.ArrayList)11 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)11 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)11 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)11 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)11 List (java.util.List)10 Element (org.w3c.dom.Element)10 IADTObject (org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)9 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)9