use of org.jdom.Element in project intellij-community by JetBrains.
the class PythonSdkAdditionalData method savePaths.
private static void savePaths(Element rootElement, Set<SimpleProjectRoot> paths, String root, String element) {
for (SimpleProjectRoot addedPath : paths) {
final Element child = new Element(root);
child.setAttribute(element, addedPath.getUrl());
rootElement.addContent(child);
}
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class JUnitConfigurationTest method testSearchScope.
public void testSearchScope() throws Exception {
JUnitConfiguration foo = new JUnitConfiguration("foo", getProject(), JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
Element element = JdomKt.loadElement("<configuration default=\"false\" name=\"DjangoTests (1.6)\" type=\"JUnit\" factoryName=\"JUnit\">\n" + " <option name=\"TEST_SEARCH_SCOPE\">\n" + " <value defaultName=\"moduleWithDependencies\" />\n" + " </option>\n" + " </configuration>");
foo.readExternal(element);
assertEquals(TestSearchScope.MODULE_WITH_DEPENDENCIES, foo.getPersistentData().getScope());
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class MavenJDOMUtilTest method readValue.
private String readValue(String xml, String valuePath) throws IOException {
VirtualFile f = createProjectSubFile("foo.xml", xml);
Element el = MavenJDOMUtil.read(f, new MavenJDOMUtil.ErrorHandler() {
@Override
public void onReadError(IOException e) {
throw new RuntimeException(e);
}
@Override
public void onSyntaxError() {
fail("syntax error");
}
});
return MavenJDOMUtil.findChildValueByPath(el, valuePath);
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class ExternalResourceManagerExImpl method getState.
@Nullable
@Override
public Element getState() {
Element element = new Element("state");
Set<String> urls = new TreeSet<>();
for (Map<String, String> map : myResources.values()) {
urls.addAll(map.keySet());
}
for (String url : urls) {
if (url == null) {
continue;
}
String location = getResourceLocation(url);
if (location == null) {
continue;
}
Element e = new Element(RESOURCE_ELEMENT);
e.setAttribute(URL_ATTR, url);
e.setAttribute(LOCATION_ATTR, location.replace(File.separatorChar, '/'));
element.addContent(e);
}
myIgnoredResources.removeAll(myStandardIgnoredResources);
for (String ignoredResource : myIgnoredResources) {
Element e = new Element(IGNORED_RESOURCE_ELEMENT);
e.setAttribute(URL_ATTR, ignoredResource);
element.addContent(e);
}
if (myDefaultHtmlDoctype != null && !HTML5_DOCTYPE_ELEMENT.equals(myDefaultHtmlDoctype)) {
Element e = new Element(HTML_DEFAULT_DOCTYPE_ELEMENT);
e.setText(myDefaultHtmlDoctype);
element.addContent(e);
}
if (myXMLSchemaVersion != XMLSchemaVersion.XMLSchema_1_0) {
Element e = new Element(XML_SCHEMA_VERSION);
e.setText(myXMLSchemaVersion.toString());
element.addContent(e);
}
if (myCatalogPropertiesFile != null) {
Element properties = new Element(CATALOG_PROPERTIES_ELEMENT);
properties.setText(myCatalogPropertiesFile);
element.addContent(properties);
}
ReplacePathToMacroMap macroReplacements = new ReplacePathToMacroMap();
PathMacrosImpl.getInstanceEx().addMacroReplacements(macroReplacements);
macroReplacements.substitute(element, SystemInfo.isFileSystemCaseSensitive);
return element;
}
use of org.jdom.Element in project intellij-community by JetBrains.
the class CutCopyPasteSupport method loadComponentsToPaste.
private static boolean loadComponentsToPaste(final GuiEditor editor, final String serializedComponents, final TIntArrayList xs, final TIntArrayList ys, final ArrayList<RadComponent> componentsToPaste) {
final PsiPropertiesProvider provider = new PsiPropertiesProvider(editor.getModule());
try {
//noinspection HardCodedStringLiteral
final Document document = SAX_BUILDER.build(new StringReader(serializedComponents), "UTF-8");
final Element rootElement = document.getRootElement();
if (!rootElement.getName().equals(ELEMENT_SERIALIZED)) {
return false;
}
final List children = rootElement.getChildren();
for (final Object aChildren : children) {
final Element e = (Element) aChildren;
// we need to add component to a container in order to read them
final LwContainer container = new LwContainer(JPanel.class.getName());
final String parentLayout = e.getAttributeValue(ATTRIBUTE_PARENT_LAYOUT);
if (parentLayout != null) {
container.setLayoutManager(parentLayout);
}
final int x = Integer.parseInt(e.getAttributeValue(ATTRIBUTE_X));
final int y = Integer.parseInt(e.getAttributeValue(ATTRIBUTE_Y));
xs.add(x);
ys.add(y);
final Element componentElement = (Element) e.getChildren().get(0);
final LwComponent lwComponent = LwContainer.createComponentFromTag(componentElement);
container.addComponent(lwComponent);
lwComponent.read(componentElement, provider);
// pasted components should have no bindings
FormEditingUtil.iterate(lwComponent, new FormEditingUtil.ComponentVisitor<LwComponent>() {
public boolean visit(final LwComponent c) {
if (c.getBinding() != null && FormEditingUtil.findComponentWithBinding(editor.getRootContainer(), c.getBinding()) != null) {
c.setBinding(null);
}
c.setId(FormEditingUtil.generateId(editor.getRootContainer()));
return true;
}
});
final ClassLoader loader = LoaderFactory.getInstance(editor.getProject()).getLoader(editor.getFile());
final RadComponent radComponent = XmlReader.createComponent(editor, lwComponent, loader, editor.getStringDescriptorLocale());
componentsToPaste.add(radComponent);
}
} catch (Exception e) {
return false;
}
return true;
}
Aggregations