Search in sources :

Example 1 with NamedList

use of com.twinsoft.convertigo.eclipse.views.schema.SchemaViewContentProvider.NamedList in project convertigo by convertigo.

the class SchemaViewLabelProvider method getText.

public String getText(Object element) {
    String txt = null;
    if (element instanceof XmlSchema) {
        XmlSchema schema = (XmlSchema) element;
        String prefix = SchemaMeta.getPrefix(schema);
        txt = prefix + "{" + schema.getTargetNamespace() + "}";
    } else if (element instanceof XmlSchemaImport) {
        txt = "import " + getText(((XmlSchemaImport) element).getSchema());
    } else if (element instanceof XmlSchemaInclude) {
        // txt = "include " + "(" +((XmlSchemaInclude) element).getSchemaLocation() +")";
        txt = "include " + getText(((XmlSchemaInclude) element).getSchema());
    } else if (element instanceof XmlSchemaDocumentation || element instanceof XmlSchemaAppInfo) {
        NodeList nl = element instanceof XmlSchemaDocumentation ? ((XmlSchemaDocumentation) element).getMarkup() : ((XmlSchemaAppInfo) element).getMarkup();
        if (nl != null && nl.getLength() > 0) {
            txt = nl.item(0).getTextContent();
        } else {
            txt = "...";
        }
    } else if (element instanceof XmlSchemaObject) {
        if (element instanceof XmlSchemaElement) {
            if (((XmlSchemaElement) element).getRefName() == null) {
                txt = ((XmlSchemaElement) element).getName();
            }
        } else if (element instanceof XmlSchemaAttribute) {
            txt = ((XmlSchemaAttribute) element).getName();
        } else if (element instanceof XmlSchemaAttributeGroup) {
            txt = ((XmlSchemaAttributeGroup) element).getName().getLocalPart();
        } else if (element instanceof XmlSchemaGroup) {
            txt = ((XmlSchemaGroup) element).getName().getLocalPart();
        } else if (element instanceof XmlSchemaType) {
            XmlSchemaType type = (XmlSchemaType) element;
            String name = type.getName();
            if (name != null) {
                txt = name;
            }
        }
        if (txt == null) {
            txt = element.getClass().getSimpleName().substring(9);
            txt = "xsd:" + Character.toLowerCase(txt.charAt(0)) + txt.substring(1);
        }
    } else if (element instanceof NamedList) {
        txt = ((NamedList) element).getName();
    } else {
        txt = "<?>";
    }
    return txt;
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) NamedList(com.twinsoft.convertigo.eclipse.views.schema.SchemaViewContentProvider.NamedList) NodeList(org.w3c.dom.NodeList) XmlSchemaAttributeGroup(org.apache.ws.commons.schema.XmlSchemaAttributeGroup) XmlSchemaDocumentation(org.apache.ws.commons.schema.XmlSchemaDocumentation) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaAttribute(org.apache.ws.commons.schema.XmlSchemaAttribute) XmlSchemaGroup(org.apache.ws.commons.schema.XmlSchemaGroup) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaImport(org.apache.ws.commons.schema.XmlSchemaImport) XmlSchemaInclude(org.apache.ws.commons.schema.XmlSchemaInclude) XmlSchemaAppInfo(org.apache.ws.commons.schema.XmlSchemaAppInfo)

Aggregations

NamedList (com.twinsoft.convertigo.eclipse.views.schema.SchemaViewContentProvider.NamedList)1 XmlSchema (org.apache.ws.commons.schema.XmlSchema)1 XmlSchemaAppInfo (org.apache.ws.commons.schema.XmlSchemaAppInfo)1 XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)1 XmlSchemaAttributeGroup (org.apache.ws.commons.schema.XmlSchemaAttributeGroup)1 XmlSchemaDocumentation (org.apache.ws.commons.schema.XmlSchemaDocumentation)1 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)1 XmlSchemaGroup (org.apache.ws.commons.schema.XmlSchemaGroup)1 XmlSchemaImport (org.apache.ws.commons.schema.XmlSchemaImport)1 XmlSchemaInclude (org.apache.ws.commons.schema.XmlSchemaInclude)1 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)1 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)1 NodeList (org.w3c.dom.NodeList)1