Search in sources :

Example 1 with XSDNamedComponent

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

the class ElementFKInfosSection 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 2 with XSDNamedComponent

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

the class SchemaTreeContentProvider method getXSDSchemaChildren.

protected Object[] getXSDSchemaChildren(XSDSchema schema) {
    List<XSDElementDeclaration> declarations = new ArrayList<XSDElementDeclaration>();
    List<Object> attributeDeclarations = new ArrayList<Object>();
    if (null != xsdSchema) {
        for (XSDSchemaContent cnt : xsdSchema.getContents()) {
            if (cnt instanceof XSDInclude) {
                XSDInclude incu = (XSDInclude) cnt;
                String schemaLocation = incu.getSchemaLocation();
                XSDSchema schemaInc = createSchema(schemaLocation);
                addElementDeclarationFromSchema(schemaInc, declarations);
            } else if (cnt instanceof XSDAttributeDeclaration) {
                XSDAttributeDeclaration attriDec = (XSDAttributeDeclaration) cnt;
                attributeDeclarations.add(attriDec);
            }
        }
    }
    addElementDeclarationFromSchema(schema, declarations);
    Object[] schemaChildren = Util.filterOutDuplicatedElems(declarations.toArray(new XSDNamedComponent[declarations.size()]));
    attributeDeclarations.addAll(Arrays.asList(schemaChildren));
    return attributeDeclarations.toArray();
}
Also used : XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) XSDSchemaContent(org.eclipse.xsd.XSDSchemaContent) TreeObject(com.amalto.workbench.models.TreeObject) XSDAttributeDeclaration(org.eclipse.xsd.XSDAttributeDeclaration) XSDInclude(org.eclipse.xsd.XSDInclude) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 3 with XSDNamedComponent

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

the class XSDAttributeGroupDefinitionSection method doHandleEvent.

public void doHandleEvent(Event event) {
    super.doHandleEvent(event);
    if (event.widget == nameText) {
        String newValue = nameText.getText().trim();
        if (input instanceof XSDNamedComponent) {
            XSDNamedComponent namedComponent = (XSDNamedComponent) input;
            if (!validateSection())
                return;
            Command command = null;
            // Make sure an actual name change has taken place
            String oldName = namedComponent.getName();
            if (!newValue.equals(oldName)) {
                command = new UpdateNameCommand(Messages._UI_ACTION_RENAME, namedComponent, newValue);
            }
            if (command != null && getCommandStack() != null) {
                getCommandStack().execute(command);
            }
        // doReferentialIntegrityCheck(namedComponent, newValue);
        }
    }
}
Also used : UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) Command(org.eclipse.gef.commands.Command)

Example 4 with XSDNamedComponent

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

the class XSDSimpleTypeSection method doHandleEvent.

// TODO: Common this up with element declaration
public void doHandleEvent(Event event) {
    if (event.type == SWT.Traverse) {
        if (event.detail == SWT.TRAVERSE_ARROW_NEXT || event.detail == SWT.TRAVERSE_ARROW_PREVIOUS) {
            isTraversing = true;
            return;
        }
    }
    if (event.widget == nameText) {
        if (!nameText.getEditable())
            return;
        String newValue = nameText.getText().trim();
        if (input instanceof XSDNamedComponent) {
            XSDNamedComponent namedComponent = (XSDNamedComponent) input;
            if (!validateSection())
                return;
            Command command = null;
            // Make sure an actual name change has taken place
            String oldName = namedComponent.getName();
            if (!newValue.equals(oldName)) {
                command = new UpdateNameCommand(Messages._UI_ACTION_RENAME, namedComponent, newValue);
            }
            if (command != null && getCommandStack() != null) {
                getCommandStack().execute(command);
            }
        }
    }
}
Also used : UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) Command(org.eclipse.gef.commands.Command)

Example 5 with XSDNamedComponent

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

the class XSDModelGroupDefinitionSection method doHandleEvent.

public void doHandleEvent(Event event) {
    super.doHandleEvent(event);
    if (event.widget == nameText) {
        String newValue = nameText.getText().trim();
        if (input instanceof XSDNamedComponent) {
            XSDNamedComponent namedComponent = (XSDNamedComponent) input;
            if (!validateSection())
                return;
            Command command = null;
            // Make sure an actual name change has taken place
            String oldName = namedComponent.getName();
            if (!newValue.equals(oldName)) {
                command = new UpdateNameCommand(Messages._UI_ACTION_RENAME, namedComponent, newValue);
            }
            if (command != null && getCommandStack() != null) {
                getCommandStack().execute(command);
            }
        // doReferentialIntegrityCheck(namedComponent, newValue);
        }
    }
}
Also used : UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) XSDNamedComponent(org.eclipse.xsd.XSDNamedComponent) UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand) Command(org.eclipse.gef.commands.Command)

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