Search in sources :

Example 1 with XSDDOMHelper

use of org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper in project webtools.sourceediting by eclipse.

the class XSDSimpleTypeSection method refresh.

public void refresh() {
    super.refresh();
    setListenerEnabled(false);
    showLink(!hideHyperLink);
    // $NON-NLS-1$
    nameText.setText("");
    // $NON-NLS-1$
    varietyCombo.setText("");
    // $NON-NLS-1$
    typesCombo.setText("");
    fillTypesCombo();
    // $NON-NLS-1$
    typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE_WITH_COLON"));
    if (input instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input;
        String simpleTypeName = st.getName();
        if (simpleTypeName != null) {
            nameText.setText(simpleTypeName);
            nameText.setEditable(true);
        } else {
            // $NON-NLS-1$);
            nameText.setText("**anonymous**");
            nameText.setEditable(false);
        }
        String variety = st.getVariety().getName();
        int intVariety = st.getVariety().getValue();
        XSDDOMHelper domHelper = new XSDDOMHelper();
        if (domHelper.getDerivedByElementFromSimpleType(st.getElement()) != null) {
            if (variety != null) {
                varietyCombo.setText(variety);
                if (intVariety == XSDVariety.ATOMIC) {
                    baseTypeDefinition = st.getBaseTypeDefinition();
                    // $NON-NLS-1$
                    String name = "";
                    if (baseTypeDefinition != null) {
                        name = baseTypeDefinition.getName();
                        if (name == null)
                            name = "";
                    }
                    typesCombo.setText(name);
                    // $NON-NLS-1$
                    typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE_WITH_COLON"));
                } else if (intVariety == XSDVariety.LIST) {
                    itemTypeDefinition = st.getItemTypeDefinition();
                    // $NON-NLS-1$
                    String name = "";
                    if (itemTypeDefinition != null) {
                        name = itemTypeDefinition.getName();
                        if (name == null)
                            name = "";
                    }
                    typesCombo.setText(name);
                    // $NON-NLS-1$
                    typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_ITEM_TYPE"));
                } else if (intVariety == XSDVariety.UNION) {
                    List memberTypesList = st.getMemberTypeDefinitions();
                    StringBuffer sb = new StringBuffer();
                    for (Iterator i = memberTypesList.iterator(); i.hasNext(); ) {
                        XSDSimpleTypeDefinition typeObject = (XSDSimpleTypeDefinition) i.next();
                        String name = typeObject.getQName();
                        if (name != null) {
                            sb.append(name);
                            if (i.hasNext()) {
                                // $NON-NLS-1$
                                sb.append(" ");
                            }
                        }
                    }
                    String memberTypes = sb.toString();
                    typesCombo.setText(memberTypes);
                    // $NON-NLS-1$
                    typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES"));
                }
            }
        }
    }
    setListenerEnabled(true);
}
Also used : XSDDOMHelper(org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List)

Example 2 with XSDDOMHelper

use of org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper 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)

Aggregations

XSDDOMHelper (org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)1 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)1 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)1 NodeList (org.w3c.dom.NodeList)1