Search in sources :

Example 36 with XSDConcreteComponent

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

the class XSDAttributeGroupDefinitionAdapter method getTopContainer.

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

Example 37 with XSDConcreteComponent

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

the class XSDBaseAdapter method populateAdapterList.

public void populateAdapterList(List notifierList, List adapterList) {
    for (Iterator i = notifierList.iterator(); i.hasNext(); ) {
        Object obj = i.next();
        if (obj instanceof XSDConcreteComponent) {
            XSDConcreteComponent component = (XSDConcreteComponent) obj;
            adapterList.add(XSDAdapterFactory.getInstance().adapt(component));
        } else {
            adapterList.add(obj);
        }
    }
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) Iterator(java.util.Iterator) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject)

Example 38 with XSDConcreteComponent

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

the class XSDBaseAdapter method getGlobalXSDContainer.

protected IADTObject getGlobalXSDContainer(XSDConcreteComponent component) {
    XSDConcreteComponent c = component.getContainer();
    // We want the top most structural component
    while (c != null && !(c.getContainer() instanceof XSDSchema) && !(c instanceof XSDComplexTypeDefinition) && !(c instanceof XSDSimpleTypeDefinition) && !(c instanceof XSDModelGroupDefinition) && !(c instanceof XSDAttributeGroupDefinition)) {
        c = c.getContainer();
    }
    Adapter adapter = XSDAdapterFactory.getInstance().adapt(c);
    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) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Adapter(org.eclipse.emf.common.notify.Adapter) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDSchema(org.eclipse.xsd.XSDSchema) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 39 with XSDConcreteComponent

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

the class XSDBaseAdapter method getContainerType.

/**
 * Implements IField getContainerType.  Get parent Complex Type containing the field
 * @return IComplexType
 */
public IComplexType getContainerType() {
    XSDConcreteComponent xsdConcreteComponent = (XSDConcreteComponent) target;
    XSDConcreteComponent parent = null;
    XSDComplexTypeDefinition ct = null;
    for (parent = xsdConcreteComponent.getContainer(); parent != null; ) {
        if (parent instanceof XSDComplexTypeDefinition) {
            ct = (XSDComplexTypeDefinition) parent;
            break;
        }
        parent = parent.getContainer();
    }
    if (ct != null) {
        return (IComplexType) XSDAdapterFactory.getInstance().adapt(ct);
    }
    return null;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) IComplexType(org.eclipse.wst.xsd.ui.internal.adt.facade.IComplexType)

Example 40 with XSDConcreteComponent

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

the class XSDBaseAdapter method isReadOnly.

public boolean isReadOnly() {
    XSDSchema xsdSchema = null;
    try {
        IEditorPart editorPart = null;
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window != null) {
            IWorkbenchPage page = window.getActivePage();
            if (page != null) {
                editorPart = page.getActiveEditor();
            }
        }
        if (target instanceof XSDConcreteComponent) {
            xsdSchema = ((XSDConcreteComponent) target).getSchema();
        }
        if (editorPart == null) {
            return fallBackCheckIsReadOnly();
        }
        XSDSchema editorSchema = (XSDSchema) editorPart.getAdapter(XSDSchema.class);
        if (xsdSchema != null && xsdSchema == editorSchema) {
            return false;
        } else {
            return fallBackCheckIsReadOnly();
        }
    } catch (Exception e) {
    }
    return true;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) XSDSchema(org.eclipse.xsd.XSDSchema)

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