static XSDParticle particle(XSDSchema schema, String elementName, String typeNS, String typeName, boolean nillable, int minOccurs, int maxOccurs) { XSDFactory factory = XSDFactory.eINSTANCE; XSDElementDeclaration element = factory.createXSDElementDeclaration(); element.setName(elementName); element.setNillable(nillable); XSDTypeDefinition type = schema.resolveTypeDefinition(typeNS, typeName); element.setTypeDefinition(type); XSDParticle particle = factory.createXSDParticle(); particle.setMinOccurs(minOccurs); particle.setMaxOccurs(maxOccurs); particle.setContent(element); return particle; }
/** * Performs a rename refactoring to rename the component and all the * references to it within the current schema. * * @param newName the new component name. */ private void renameComponent(String newName) { // this is a 'globally' defined component (e.g. global element) if (component.eContainer() instanceof XSDSchema) { RefactoringComponent refactoringComponent = new XMLRefactoringComponent( component, (IDOMElement)component.getElement(), component.getName(), component.getTargetNamespace()); RenameComponentProcessor processor = new RenameComponentProcessor(refactoringComponent, newName, true); RenameRefactoring refactoring = new RenameRefactoring(processor); PerformUnsavedRefactoringOperation operation = new PerformUnsavedRefactoringOperation(refactoring); operation.run(null); } else { // this is a 'locally' defined component (e.g. local element) // no need to call refactoring since this component can't be referenced component.setName(newName); } } }
public void run(ISelection selection) { if (selectedComponent.getName() == null) { selectedComponent.setName(new String());