public XSDSchema getXSDSchema() { return component.getSchema(); }
protected void reset(List<? extends XSDConcreteComponent> components) { for (Iterator<? extends XSDConcreteComponent> i = components.iterator(); i.hasNext(); ) { XSDConcreteComponent xsdConcreteComponent = i.next(); if (xsdConcreteComponent.getSchema() != this) { i.remove(); } } }
protected void reset(List<? extends XSDConcreteComponent> components) { for (Iterator<? extends XSDConcreteComponent> i = components.iterator(); i.hasNext(); ) { XSDConcreteComponent xsdConcreteComponent = i.next(); if (xsdConcreteComponent.getSchema() != this) { i.remove(); } } }
protected String createUniquePrefix(XSDConcreteComponent component) { String prefix = "p"; //$NON-NLS-1$ Map prefMapper = component.getSchema().getQNamePrefixToNamespaceMap(); if ( prefMapper.get(prefix) != null){ int i = 1; while ( prefMapper.get(prefix + i) != null) i++; prefix += i; } return prefix; } }
protected boolean canEnable(Object selectedComponent) { XSDSchema selectedComponentSchema = null; if (selectedComponent instanceof XSDConcreteComponent) { selectedComponentSchema = ((XSDConcreteComponent)selectedComponent).getSchema(); } if (selectedComponentSchema != null && selectedComponentSchema == getSchema() ) { return true; } return false; }
/** * @deprecated */ protected String createUniquePrefix(XSDConcreteComponent component) { String prefix = "p"; //$NON-NLS-1$ Map prefMapper = component.getSchema().getQNamePrefixToNamespaceMap(); if ( prefMapper.get(prefix) != null){ int i = 1; while ( prefMapper.get(prefix + i) != null) i++; prefix += i; } return prefix; }
/** * Detects if a given schema component is from the schema for schema (built in * data types). Used to avoid navigating to this type of components as they * don't have an accessible physical location. * * @param component the component to check. * @return true if the component is from the schema for schema namespace, * false otherwise. */ public boolean isFromSchemaForSchema(XSDConcreteComponent component) { if (component == null) { return false; } XSDSchema schema = component.getSchema(); if (schema != null && schema.equals(schema.getSchemaForSchema())) { return true; } return false; }
public IFile getFile(Object component) { IFile result = null; if (component instanceof ComponentSpecification) { result = ((ComponentSpecification)component).getFile(); } else if (component instanceof SearchMatch) { result = ((SearchMatch)component).getFile(); } else if (component instanceof XSDConcreteComponent) { XSDConcreteComponent concreteComponent = (XSDConcreteComponent)component; XSDSchema schema = concreteComponent.getSchema(); if (schema != null) { // TODO (cs) revisit and test more // String location = schema.getSchemaLocation(); String platformResource = "platform:/resource"; if (location != null && location.startsWith(platformResource)) { Path path = new Path(location.substring(platformResource.length())); result = ResourcesPlugin.getWorkspace().getRoot().getFile(path); } } } return result; }
protected XSDModelGroupDefinition createXSDModelGroupDefinition() { XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory(); XSDModelGroupDefinition def = factory.createXSDModelGroupDefinition(); List list = parent.getSchema().getModelGroupDefinitions(); String newName = XSDCommonUIUtils.createUniqueElementName("ModelGroupDefinition", list); //$NON-NLS-1$ def.setName(newName); XSDModelGroup modelGroup = createModelGroup(); def.setModelGroup(modelGroup); Text textNode = parent.getSchema().getDocument().createTextNode("\n"); //$NON-NLS-1$ parent.getSchema().getElement().appendChild(textNode); parent.getSchema().getContents().add(def); formatChild(def.getElement()); return def; }
/** Create a namespace prefix if needed, other wise retrieve * a predefined namespace prefix * @return */ private String handleNamespacePrefices() { Element schemaElement = component.getSchema().getElement(); String prefix = null; // If target namespace of the attribute already exists List namespacePrefices = manager.getNamespaceInfoList(schemaElement); for (int i = 0; i < namespacePrefices.size(); i++){ NamespaceInfo info = (NamespaceInfo) namespacePrefices.get(i); if ( info.uri.equals(attribute.getTargetNamespace())) { prefix = info.prefix; } } // Create unquie namespace prefix if ( prefix == null){ prefix = createUniquePrefix(component); } NamespaceInfo info = new NamespaceInfo(attribute.getTargetNamespace(), prefix, ""); //$NON-NLS-1$ List infoList = new ArrayList(1); infoList.add(info); manager.addNamespaceInfo(schemaElement, infoList, false); return prefix; }
public void visitElementDeclaration(org.eclipse.xsd.XSDElementDeclaration element) { if (element.getTypeDefinition() == target) { XSDSimpleTypeDefinition type = target.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string"); //$NON-NLS-1$ element.setTypeDefinition(type); } super.visitElementDeclaration(element); } };
public String getLocationURI() { if (getLocationURIGen() == null) { XSDConcreteComponent thePrimaryComponent = getPrimaryComponent(); if (thePrimaryComponent != null) { XSDSchema xsdSchema = thePrimaryComponent.getSchema(); if (xsdSchema != null) { return xsdSchema.getSchemaLocation(); } } } return getLocationURIGen(); }
public String getLocationURI() { if (getLocationURIGen() == null) { XSDConcreteComponent thePrimaryComponent = getPrimaryComponent(); if (thePrimaryComponent != null) { XSDSchema xsdSchema = thePrimaryComponent.getSchema(); if (xsdSchema != null) { return xsdSchema.getSchemaLocation(); } } } return getLocationURIGen(); }
public static void openXSDEditor(XSDConcreteComponent xsdComponent) { XSDSchema schema = xsdComponent.getSchema(); if (schema != null) { String schemaLocation = URIHelper.removePlatformResourceProtocol(schema.getSchemaLocation()); IPath schemaPath = new Path(schemaLocation); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath); if (file != null && file.exists()) { IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (workbenchWindow != null) { IWorkbenchPage page = workbenchWindow.getActivePage(); try { IEditorPart editorPart = IDE.openEditor(page, file, true); if (editorPart instanceof InternalXSDMultiPageEditor) { InternalXSDMultiPageEditor xsdEditor = (InternalXSDMultiPageEditor) editorPart; xsdEditor.openOnGlobalReference(xsdComponent); } } catch (PartInitException pie) { } } } } }
public void execute() { try { beginRecording(component.getElement()); super.execute(); addAnnotationSet(component.getSchema(), extensionsSchemaSpec); formatChild(component.getElement()); } finally { endRecording(); } }
XSDSchema containingXSDSchema = container.getSchema(); if (containingXSDSchema == null)
XSDSchema containingXSDSchema = container.getSchema(); if (containingXSDSchema == null)
protected boolean calculateEnabled() { if (getWorkbenchPart() instanceof IEditorPart) { IEditorPart owningEditor = (IEditorPart)getWorkbenchPart(); Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); if (selection instanceof XSDBaseAdapter) { selection = ((XSDBaseAdapter) selection).getTarget(); } XSDSchema xsdSchema = null; if (selection instanceof XSDConcreteComponent) { xsdSchema = ((XSDConcreteComponent)selection).getSchema(); } if (xsdSchema != null && xsdSchema == owningEditor.getAdapter(XSDSchema.class)) { return true; } } return false; }
XSDComplexTypeDefinition complexType = factory.createXSDComplexTypeDefinition(); addedXSDConcreteComponent = complexType; String newName = getNewName(nameToAdd == null ? "NewXSDComplexType" : nameToAdd, parent.getSchema()); //$NON-NLS-1$ complexType.setName(newName); if (parent instanceof XSDSchema)
xsdSchema = ((XSDConcreteComponent)input).getSchema();