Search in sources :

Example 1 with XSDModelGroupImpl

use of org.eclipse.xsd.impl.XSDModelGroupImpl in project tmdm-studio-se by Talend.

the class Util method doChangeElementTypeToSequence.

private static IStatus doChangeElementTypeToSequence(XSDComplexTypeDefinition compx, int maxOccurs) {
    XSDParticleImpl partCnt = (XSDParticleImpl) compx.getContent();
    XSDModelGroupImpl mdlGrp = (XSDModelGroupImpl) partCnt.getTerm();
    if ((maxOccurs > 1 || maxOccurs == -1) && mdlGrp.getCompositor() != XSDCompositor.SEQUENCE_LITERAL) {
        // change the parent element to xsd:sequence
        if (!MessageDialog.openConfirm(null, Messages.Util_32, Messages.Util_33)) {
            return Status.CANCEL_STATUS;
        }
        mdlGrp.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
        compx.updateElement();
    }
    return Status.OK_STATUS;
}
Also used : XSDParticleImpl(org.eclipse.xsd.impl.XSDParticleImpl) XSDModelGroupImpl(org.eclipse.xsd.impl.XSDModelGroupImpl)

Example 2 with XSDModelGroupImpl

use of org.eclipse.xsd.impl.XSDModelGroupImpl in project tmdm-studio-se by Talend.

the class ConceptComposite method updateElementGroup.

private void updateElementGroup(XSDComplexTypeDefinition type) {
    if (type != null) {
        XSDParticleImpl partCnt = (XSDParticleImpl) type.getContent();
        if (partCnt != null) {
            XSDModelGroupImpl mdlGrp = (XSDModelGroupImpl) partCnt.getTerm();
            XSDCompositor typeComposite = mdlGrp.getCompositor();
            if (typeComposite.equals(XSDCompositor.SEQUENCE_LITERAL)) {
                setSequence();
            } else if (typeComposite.equals(XSDCompositor.ALL_LITERAL)) {
                setAll();
            } else if (typeComposite.equals(XSDCompositor.CHOICE_LITERAL)) {
                setChoice();
            }
            enableRadioButtons(false);
        }
    }
}
Also used : XSDParticleImpl(org.eclipse.xsd.impl.XSDParticleImpl) XSDCompositor(org.eclipse.xsd.XSDCompositor) XSDModelGroupImpl(org.eclipse.xsd.impl.XSDModelGroupImpl)

Example 3 with XSDModelGroupImpl

use of org.eclipse.xsd.impl.XSDModelGroupImpl in project webtools.sourceediting by eclipse.

the class AddXSDElementAction method run.

public void run() {
    Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
    if (selection instanceof XSDBaseAdapter) {
        selection = ((XSDBaseAdapter) selection).getTarget();
    }
    AddXSDElementCommand command = null;
    if (selection instanceof XSDComplexTypeDefinition) {
        command = new AddXSDElementCommand(getText(), (XSDComplexTypeDefinition) selection);
        command.setReference(isReference);
        getCommandStack().execute(command);
    } else if (selection instanceof XSDModelGroupDefinition) {
        command = new AddXSDElementCommand(getText(), (XSDModelGroupDefinition) selection);
        command.setReference(isReference);
        getCommandStack().execute(command);
    } else if (selection instanceof XSDSchema) {
        command = new AddXSDElementCommand(getText(), (XSDSchema) selection);
        getCommandStack().execute(command);
    } else if (selection instanceof XSDModelGroup) {
        XSDModelGroup modelGroup = (XSDModelGroup) selection;
        XSDConcreteComponent component = modelGroup.getContainer();
        XSDComplexTypeDefinition ct = null;
        while (component != null) {
            if (component instanceof XSDComplexTypeDefinition) {
                ct = (XSDComplexTypeDefinition) component;
                break;
            }
            component = component.getContainer();
        }
        if (ct != null) {
            command = new AddXSDElementCommand(getText(), (XSDModelGroup) selection, ct);
        } else {
            command = new AddXSDElementCommand(getText(), (XSDModelGroup) selection);
        }
        command.setReference(isReference);
        getCommandStack().execute(command);
    } else if (selection instanceof XSDElementDeclaration || selection instanceof XSDAttributeUse) {
        XSDConcreteComponent xsdConcreteComponent = (XSDConcreteComponent) selection;
        XSDConcreteComponent parent = null;
        XSDComplexTypeDefinition ct = null;
        XSDModelGroupDefinition group = null;
        XSDModelGroupImpl ctGroup = null;
        for (parent = xsdConcreteComponent.getContainer(); parent != null; ) {
            if (parent instanceof XSDComplexTypeDefinition) {
                ct = (XSDComplexTypeDefinition) parent;
                break;
            } else if (parent instanceof XSDModelGroupDefinition) {
                group = (XSDModelGroupDefinition) parent;
                break;
            } else if (parent instanceof XSDModelGroupImpl) {
                ctGroup = (XSDModelGroupImpl) parent;
                break;
            }
            parent = parent.getContainer();
        }
        if (ct != null) {
            command = new AddXSDElementCommand(getText(), ct);
            command.setReference(isReference);
            getCommandStack().execute(command);
        } else if (ctGroup != null) {
            XSDElementDeclaration sel = (XSDElementDeclaration) selection;
            int index = ctGroup.getContents().indexOf(sel.eContainer());
            command = new AddXSDElementCommand(getText(), ctGroup, getId(), index);
            command.setReference(isReference);
            getCommandStack().execute(command);
        } else if (group != null) {
            command = new AddXSDElementCommand(getText(), group);
            command.setReference(isReference);
            getCommandStack().execute(command);
        }
    }
    if (command != null) {
        addedComponent = command.getAddedComponent();
        Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent);
        selectAddedComponent(adapter);
    }
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) Adapter(org.eclipse.emf.common.notify.Adapter) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AddXSDElementCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDElementCommand) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDSchema(org.eclipse.xsd.XSDSchema) XSDModelGroupImpl(org.eclipse.xsd.impl.XSDModelGroupImpl)

Aggregations

XSDModelGroupImpl (org.eclipse.xsd.impl.XSDModelGroupImpl)3 XSDParticleImpl (org.eclipse.xsd.impl.XSDParticleImpl)2 Adapter (org.eclipse.emf.common.notify.Adapter)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)1 AddXSDElementCommand (org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDElementCommand)1 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)1 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)1 XSDCompositor (org.eclipse.xsd.XSDCompositor)1 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)1 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)1 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)1 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)1 XSDSchema (org.eclipse.xsd.XSDSchema)1