Search in sources :

Example 91 with XSDModelGroup

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

the class XSDModelGroupAdapter method getText.

/*
   * (non-Javadoc)
   * 
   * @see org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement#getText()
   */
public String getText() {
    XSDModelGroup xsdModelGroup = getXSDModelGroup();
    StringBuffer result = new StringBuffer();
    String name = xsdModelGroup.getCompositor().getName();
    if (name != null) {
        result.append(name);
    }
    Element element = xsdModelGroup.getElement();
    if (element != null) {
        boolean hasMinOccurs = element.hasAttribute(XSDConstants.MINOCCURS_ATTRIBUTE);
        boolean hasMaxOccurs = element.hasAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE);
        if (hasMinOccurs || hasMaxOccurs) {
            // $NON-NLS-1$
            result.append(" [");
            if (hasMinOccurs) {
                int min = ((XSDParticle) xsdModelGroup.getContainer()).getMinOccurs();
                if (min == XSDParticle.UNBOUNDED) {
                    // $NON-NLS-1$
                    result.append("*");
                } else {
                    result.append(String.valueOf(min));
                }
            } else // print default
            {
                int min = ((XSDParticle) xsdModelGroup.getContainer()).getMinOccurs();
                result.append(String.valueOf(min));
            }
            if (hasMaxOccurs) {
                int max = ((XSDParticle) xsdModelGroup.getContainer()).getMaxOccurs();
                // $NON-NLS-1$
                result.append("..");
                if (max == XSDParticle.UNBOUNDED) {
                    // $NON-NLS-1$
                    result.append("*");
                } else {
                    result.append(String.valueOf(max));
                }
            } else // print default
            {
                // $NON-NLS-1$
                result.append("..");
                int max = ((XSDParticle) xsdModelGroup.getContainer()).getMaxOccurs();
                result.append(String.valueOf(max));
            }
            // $NON-NLS-1$
            result.append("]");
        }
    }
    return result.toString();
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) IGraphElement(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IGraphElement) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement) Element(org.w3c.dom.Element) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 92 with XSDModelGroup

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

the class XSDModelGroupAdapter method getChildren.

public ITreeElement[] getChildren() {
    XSDModelGroup xsdModelGroup = getXSDModelGroup();
    List list = new ArrayList();
    for (Iterator i = xsdModelGroup.getContents().iterator(); i.hasNext(); ) {
        Object object = i.next();
        XSDParticleContent particle = ((XSDParticle) object).getContent();
        if (particle instanceof XSDElementDeclaration) {
            list.add(particle);
        } else if (particle instanceof XSDWildcard) {
            list.add(particle);
        } else if (particle instanceof XSDModelGroup) {
            list.add(particle);
        } else if (particle instanceof XSDModelGroupDefinition) {
            // list.add(((XSDModelGroupDefinition)particle).getResolvedModelGroupDefinition());
            list.add(particle);
        }
    }
    List adapterList = new ArrayList();
    populateAdapterList(list, adapterList);
    return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]);
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) XSDParticleContent(org.eclipse.xsd.XSDParticleContent) XSDWildcard(org.eclipse.xsd.XSDWildcard) ArrayList(java.util.ArrayList) List(java.util.List) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 93 with XSDModelGroup

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

the class XSDElementDragAndDropCommand method doDrop.

protected void doDrop(List siblings, GraphicalEditPart movingEditPart) {
    commonSetup(siblings, movingEditPart);
    // Can common this code up with XSDAttributeDragAndDropCommand...
    if ((previousRefComponent instanceof XSDElementDeclaration || previousRefComponent instanceof XSDWildcard) && (nextRefComponent instanceof XSDElementDeclaration || nextRefComponent instanceof XSDWildcard)) {
        XSDModelGroup modelGroup = (XSDModelGroup) previousRefComponent.getContainer().getContainer();
        if (parentEditPart != null)
            modelGroup = ((ModelGroupEditPart) parentEditPart).getXSDModelGroup();
        action = new MoveXSDElementAction(modelGroup, xsdComponentToDrag, previousRefComponent, nextRefComponent);
    } else if (previousRefComponent == null && (nextRefComponent instanceof XSDElementDeclaration || nextRefComponent instanceof XSDWildcard)) {
        if (closerSibling == ABOVE_IS_CLOSER) {
            if (leftSiblingEditPart == null) {
                action = new MoveXSDElementAction(topMostGroup.getXSDModelGroup(), xsdComponentToDrag, null, null, false);
            } else if (parentEditPart != null) {
                action = new MoveXSDElementAction(((ModelGroupEditPart) parentEditPart).getXSDModelGroup(), xsdComponentToDrag, previousRefComponent, nextRefComponent);
            }
        } else {
            XSDModelGroup modelGroup = (XSDModelGroup) nextRefComponent.getContainer().getContainer();
            action = new MoveXSDElementAction(modelGroup, xsdComponentToDrag, previousRefComponent, nextRefComponent);
        }
    } else if ((previousRefComponent instanceof XSDElementDeclaration || previousRefComponent instanceof XSDWildcard) && nextRefComponent == null) {
        XSDModelGroup modelGroup = (XSDModelGroup) previousRefComponent.getContainer().getContainer();
        if (parentEditPart != null)
            modelGroup = ((ModelGroupEditPart) parentEditPart).getXSDModelGroup();
        if (closerSibling == ABOVE_IS_CLOSER) {
            action = new MoveXSDElementAction(modelGroup, xsdComponentToDrag, previousRefComponent, nextRefComponent);
        } else {
            if (rightSiblingEditPart == null) {
                action = new MoveXSDElementAction(topMostGroup.getXSDModelGroup(), xsdComponentToDrag, null, null, true);
            } else {
                action = new MoveXSDElementAction(modelGroup, xsdComponentToDrag, previousRefComponent, nextRefComponent);
            }
        }
    }
    if (action != null)
        canExecute = action.canMove();
}
Also used : ModelGroupEditPart(org.eclipse.wst.xsd.ui.internal.design.editparts.ModelGroupEditPart) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) MoveXSDElementAction(org.eclipse.wst.xsd.ui.internal.actions.MoveXSDElementAction) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDWildcard(org.eclipse.xsd.XSDWildcard)

Example 94 with XSDModelGroup

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

the class ModelGroupDefinitionReferenceEditPart method getModelChildren.

protected List getModelChildren() {
    List list = new ArrayList();
    XSDModelGroupDefinitionAdapter adapter = (XSDModelGroupDefinitionAdapter) getModel();
    XSDModelGroupDefinition groupDef = ((XSDModelGroupDefinition) adapter.getTarget());
    XSDModelGroupDefinition resolvedGroupDef = groupDef.getResolvedModelGroupDefinition();
    XSDModelGroup xsdModelGroup = resolvedGroupDef.getModelGroup();
    ArrayList listOfVisibleGroupRefs = new ArrayList();
    for (EditPart ep = getParent(); ep != null; ) {
        Object object = ep.getModel();
        if (object instanceof XSDModelGroupDefinitionAdapter) {
            Object model = ((XSDModelGroupDefinitionAdapter) object).getTarget();
            if (model instanceof XSDModelGroupDefinition) {
                listOfVisibleGroupRefs.add(((XSDModelGroupDefinition) model).getResolvedModelGroupDefinition());
            }
        }
        ep = ep.getParent();
    }
    boolean isCyclic = (listOfVisibleGroupRefs.contains(resolvedGroupDef));
    if (xsdModelGroup != null && !isCyclic)
        list.add(XSDAdapterFactory.getInstance().adapt(xsdModelGroup));
    if (isCyclic)
        list.add(new TargetConnectionSpaceFiller(null));
    return list;
}
Also used : XSDModelGroupDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupDefinitionAdapter) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) ArrayList(java.util.ArrayList) BaseEditPart(org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseEditPart) EditPart(org.eclipse.gef.EditPart) List(java.util.List) ArrayList(java.util.ArrayList) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) TargetConnectionSpaceFiller(org.eclipse.wst.xsd.ui.internal.design.editparts.model.TargetConnectionSpaceFiller)

Example 95 with XSDModelGroup

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

the class XSDModelGroupSection method refresh.

public void refresh() {
    super.refresh();
    if (isReadOnly) {
        composite.setEnabled(false);
    } else {
        composite.setEnabled(true);
    }
    setListenerEnabled(false);
    if (input != null) {
        if (input instanceof XSDModelGroup) {
            XSDModelGroup particle = (XSDModelGroup) input;
            String modelType = particle.getCompositor().getName();
            modelGroupCombo.setText(modelType);
            minCombo.setEnabled(!(particle.eContainer() instanceof XSDModelGroupDefinition));
            maxCombo.setEnabled(!(particle.eContainer() instanceof XSDModelGroupDefinition));
        }
    }
    refreshMinMax();
    setListenerEnabled(true);
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition)

Aggregations

XSDModelGroup (org.eclipse.xsd.XSDModelGroup)119 XSDParticle (org.eclipse.xsd.XSDParticle)93 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)87 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)76 ArrayList (java.util.ArrayList)33 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)32 XSDTerm (org.eclipse.xsd.XSDTerm)28 XSDFactory (org.eclipse.xsd.XSDFactory)26 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)26 Test (org.junit.Test)25 XSDSchema (org.eclipse.xsd.XSDSchema)23 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)22 EList (org.eclipse.emf.common.util.EList)21 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)20 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)19 List (java.util.List)18 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)18 Iterator (java.util.Iterator)16 XSDWildcard (org.eclipse.xsd.XSDWildcard)16 TreeObject (com.amalto.workbench.models.TreeObject)15