Search in sources :

Example 11 with XSDConcreteComponent

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

the class DesignViewNavigationLocation method restoreLocation.

public void restoreLocation() {
    XSDSchema schema = (XSDSchema) getEditorPart().getAdapter(XSDSchema.class);
    Object viewer = getEditorPart().getAdapter(GraphicalViewer.class);
    if (viewer instanceof DesignViewGraphicalViewer) {
        DesignViewGraphicalViewer graphicalViewer = (DesignViewGraphicalViewer) viewer;
        XSDConcreteComponent component = Path.computeComponent(schema, path);
        if (component != null) {
            Adapter adapter = XSDAdapterFactory.getInstance().adapt(component);
            if (adapter instanceof IADTObject) {
                graphicalViewer.setInput((IADTObject) adapter);
            }
        } else if (path.segments.isEmpty()) {
            Adapter adapter = XSDAdapterFactory.getInstance().adapt(schema);
            if (adapter instanceof IADTObject) {
                graphicalViewer.setInput((IADTObject) adapter);
            }
        }
    }
}
Also used : DesignViewGraphicalViewer(org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) EObject(org.eclipse.emf.ecore.EObject) Adapter(org.eclipse.emf.common.notify.Adapter) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 12 with XSDConcreteComponent

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

the class XSDEditPartFactory method createStructureFigure.

public IStructureFigure createStructureFigure(Object model) {
    IStructureFigure figure = delegate.createStructureFigure(model);
    if (model instanceof XSDBaseAdapter) {
        XSDConcreteComponent comp = (XSDConcreteComponent) ((XSDBaseAdapter) model).getTarget();
        boolean isReadOnly = ((XSDBaseAdapter) model).isReadOnly();
        figure.getNameLabel().setIcon(XSDCommonUIUtils.getUpdatedImage(comp, ((XSDBaseAdapter) model).getImage(), isReadOnly));
    }
    return figure;
}
Also used : IStructureFigure(org.eclipse.wst.xsd.ui.internal.adt.design.figures.IStructureFigure) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)

Example 13 with XSDConcreteComponent

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

the class MoveXSDElementAction method run.

/*
   * @see IAction#run()
   */
public void run() {
    int originalIndex = 0;
    for (Iterator particles = parentModelGroup.getContents().iterator(); particles.hasNext(); ) {
        XSDParticle particle = (XSDParticle) particles.next();
        XSDParticleContent particleContent = particle.getContent();
        if (particleContent == selected) {
            parentModelGroup.getContents().remove(particle);
            break;
        }
        originalIndex++;
    }
    int index = 0;
    boolean addedBack = false;
    if (insertType == INSERT_DIRECT) {
        XSDConcreteComponent container = selected.getContainer();
        if (container != null) {
            XSDConcreteComponent container2 = container.getContainer();
            if (container2 instanceof XSDModelGroup) {
                ((XSDModelGroup) container2).getContents().remove(container);
            }
            if (insertAtEnd)
                parentModelGroup.getContents().add(container);
            else
                parentModelGroup.getContents().add(0, container);
            addedBack = true;
        }
        return;
    }
    List particles = parentModelGroup.getContents();
    for (Iterator iterator = particles.iterator(); iterator.hasNext(); ) {
        XSDParticle particle = (XSDParticle) iterator.next();
        XSDParticleContent particleContent = particle.getContent();
        if (insertType == INSERT_BEFORE) {
            if (particleContent == nextRefComponent) {
                parentModelGroup.getContents().add(index, selected.getContainer());
                addedBack = true;
                break;
            }
            if (selected == nextRefComponent && originalIndex == index) {
                parentModelGroup.getContents().add(index, selected.getContainer());
                addedBack = true;
                break;
            }
        } else if (insertType == INSERT_AFTER) {
            if (particleContent == previousRefComponent) {
                parentModelGroup.getContents().add(index + 1, selected.getContainer());
                addedBack = true;
                break;
            }
            if (selected == previousRefComponent && originalIndex == index) {
                parentModelGroup.getContents().add(index, selected.getContainer());
                addedBack = true;
                break;
            }
        }
        index++;
    }
    if (particles.size() == 0) {
        parentModelGroup.getContents().add(selected.getContainer());
        addedBack = true;
    }
    if (!addedBack) {
        parentModelGroup.getContents().add(originalIndex, selected.getContainer());
    }
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) Iterator(java.util.Iterator) XSDParticleContent(org.eclipse.xsd.XSDParticleContent) List(java.util.List) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 14 with XSDConcreteComponent

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

the class XSDSchemaAdapter method getTypes.

public List getTypes() {
    if (types == null) {
        types = new ArrayList();
        XSDSchema schema = (XSDSchema) target;
        List concreteComponentList = new ArrayList();
        for (Iterator i = schema.getContents().iterator(); i.hasNext(); ) {
            XSDConcreteComponent component = (XSDConcreteComponent) i.next();
            if (component instanceof XSDTypeDefinition) {
                concreteComponentList.add(component);
            }
        }
        populateAdapterList(concreteComponentList, types);
    }
    return types;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) XSDSchema(org.eclipse.xsd.XSDSchema) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 15 with XSDConcreteComponent

use of org.eclipse.xsd.XSDConcreteComponent 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)

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