Search in sources :

Example 11 with XSDNamedComponent

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

the class FindReferencesInProjectAction method run.

public void run() {
    String pattern = "";
    XSDNamedComponent component = getXSDNamedComponent();
    IFile file = getCurrentFile();
    if (file != null && component != null) {
        QualifiedName metaName = determineMetaName(component);
        QualifiedName elementQName = new QualifiedName(component.getTargetNamespace(), component.getName());
        IPath fullPath = file.getFullPath();
        ProjectSearchScope scope = new ProjectSearchScope(fullPath);
        String scopeDescription = "Project";
        XSDSearchQuery searchQuery = new XSDSearchQuery(pattern, file, elementQName, metaName, XSDSearchQuery.LIMIT_TO_REFERENCES, scope, scopeDescription);
        NewSearchUI.activateSearchResultView();
        NewSearchUI.runQueryInBackground(searchQuery);
    }
}
Also used : XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) QualifiedName(org.eclipse.wst.common.core.search.pattern.QualifiedName) ProjectSearchScope(org.eclipse.wst.common.core.search.scope.ProjectSearchScope) XSDSearchQuery(org.eclipse.wst.xsd.ui.internal.search.XSDSearchQuery)

Example 12 with XSDNamedComponent

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

the class XpathComposite method getItems.

protected String[] getItems() {
    Set<String> entities = section.getEntities();
    if (null != entities) {
        XSDSchema schema = getDatamodelXSD();
        Object[] child = getXSDSchemaChildren(schema);
        List<String> items = new LinkedList<String>();
        for (Object obj : child) {
            if (obj instanceof XSDNamedComponent) {
                if (entities.contains(((XSDNamedComponent) obj).getName())) {
                    XSDComponentChildElementsHolder holder = new XSDComponentChildElementsHolder((XSDNamedComponent) obj);
                    String[] eles = holder.getAllElements();
                    if (null == eles) {
                        continue;
                    }
                    for (String ele : eles) {
                        items.add(ele);
                    }
                }
            }
        }
        return items.toArray(new String[0]);
    }
    return null;
}
Also used : XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) XSDComponentChildElementsHolder(com.amalto.workbench.models.infoextractor.XSDComponentChildElementsHolder) LinkedList(java.util.LinkedList) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 13 with XSDNamedComponent

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

the class XpathComposite method getXSDSchemaChildren.

Object[] getXSDSchemaChildren(XSDSchema schema) {
    List<XSDElementDeclaration> declarations = new ArrayList<XSDElementDeclaration>();
    EList<XSDElementDeclaration> elementDeclarations = schema.getElementDeclarations();
    for (XSDElementDeclaration declaration : elementDeclarations) {
        if (declaration.eContainer().equals(schema)) {
            declarations.add(declaration);
        }
    }
    Object[] schemaChildren = Util.filterOutDuplicatedElems(declarations.toArray(new XSDNamedComponent[declarations.size()]));
    return schemaChildren;
}
Also used : XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList)

Example 14 with XSDNamedComponent

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

the class UtilTest method testFilterOutDuplicatedElems.

@Test
public void testFilterOutDuplicatedElems() {
    // $NON-NLS-1$
    String simpletypeName = "simpletype";
    // $NON-NLS-1$
    String complextypeName = "complextype";
    // $NON-NLS-1$
    String concepName = "concept";
    // $NON-NLS-1$
    String idconstraintName = "identityconstraint";
    // $NON-NLS-1$
    String modelgroupName = "modelgroup";
    XSDFactory factory = XSDFactory.eINSTANCE;
    XSDSimpleTypeDefinition simpleTypeDefinition = factory.createXSDSimpleTypeDefinition();
    XSDComplexTypeDefinition complexTypeDefinition = factory.createXSDComplexTypeDefinition();
    XSDElementDeclaration elementDeclaration = factory.createXSDElementDeclaration();
    XSDIdentityConstraintDefinition identityConstraintDefinition = factory.createXSDIdentityConstraintDefinition();
    XSDModelGroupDefinition modelGroupDefinition = factory.createXSDModelGroupDefinition();
    simpleTypeDefinition.setName(simpletypeName);
    complexTypeDefinition.setName(complextypeName);
    elementDeclaration.setName(concepName);
    identityConstraintDefinition.setName(idconstraintName);
    modelGroupDefinition.setName(modelgroupName);
    XSDNamedComponent[] checkedElements = { simpleTypeDefinition, complexTypeDefinition, elementDeclaration, identityConstraintDefinition, modelGroupDefinition };
    Object[] duplicatedElems = Util.filterOutDuplicatedElems(checkedElements);
    List<XSDNamedComponent> allElements = Arrays.asList(checkedElements);
    assertNotNull(duplicatedElems);
    assertTrue(checkedElements.length == duplicatedElems.length);
    for (int i = 0; i < duplicatedElems.length; i++) {
        assertTrue(allElements.contains(duplicatedElems[i]));
    }
    // 
    XSDSimpleTypeDefinition simpleTypeDefinition2 = factory.createXSDSimpleTypeDefinition();
    XSDComplexTypeDefinition complexTypeDefinition2 = factory.createXSDComplexTypeDefinition();
    XSDElementDeclaration elementDeclaration2 = factory.createXSDElementDeclaration();
    XSDIdentityConstraintDefinition identityConstraintDefinition2 = factory.createXSDIdentityConstraintDefinition();
    XSDModelGroupDefinition modelGroupDefinition2 = factory.createXSDModelGroupDefinition();
    simpleTypeDefinition2.setName(simpletypeName);
    complexTypeDefinition2.setName(complextypeName);
    elementDeclaration2.setName(concepName);
    identityConstraintDefinition2.setName(idconstraintName);
    modelGroupDefinition2.setName(modelgroupName);
    XSDNamedComponent[] checkedElements2 = { simpleTypeDefinition, complexTypeDefinition, elementDeclaration, identityConstraintDefinition, modelGroupDefinition, simpleTypeDefinition2, complexTypeDefinition2, elementDeclaration2, identityConstraintDefinition2, modelGroupDefinition2 };
    duplicatedElems = Util.filterOutDuplicatedElems(checkedElements2);
    assertNotNull(duplicatedElems);
    assertTrue(checkedElements.length == duplicatedElems.length);
    for (int i = 0; i < duplicatedElems.length; i++) {
        assertTrue(allElements.contains(duplicatedElems[i]));
    }
}
Also used : XSDFactory(org.eclipse.xsd.XSDFactory) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) Test(org.junit.Test)

Example 15 with XSDNamedComponent

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

the class BaseFieldEditPart method doEditName.

public void doEditName(boolean addFromDesign) {
    if (!addFromDesign)
        return;
    // removeFeedback();
    Runnable runnable = new Runnable() {

        public void run() {
            Object object = ((XSDBaseAdapter) getModel()).getTarget();
            if (object instanceof XSDNamedComponent) {
                Point p = getNameLabelFigure().getLocation();
                LabelEditManager manager = new LabelEditManager(BaseFieldEditPart.this, new LabelCellEditorLocator(BaseFieldEditPart.this, p));
                NameUpdateCommandWrapper wrapper = new NameUpdateCommandWrapper();
                adtDirectEditPolicy.setUpdateCommand(wrapper);
                manager.show();
            }
        }
    };
    Display.getCurrent().asyncExec(runnable);
}
Also used : XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) LabelEditManager(org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelEditManager) LabelCellEditorLocator(org.eclipse.wst.xsd.ui.internal.adt.design.directedit.LabelCellEditorLocator) XSDBaseAdapter(org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

XSDNamedComponent (org.eclipse.xsd.XSDNamedComponent)26 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)8 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)6 XSDSchema (org.eclipse.xsd.XSDSchema)6 Element (org.w3c.dom.Element)6 ArrayList (java.util.ArrayList)4 Command (org.eclipse.gef.commands.Command)4 UpdateNameCommand (org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand)4 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)4 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)4 Iterator (java.util.Iterator)3 IFile (org.eclipse.core.resources.IFile)3 QualifiedName (org.eclipse.wst.common.core.search.pattern.QualifiedName)3 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)3 Point (org.eclipse.draw2d.geometry.Point)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 XSDBaseAdapter (org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter)2 XSDSearchQuery (org.eclipse.wst.xsd.ui.internal.search.XSDSearchQuery)2 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)2 TreeObject (com.amalto.workbench.models.TreeObject)1