Search in sources :

Example 1 with XSDModelGroupDefinition

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

the class XSDModelGroupAdapter method getActions.

/*
   * (non-Javadoc)
   * 
   * @see org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider#getActions(java.lang.Object)
   */
public String[] getActions(Object object) {
    Collection actionIDs = new ArrayList();
    actionIDs.add(AddXSDElementAction.ID);
    actionIDs.add(AddXSDElementAction.REF_ID);
    actionIDs.add(AddXSDAnyElementAction.ID);
    // Add Element Ref
    actionIDs.add(BaseSelectionAction.SEPARATOR_ID);
    actionIDs.add(AddXSDModelGroupAction.SEQUENCE_ID);
    actionIDs.add(AddXSDModelGroupAction.CHOICE_ID);
    actionIDs.add(AddXSDModelGroupAction.ALL_ID);
    actionIDs.add(BaseSelectionAction.SEPARATOR_ID);
    actionIDs.add(AddXSDModelGroupDefinitionAction.MODELGROUPDEFINITIONREF_ID);
    // actionIDs.add(AddFieldAction.ID);
    actionIDs.add(BaseSelectionAction.SEPARATOR_ID);
    // Add Any
    actionIDs.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_SET_MULTIPLICITY);
    actionIDs.add(SetMultiplicityAction.REQUIRED_ID);
    actionIDs.add(SetMultiplicityAction.ZERO_OR_ONE_ID);
    actionIDs.add(SetMultiplicityAction.ZERO_OR_MORE_ID);
    actionIDs.add(SetMultiplicityAction.ONE_OR_MORE_ID);
    actionIDs.add(BaseSelectionAction.SUBMENU_END_ID);
    if (!(getParent(target) instanceof XSDModelGroupDefinition)) {
        actionIDs.add(BaseSelectionAction.SEPARATOR_ID);
        actionIDs.add(DeleteAction.ID);
    }
    actionIDs.add(BaseSelectionAction.SEPARATOR_ID);
    actionIDs.add(ShowPropertiesViewAction.ID);
    return (String[]) actionIDs.toArray(new String[0]);
}
Also used : ArrayList(java.util.ArrayList) Collection(java.util.Collection) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition)

Example 2 with XSDModelGroupDefinition

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

the class XSDSchemaAdapter method getGroups.

public List getGroups(XSDSchema schema, boolean showFromIncludes) {
    List groups = schema.getModelGroupDefinitions();
    List list = new ArrayList();
    for (Iterator i = groups.iterator(); i.hasNext(); ) {
        XSDModelGroupDefinition group = (XSDModelGroupDefinition) i.next();
        if (shouldShowComponent(group, schema, showFromIncludes)) {
            list.add(group);
        }
    }
    List adapterList = new ArrayList();
    populateAdapterList(list, adapterList);
    return adapterList;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition)

Example 3 with XSDModelGroupDefinition

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

the class XSDVisitorForFields method visitModelGroupDefinition.

public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroupDef) {
    // listen to definition in case it changes
    XSDModelGroupDefinition resolvedModelGroupDef = modelGroupDef.getResolvedModelGroupDefinition();
    if (visitedGroups.contains(resolvedModelGroupDef.getModelGroup()))
        return;
    if (modelGroupDef.isModelGroupDefinitionReference()) {
        // if it's a reference we need to listen to the reference incase it changes
        if (!thingsWeNeedToListenTo.contains(modelGroupDef))
            thingsWeNeedToListenTo.add(modelGroupDef);
    }
    super.visitModelGroupDefinition(modelGroupDef);
}
Also used : XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition)

Example 4 with XSDModelGroupDefinition

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

the class AddXSDModelGroupAction method run.

public void run() {
    Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
    if (selection instanceof XSDBaseAdapter) {
        XSDConcreteComponent xsdComponent = (XSDConcreteComponent) ((XSDBaseAdapter) selection).getTarget();
        AddXSDModelGroupCommand command = null;
        if (xsdComponent instanceof XSDElementDeclaration) {
            XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) xsdComponent;
            command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdElementDeclaration, xsdCompositor);
            getCommandStack().execute(command);
        } else if (xsdComponent instanceof XSDModelGroup) {
            XSDModelGroup xsdModelGroup = (XSDModelGroup) xsdComponent;
            command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdModelGroup, xsdCompositor);
            getCommandStack().execute(command);
        } else if (xsdComponent instanceof XSDComplexTypeDefinition || xsdComponent instanceof XSDModelGroupDefinition) {
            command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdComponent, xsdCompositor);
            getCommandStack().execute(command);
        }
        if (command != null) {
            Adapter adapter = XSDAdapterFactory.getInstance().adapt(command.getAddedComponent());
            if (adapter != null)
                provider.setSelection(new StructuredSelection(adapter));
        }
    }
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) AddXSDModelGroupCommand(org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDModelGroupCommand) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) Adapter(org.eclipse.emf.common.notify.Adapter) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition)

Example 5 with XSDModelGroupDefinition

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

the class AddXSDElementCommand method createXSDElementDeclaration.

protected XSDParticle createXSDElementDeclaration() {
    // $NON-NLS-1$
    XSDSimpleTypeDefinition type = xsdModelGroup.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string");
    XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration();
    XSDConcreteComponent comp = xsdModelGroup.getContainer();
    ArrayList usedAttributeNames = new ArrayList();
    XSDCommonUIUtils.resetVisitedGroupsStack();
    usedAttributeNames.addAll(XSDCommonUIUtils.getChildElements(xsdModelGroup));
    while (comp != null) {
        if (comp instanceof XSDModelGroupDefinition) {
            usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes((XSDModelGroupDefinition) comp));
            break;
        } else if (comp instanceof XSDComplexTypeDefinition) {
            usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes((XSDComplexTypeDefinition) comp));
            usedAttributeNames.addAll(XSDCommonUIUtils.getInheritedAttributes((XSDComplexTypeDefinition) comp));
            break;
        }
        comp = comp.getContainer();
    }
    element.setName(XSDCommonUIUtils.createUniqueElementName(nameToAdd == null ? "NewElement" : nameToAdd, // $NON-NLS-1$
    usedAttributeNames));
    element.setTypeDefinition(type);
    XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
    particle.setContent(element);
    addedXSDConcreteComponent = element;
    return particle;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle)

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