}
protected void addXsdDefinition(INamespaceDefinition definition) {
if (!existsInConfiguration(definition)) {
StructuredTextViewer textView = getConfigEditor().getTextViewer();
IDOMDocument doc = getConfigEditor().getDomDocument();
doc.getModel().beginRecording(textView);
if (rootElement == null) {
// Create a beans element and add the default namespace
rootElement = doc.createElement(BeansSchemaConstants.ELEM_BEANS);
doc.appendChild(rootElement);
INamespaceDefinition defNamespace = NamespaceUtils.getDefaultNamespaceDefinition();
if (defNamespace != null) {
if (!xsdViewer.getChecked(defNamespace)) {
xsdViewer.setChecked(defNamespace, true);
}
rootElement.setAttribute(ConfigCoreUtils.ATTR_DEFAULT_NAMESPACE, defNamespace.getNamespaceURI());
}
rootElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Check again so we don't add the default namespace twice
if (!existsInConfiguration(definition)) {
rootElement.setAttribute(
ConfigCoreUtils.ATTR_NAMESPACE_PREFIX
+ definition.getNamespacePrefix(getConfigEditor().getResourceFile()),
definition.getNamespaceURI());
}
selectedNamespaces.add(definition);
updateXsdVersion();
doc.getModel().endRecording(textView);
}
}