Search in sources :

Example 96 with XSDTypeDefinition

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

the class XSDComplexTypeSection method fillTypesCombo.

private void fillTypesCombo() {
    baseTypeCombo.removeAll();
    baseTypeCombo.add(Messages._UI_COMBO_BROWSE);
    baseTypeCombo.add(Messages._UI_COMBO_NEW);
    // Add the current Type of this attribute if needed
    XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input;
    XSDTypeDefinition baseType = complexType.getBaseType();
    if (baseType != null && baseType.getQName() != null) {
        // no prefix
        String currentTypeName = baseType.getQName(xsdSchema);
        if (currentTypeName != null && !currentTypeName.equals("anyType"))
            baseTypeCombo.add(currentTypeName);
    }
}
Also used : XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 97 with XSDTypeDefinition

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

the class XSDComplexTypeSection method refresh.

/*
   * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
   */
public void refresh() {
    super.refresh();
    if (Display.getCurrent() == null)
        return;
    setListenerEnabled(false);
    showLink(!hideHyperLink);
    try {
        // $NON-NLS-1$
        nameText.setText("");
        // $NON-NLS-1$
        baseTypeCombo.setText("");
        fillTypesCombo();
        if (input instanceof XSDComplexTypeDefinition) {
            XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input;
            String name = complexType.getName();
            if (name == null)
                // $NON-NLS-1$
                name = "";
            // $NON-NLS-1$
            boolean isAnonymousType = name.equals("") ? true : false;
            if (isAnonymousType) {
                // $NON-NLS-1$
                nameText.setText("**anonymous**");
                nameText.setEditable(false);
            } else {
                nameText.setText(name);
                nameText.setEditable(true);
            }
            XSDTypeDefinition baseTypeDefinition = complexType.getBaseTypeDefinition();
            // $NON-NLS-1$
            String baseType = "";
            if (baseTypeDefinition != null) {
                baseType = baseTypeDefinition.getName();
                if (baseType == null) {
                    // $NON-NLS-1$
                    baseType = "";
                } else if (baseType.equals("anyType")) {
                    // $NON-NLS-1$
                    baseType = "";
                }
            }
            baseTypeCombo.setText(baseType);
            // $NON-NLS-1$
            derivedByCombo.setText("");
            int derivationMethod = complexType.getDerivationMethod().getValue();
            XSDDOMHelper domHelper = new XSDDOMHelper();
            if (domHelper.getDerivedByElementFromComplexType(complexType.getElement()) != null) {
                if (derivationMethod == XSDDerivationMethod.EXTENSION) {
                    derivedByCombo.setText(XSDConstants.EXTENSION_ELEMENT_TAG);
                } else if (derivationMethod == XSDDerivationMethod.RESTRICTION) {
                    derivedByCombo.setText(XSDConstants.RESTRICTION_ELEMENT_TAG);
                }
            }
        }
    } finally {
        setListenerEnabled(true);
    }
}
Also used : XSDDOMHelper(org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 98 with XSDTypeDefinition

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

the class XSDElementDeclarationSection method refresh.

/*
   * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
   */
public void refresh() {
    setListenerEnabled(false);
    super.refresh();
    XSDElementDeclaration xsdElementDeclaration = ((XSDElementDeclaration) input).getResolvedElementDeclaration();
    // refresh name
    // $NON-NLS-1$
    nameText.setText("");
    // $NON-NLS-1$
    typeCombo.setText("");
    String name = xsdElementDeclaration.getName();
    if (name != null) {
        nameText.setText(name);
    }
    if (isElementReference) {
        refreshRefCombo();
    }
    // refresh type
    if (input != null) {
        if (input instanceof XSDElementDeclaration) {
            boolean isAnonymous = xsdElementDeclaration.getAnonymousTypeDefinition() != null;
            // XSDTypeDefinition typeDef = XSDUtils.getResolvedType(xsdElementDeclaration);
            XSDTypeDefinition typeDef = xsdElementDeclaration.getResolvedElementDeclaration().getTypeDefinition();
            if (typeDef != null)
                typeName = typeDef.getQName(xsdSchema);
            if (typeName == null) {
                // $NON-NLS-1$
                typeName = "";
            }
            fillTypesCombo();
            if (isAnonymous) {
                typeCombo.setText("**Anonymous**");
                typeName = "**Anonymous**";
            } else {
                if (typeDefinition != null) {
                    typeCombo.setText(typeName);
                } else {
                    // $NON-NLS-1$
                    typeCombo.setText(Messages.UI_NO_TYPE);
                }
            }
            maxCombo.setEnabled(!xsdElementDeclaration.isGlobal() || isElementReference);
            minCombo.setEnabled(!xsdElementDeclaration.isGlobal() || isElementReference);
        }
    }
    // refresh min max
    refreshMinMax();
    setListenerEnabled(true);
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 99 with XSDTypeDefinition

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

the class XSDSimpleTypeSection method fillTypesCombo.

private void fillTypesCombo() {
    typesCombo.removeAll();
    IEditorPart editor = getActiveEditor();
    ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDTypeReferenceEditManager.class);
    if (manager != null) {
        ComponentSpecification[] items = manager.getQuickPicks();
        typesCombo.add(Messages._UI_COMBO_BROWSE);
        typesCombo.add(Messages._UI_COMBO_NEW);
        for (int i = 0; i < items.length; i++) {
            typesCombo.add(items[i].getName());
        }
        // Add the current Type of this attribute if needed
        XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition) input;
        XSDTypeDefinition baseType = simpleType.getBaseType();
        if (baseType != null && baseType.getQName() != null) {
            // no prefix
            String currentTypeName = baseType.getQName(xsdSchema);
            ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName, manager);
            if (// not in quickPick
            ret == null && currentTypeName != null) {
                typesCombo.add(currentTypeName);
            }
        }
    }
}
Also used : XSDTypeReferenceEditManager(org.eclipse.wst.xsd.ui.internal.editor.XSDTypeReferenceEditManager) ComponentSpecification(org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ComponentReferenceEditManager(org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager) IEditorPart(org.eclipse.ui.IEditorPart) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 100 with XSDTypeDefinition

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

the class AddXSDAttributeGroupDefinitionCommand method walkUpInheritance.

private void walkUpInheritance(XSDComplexTypeDefinition ct) {
    updateNames(ct);
    XSDTypeDefinition typeDef = ct.getBaseTypeDefinition();
    if (ct != ct.getRootType()) {
        if (typeDef instanceof XSDComplexTypeDefinition) {
            XSDComplexTypeDefinition ct2 = (XSDComplexTypeDefinition) typeDef;
            walkUpInheritance(ct2);
        }
    }
}
Also used : XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Aggregations

XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)119 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)66 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)57 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)46 ArrayList (java.util.ArrayList)39 XSDParticle (org.eclipse.xsd.XSDParticle)36 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)32 Iterator (java.util.Iterator)26 XSDSchema (org.eclipse.xsd.XSDSchema)26 List (java.util.List)22 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)17 EList (org.eclipse.emf.common.util.EList)16 TreeObject (com.amalto.workbench.models.TreeObject)14 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)14 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)13 XSDTerm (org.eclipse.xsd.XSDTerm)13 XSDFactory (org.eclipse.xsd.XSDFactory)12 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)11 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)10 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)10