Search in sources :

Example 21 with XSDWildcard

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

the class XSDVisitorForFields method visitAttributeGroupDefinition.

public void visitAttributeGroupDefinition(XSDAttributeGroupDefinition attributeGroup) {
    for (Iterator it = attributeGroup.getContents().iterator(); it.hasNext(); ) {
        Object o = it.next();
        if (o instanceof XSDAttributeUse) {
            XSDAttributeUse attributeUse = (XSDAttributeUse) o;
            concreteComponentList.add(attributeUse.getAttributeDeclaration());
            thingsWeNeedToListenTo.add(attributeUse.getAttributeDeclaration());
        } else if (o instanceof XSDAttributeGroupDefinition) {
            XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) o;
            thingsWeNeedToListenTo.add(attrGroup);
            if (attrGroup.isAttributeGroupDefinitionReference()) {
                attrGroup = attrGroup.getResolvedAttributeGroupDefinition();
                visitAttributeGroupDefinition(attrGroup);
            }
        }
    }
    XSDWildcard anyAttribute = attributeGroup.getAttributeWildcardContent();
    if (anyAttribute != null) {
        concreteComponentList.add(anyAttribute);
        thingsWeNeedToListenTo.add(anyAttribute);
    }
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) Iterator(java.util.Iterator) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 22 with XSDWildcard

use of org.eclipse.xsd.XSDWildcard 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 23 with XSDWildcard

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

the class XSDAnyElementContentsSection method refresh.

/*
   * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
   */
public void refresh() {
    setListenerEnabled(false);
    // $NON-NLS-1$
    namespaceCombo.setText("");
    // $NON-NLS-1$
    processContentsCombo.setText("");
    if (input != null) {
        if (input instanceof XSDWildcard) {
            XSDWildcard wildcard = (XSDWildcard) input;
            if (wildcard.isSetLexicalNamespaceConstraint()) {
                namespaceCombo.setText(wildcard.getStringLexicalNamespaceConstraint());
            } else {
                namespaceCombo.setText("");
            }
            if (wildcard.isSetProcessContents()) {
                XSDProcessContents pc = wildcard.getProcessContents();
                processContentsCombo.setText(pc.getName());
            }
            if (wildcard.eContainer() instanceof XSDParticle) {
                minCombo.setEnabled(!isReadOnly);
                maxCombo.setEnabled(!isReadOnly);
            } else {
                minCombo.setEnabled(false);
                maxCombo.setEnabled(false);
            }
        }
    }
    refreshMinMax();
    setListenerEnabled(true);
}
Also used : XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDParticle(org.eclipse.xsd.XSDParticle) XSDProcessContents(org.eclipse.xsd.XSDProcessContents)

Example 24 with XSDWildcard

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

the class DeleteCommand method execute.

public void execute() {
    XSDVisitor visitor = new XSDVisitor() {

        public void visitElementDeclaration(org.eclipse.xsd.XSDElementDeclaration element) {
            if (element.getTypeDefinition() == target) {
                // $NON-NLS-1$
                XSDSimpleTypeDefinition type = target.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string");
                element.setTypeDefinition(type);
            }
            super.visitElementDeclaration(element);
        }
    };
    XSDConcreteComponent parent = target.getContainer();
    XSDSchema schema = target.getSchema();
    try {
        beginRecording(parent.getElement());
        boolean doCleanup = false;
        if (target instanceof XSDModelGroup || target instanceof XSDElementDeclaration || target instanceof XSDModelGroupDefinition) {
            doCleanup = true;
            if (parent instanceof XSDParticle) {
                if (parent.getContainer() instanceof XSDModelGroup) {
                    XSDModelGroup modelGroup = (XSDModelGroup) ((XSDParticle) parent).getContainer();
                    modelGroup.getContents().remove(parent);
                } else if (parent.getContainer() instanceof XSDComplexTypeDefinition) {
                    XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) parent.getContainer();
                    complexType.setContent(null);
                }
            } else if (parent instanceof XSDSchema) {
                visitor.visitSchema(target.getSchema());
                ((XSDSchema) parent).getContents().remove(target);
            } else if (parent instanceof XSDRedefine) {
                Object adapter = target.eAdapters().get(0);
                if (adapter instanceof XSDModelGroupDefinitionAdapter) {
                    ((XSDModelGroupDefinitionAdapter) adapter).setReadOnly(true);
                    ((XSDModelGroupDefinitionAdapter) adapter).setChangeReadOnlyField(true);
                }
                ((XSDRedefine) parent).getContents().remove(target);
            }
        } else if (target instanceof XSDAttributeDeclaration) {
            doCleanup = true;
            if (parent instanceof XSDAttributeUse) {
                EObject obj = parent.eContainer();
                XSDComplexTypeDefinition complexType = null;
                while (obj != null) {
                    if (obj instanceof XSDComplexTypeDefinition) {
                        complexType = (XSDComplexTypeDefinition) obj;
                        break;
                    }
                    obj = obj.eContainer();
                }
                if (complexType != null) {
                    complexType.getAttributeContents().remove(parent);
                }
                if (parent.getContainer() instanceof XSDAttributeGroupDefinition) {
                    XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) parent.getContainer();
                    attrGroup.getContents().remove(parent);
                }
            } else if (parent instanceof XSDSchema) {
                visitor.visitSchema(target.getSchema());
                ((XSDSchema) parent).getContents().remove(target);
            }
        } else if (target instanceof XSDAttributeGroupDefinition && parent instanceof XSDComplexTypeDefinition) {
            doCleanup = true;
            ((XSDComplexTypeDefinition) parent).getAttributeContents().remove(target);
        } else if (target instanceof XSDEnumerationFacet) {
            XSDEnumerationFacet enumerationFacet = (XSDEnumerationFacet) target;
            enumerationFacet.getSimpleTypeDefinition().getFacetContents().remove(enumerationFacet);
        } else if (target instanceof XSDWildcard) {
            if (parent instanceof XSDParticle) {
                if (parent.getContainer() instanceof XSDModelGroup) {
                    XSDModelGroup modelGroup = (XSDModelGroup) ((XSDParticle) parent).getContainer();
                    modelGroup.getContents().remove(parent);
                }
            } else if (parent instanceof XSDComplexTypeDefinition) {
                ((XSDComplexTypeDefinition) parent).setAttributeWildcardContent(null);
            } else if (parent instanceof XSDAttributeGroupDefinition) {
                ((XSDAttributeGroupDefinition) parent).setAttributeWildcardContent(null);
            }
        } else if (target instanceof XSDTypeDefinition && parent instanceof XSDElementDeclaration) {
            doCleanup = true;
            ((XSDElementDeclaration) parent).setTypeDefinition(target.resolveSimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string"));
        } else {
            if (parent instanceof XSDSchema) {
                doCleanup = true;
                visitor.visitSchema(target.getSchema());
                ((XSDSchema) parent).getContents().remove(target);
            } else if (parent instanceof XSDRedefine) {
                doCleanup = false;
                EList contents = ((XSDRedefine) parent).getContents();
                Object adapter = target.eAdapters().get(0);
                if (adapter instanceof XSDComplexTypeDefinitionAdapter) {
                    ((XSDComplexTypeDefinitionAdapter) adapter).setReadOnly(true);
                    ((XSDComplexTypeDefinitionAdapter) adapter).setChangeReadOnlyField(true);
                } else if (adapter instanceof XSDSimpleTypeDefinitionAdapter) {
                    ((XSDSimpleTypeDefinitionAdapter) adapter).setReadOnly(true);
                    ((XSDSimpleTypeDefinitionAdapter) adapter).setChangeReadOnlyField(true);
                } else if (adapter instanceof XSDAttributeGroupDefinitionAdapter) {
                    ((XSDAttributeGroupDefinitionAdapter) adapter).setReadOnly(true);
                    ((XSDAttributeGroupDefinitionAdapter) adapter).setChangeReadOnlyField(true);
                }
                contents.remove(target);
            }
        }
        if (doCleanup)
            XSDDirectivesManager.removeUnusedXSDImports(schema);
    } finally {
        endRecording();
    }
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDVisitor(org.eclipse.wst.xsd.ui.internal.adapters.XSDVisitor) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDSimpleTypeDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDSimpleTypeDefinitionAdapter) XSDEnumerationFacet(org.eclipse.xsd.XSDEnumerationFacet) EObject(org.eclipse.emf.ecore.EObject) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDSchema(org.eclipse.xsd.XSDSchema) XSDComplexTypeDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter) XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDAttributeGroupDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDAttributeGroupDefinitionAdapter) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) EList(org.eclipse.emf.common.util.EList) XSDModelGroupDefinitionAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupDefinitionAdapter) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) EObject(org.eclipse.emf.ecore.EObject) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration)

Example 25 with XSDWildcard

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

the class XSDAdapterFactory method createAdapter.

public Adapter createAdapter(Notifier target) {
    XSDSwitch xsdSwitch = new XSDSwitch() {

        public Object caseXSDSchemaDirective(XSDSchemaDirective object) {
            return new XSDSchemaDirectiveAdapter();
        }

        public Object caseXSDWildcard(XSDWildcard object) {
            return new XSDWildcardAdapter();
        }

        public Object caseXSDAttributeGroupDefinition(XSDAttributeGroupDefinition object) {
            return new XSDAttributeGroupDefinitionAdapter();
        }

        public Object caseXSDModelGroupDefinition(XSDModelGroupDefinition object) {
            return new XSDModelGroupDefinitionAdapter();
        }

        public Object caseXSDAttributeDeclaration(XSDAttributeDeclaration object) {
            return new XSDAttributeDeclarationAdapter();
        }

        public Object caseXSDAttributeUse(XSDAttributeUse object) {
            return new XSDAttributeUseAdapter();
        }

        public Object caseXSDParticle(XSDParticle object) {
            return new XSDParticleAdapter();
        }

        public Object caseXSDElementDeclaration(XSDElementDeclaration object) {
            return new XSDElementDeclarationAdapter();
        }

        public Object caseXSDSimpleTypeDefinition(XSDSimpleTypeDefinition object) {
            return new XSDSimpleTypeDefinitionAdapter();
        }

        public Object caseXSDComplexTypeDefinition(XSDComplexTypeDefinition object) {
            // 
            if (// $NON-NLS-1$
            "anyType".equals(object.getName())) {
                return new XSDAnyTypeDefinitionAdapter();
            } else {
                return new XSDComplexTypeDefinitionAdapter();
            }
        }

        public Object caseXSDModelGroup(XSDModelGroup object) {
            return new XSDModelGroupAdapter();
        }

        public Object caseXSDSchema(XSDSchema object) {
            return new XSDSchemaAdapter();
        }

        public Object caseXSDEnumerationFacet(XSDEnumerationFacet object) {
            return new XSDEnumerationFacetAdapter();
        }

        public Object caseXSDRedefine(XSDRedefine object) {
            return new XSDRedefineAdapter();
        }
    };
    Object o = xsdSwitch.doSwitch((EObject) target);
    Adapter result = null;
    if (o instanceof Adapter) {
        result = (Adapter) o;
    } else {
    // Thread.dumpStack();
    }
    return result;
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDRedefine(org.eclipse.xsd.XSDRedefine) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) Adapter(org.eclipse.emf.common.notify.Adapter) XSDEnumerationFacet(org.eclipse.xsd.XSDEnumerationFacet) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDSchema(org.eclipse.xsd.XSDSchema) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDSwitch(org.eclipse.xsd.util.XSDSwitch) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDSchemaDirective(org.eclipse.xsd.XSDSchemaDirective) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) EObject(org.eclipse.emf.ecore.EObject) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration)

Aggregations

XSDWildcard (org.eclipse.xsd.XSDWildcard)25 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)16 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)15 XSDParticle (org.eclipse.xsd.XSDParticle)13 ArrayList (java.util.ArrayList)10 Iterator (java.util.Iterator)10 EList (org.eclipse.emf.common.util.EList)10 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)9 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)8 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)8 XSDTerm (org.eclipse.xsd.XSDTerm)8 List (java.util.List)7 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)7 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)6 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)6 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)6 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)5 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)5 TreeObject (com.amalto.workbench.models.TreeObject)4 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)4