Search in sources :

Example 61 with XSDTypeDefinition

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

the class XSDTypesSearchListProvider method populateComponentList.

public void populateComponentList(IComponentList list, SearchScope scope, IProgressMonitor pm) {
    // first we add the 'built in' types
    // 
    XSDSchema schemaForSchema = XSDSchemaImpl.getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
    for (Iterator i = schemaForSchema.getSimpleTypeIdMap().values().iterator(); i.hasNext(); ) {
        XSDTypeDefinition td = (XSDTypeDefinition) i.next();
        if (builtInFilter == null || !builtInFilter.shouldFilterOut(td)) {
            list.add(td);
        }
    }
    // now we traverse the types already defined within the visible schemas
    // we do this in addition to the component search since this should execute
    // very quickly and there's a good chance the user wants to select a time
    // that's
    // already imported/included
    // TODO (cs) ensure we don't add duplicates when we proceed to use the
    // search list
    // 
    List visitedSchemas = new ArrayList();
    for (int i = 0; i < schemas.length; i++) {
        XSDSchema schema = schemas[i];
        QualifiedName kind = showComplexTypes ? IXSDSearchConstants.TYPE_META_NAME : IXSDSearchConstants.SIMPLE_TYPE_META_NAME;
        ComponentCollectingXSDVisitor visitor = new ComponentCollectingXSDVisitor(list, kind);
        visitor.visitSchema(schema, true);
        visitedSchemas.addAll(visitor.getVisitedSchemas());
    }
    // 
    if (scope != null) {
        populateComponentListUsingSearch(list, scope, pm, createFileMap(visitedSchemas));
    }
}
Also used : QualifiedName(org.eclipse.wst.common.core.search.pattern.QualifiedName) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IComponentList(org.eclipse.wst.common.ui.internal.search.dialogs.IComponentList) XSDSchema(org.eclipse.xsd.XSDSchema) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 62 with XSDTypeDefinition

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

the class XSDHyperlinkTargetLocator method caseXSDTypeDefinition.

/*
   * (non-Javadoc)
   * 
   * @see org.eclipse.xsd.util.XSDSwitch#caseXSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)
   */
public Object caseXSDTypeDefinition(XSDTypeDefinition typeDefinition) {
    XSDConcreteComponent target = null;
    XSDTypeDefinition baseType = typeDefinition.getBaseType();
    if (baseType != null) {
        target = baseType;
    }
    if (isFromSchemaForSchema(target)) {
        target = null;
    }
    return target;
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 63 with XSDTypeDefinition

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

the class MakeAnonymousTypeGlobalCommand method run.

public void run() {
    XSDConcreteComponent model = getModelObject();
    XSDConcreteComponent parent = model.getContainer();
    XSDTypeDefinition globalTypeDef = null;
    if (model instanceof XSDComplexTypeDefinition) {
        if (parent instanceof XSDElementDeclaration) {
            // clone typedef with it's content and set it global
            globalTypeDef = (XSDComplexTypeDefinition) model.cloneConcreteComponent(true, false);
            globalTypeDef.setName(fNewName);
            parent.getSchema().getContents().add(globalTypeDef);
            ((XSDElementDeclaration) parent).setTypeDefinition(globalTypeDef);
        }
    } else if (model instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition typeDef = (XSDSimpleTypeDefinition) model;
        if (parent instanceof XSDElementDeclaration) {
            // clone typedef with it's content and set it global
            globalTypeDef = (XSDSimpleTypeDefinition) typeDef.cloneConcreteComponent(true, false);
            globalTypeDef.setName(fNewName);
            parent.getSchema().getContents().add(globalTypeDef);
            ((XSDElementDeclaration) parent).setTypeDefinition(globalTypeDef);
            formatChild(globalTypeDef.getElement());
        } else if (parent instanceof XSDAttributeDeclaration) {
            // clone typedef with it's content and set it global
            globalTypeDef = (XSDSimpleTypeDefinition) typeDef.cloneConcreteComponent(true, false);
            globalTypeDef.setName(fNewName);
            parent.getSchema().getContents().add(globalTypeDef);
            ((XSDAttributeDeclaration) parent).setTypeDefinition((XSDSimpleTypeDefinition) globalTypeDef);
        }
    }
    formatChild(globalTypeDef.getElement());
}
Also used : XSDConcreteComponent(org.eclipse.xsd.XSDConcreteComponent) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 64 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.

the class ComplexTypeConfigComposite method refresh.

private void refresh() {
    XSDTypeDefinition selectedExtends = getExtends();
    radGroupAll.setEnabled(!isExtendsSelected());
    radGroupSequence.setEnabled(!isExtendsSelected());
    radGroupChoice.setEnabled(!isExtendsSelected());
    if (!getDefaultExtends().equals(selectedExtends) && selectedExtends instanceof XSDComplexTypeDefinition && !Util.isAllComplexType((XSDComplexTypeDefinition) selectedExtends)) {
        radGroupAll.setSelection(false);
        radGroupSequence.setSelection(Util.isSequenceComplexType((XSDComplexTypeDefinition) selectedExtends));
        radGroupChoice.setSelection(Util.isChoiceComplexType((XSDComplexTypeDefinition) selectedExtends));
    }
    comboExtends.getCombo().setEnabled(!isGroupAll());
}
Also used : XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 65 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.

the class ComplexTypeInputDialog method modifyText.

public void modifyText(ModifyEvent e) {
    getButton(IDialogConstants.OK_ID).setEnabled(true);
    // $NON-NLS-1$
    conceptPanel.setMessage("");
    String type = conceptPanel.getText();
    if (// $NON-NLS-1$
    Pattern.compile("^\\s+\\w+\\s*").matcher(type).matches() || type.trim().replaceAll("\\s", "").length() != type.trim().length()) {
        // $NON-NLS-1$//$NON-NLS-2$
        conceptPanel.setMessage(Messages._NameWithEmptyCharacters);
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        return;
    }
    type = type.trim();
    if (!XSDUtil.isValidatedXSDName(type)) {
        conceptPanel.setMessage(Messages.InvalidName_Message);
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        return;
    }
    for (XSDTypeDefinition specType : xsdSchema.getTypeDefinitions()) {
        String typeToCompare = specType.getName();
        // $NON-NLS-1$
        int delimiter = type.indexOf(" : ");
        if (delimiter != -1) {
            type = type.substring(0, delimiter);
        }
        if (typeToCompare.equals(type)) {
            if (caller instanceof XSDNewComplexTypeDefinition) {
                conceptPanel.setMessage(Messages._SameTypeNameExists);
                getButton(IDialogConstants.OK_ID).setEnabled(false);
            } else if (caller instanceof XSDChangeToComplexTypeAction && specType instanceof XSDSimpleTypeDefinition) {
                conceptPanel.setMessage(Messages._SameTypeNameExists);
                getButton(IDialogConstants.OK_ID).setEnabled(false);
            }
            break;
        }
    }
}
Also used : XSDChangeToComplexTypeAction(com.amalto.workbench.actions.XSDChangeToComplexTypeAction) XSDNewComplexTypeDefinition(com.amalto.workbench.actions.XSDNewComplexTypeDefinition) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) 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