use of org.jdom.Document in project intellij-community by JetBrains.
the class ProductivityFeaturesRegistryImpl method readFromXml.
private void readFromXml(String path) throws JDOMException, IOException {
final Document document = JDOMUtil.loadResourceDocument(new URL(path));
final Element root = document.getRootElement();
readGroups(root);
readFilters(root);
}
use of org.jdom.Document in project intellij-community by JetBrains.
the class SearchableOptionsRegistrarImpl method loadHugeFilesIfNecessary.
private void loadHugeFilesIfNecessary() {
if (allTheseHugeFilesAreLoaded) {
return;
}
allTheseHugeFilesAreLoaded = true;
try {
//index
final URL indexResource = ResourceUtil.getResource(SearchableOptionsRegistrar.class, "/search/", "searchableOptions.xml");
if (indexResource == null) {
LOG.info("No /search/searchableOptions.xml found, settings search won't work!");
return;
}
Document document = JDOMUtil.loadDocument(indexResource);
Element root = document.getRootElement();
List configurables = root.getChildren("configurable");
for (final Object o : configurables) {
final Element configurable = (Element) o;
final String id = configurable.getAttributeValue("id");
final String groupName = configurable.getAttributeValue("configurable_name");
final List options = configurable.getChildren("option");
for (Object o1 : options) {
Element optionElement = (Element) o1;
final String option = optionElement.getAttributeValue("name");
final String path = optionElement.getAttributeValue("path");
final String hit = optionElement.getAttributeValue("hit");
putOptionWithHelpId(option, id, groupName, hit, path);
}
}
//synonyms
document = JDOMUtil.loadDocument(ResourceUtil.getResource(SearchableOptionsRegistrar.class, "/search/", "synonyms.xml"));
root = document.getRootElement();
configurables = root.getChildren("configurable");
for (final Object o : configurables) {
final Element configurable = (Element) o;
final String id = configurable.getAttributeValue("id");
final String groupName = configurable.getAttributeValue("configurable_name");
final List synonyms = configurable.getChildren("synonym");
for (Object o1 : synonyms) {
Element synonymElement = (Element) o1;
final String synonym = synonymElement.getTextNormalize();
if (synonym != null) {
Set<String> words = getProcessedWords(synonym);
for (String word : words) {
putOptionWithHelpId(word, id, groupName, synonym, null);
}
}
}
final List options = configurable.getChildren("option");
for (Object o1 : options) {
Element optionElement = (Element) o1;
final String option = optionElement.getAttributeValue("name");
final List list = optionElement.getChildren("synonym");
for (Object o2 : list) {
Element synonymElement = (Element) o2;
final String synonym = synonymElement.getTextNormalize();
if (synonym != null) {
Set<String> words = getProcessedWords(synonym);
for (String word : words) {
putOptionWithHelpId(word, id, groupName, synonym, null);
}
final Couple<String> key = Couple.of(option, id);
Set<String> foundSynonyms = myHighlightOption2Synonym.get(key);
if (foundSynonyms == null) {
foundSynonyms = new THashSet<>();
myHighlightOption2Synonym.put(key, foundSynonyms);
}
foundSynonyms.add(synonym);
}
}
}
}
} catch (Exception e) {
LOG.error(e);
}
ApplicationInfoEx applicationInfo = ApplicationInfoEx.getInstanceEx();
for (IdeaPluginDescriptor plugin : PluginManagerCore.getPlugins()) {
if (applicationInfo.isEssentialPlugin(plugin.getPluginId().getIdString())) {
continue;
}
final String pluginName = plugin.getName();
final Set<String> words = getProcessedWordsWithoutStemming(pluginName);
final String description = plugin.getDescription();
if (description != null) {
words.addAll(getProcessedWordsWithoutStemming(description));
}
for (String word : words) {
addOption(word, null, pluginName, PluginManagerConfigurable.ID, PluginManagerConfigurable.DISPLAY_NAME);
}
}
}
use of org.jdom.Document in project android by JetBrains.
the class GuiTestRule method cleanUpProjectForImport.
public void cleanUpProjectForImport(@NotNull File projectPath) {
File dotIdeaFolderPath = new File(projectPath, Project.DIRECTORY_STORE_FOLDER);
if (dotIdeaFolderPath.isDirectory()) {
File modulesXmlFilePath = new File(dotIdeaFolderPath, "modules.xml");
if (modulesXmlFilePath.isFile()) {
SAXBuilder saxBuilder = new SAXBuilder();
try {
Document document = saxBuilder.build(modulesXmlFilePath);
XPath xpath = XPath.newInstance("//*[@fileurl]");
//noinspection unchecked
List<Element> modules = xpath.selectNodes(document);
int urlPrefixSize = "file://$PROJECT_DIR$/".length();
for (Element module : modules) {
String fileUrl = module.getAttributeValue("fileurl");
if (!StringUtil.isEmpty(fileUrl)) {
String relativePath = FileUtil.toSystemDependentName(fileUrl.substring(urlPrefixSize));
File imlFilePath = new File(projectPath, relativePath);
if (imlFilePath.isFile()) {
FileUtilRt.delete(imlFilePath);
}
// It is likely that each module has a "build" folder. Delete it as well.
File buildFilePath = new File(imlFilePath.getParentFile(), "build");
if (buildFilePath.isDirectory()) {
FileUtilRt.delete(buildFilePath);
}
}
}
} catch (Throwable ignored) {
// if something goes wrong, just ignore. Most likely it won't affect project import in any way.
}
}
FileUtilRt.delete(dotIdeaFolderPath);
}
}
use of org.jdom.Document in project intellij-plugins by JetBrains.
the class FlexConversionTest method toString.
@SuppressWarnings("UnusedDeclaration")
private static String toString(Element e) {
Element clone = e.clone();
ConversionHelper.collapsePaths(clone);
return JDOMUtil.writeDocument(new Document(clone), "\n");
}
use of org.jdom.Document in project intellij-plugins by JetBrains.
the class P2PNetworkXmlMessage method processResponse.
void processResponse() {
if (myMessage == null || !myMessage.needsResponse())
return;
try {
final String response = getResponse().toString();
if (!com.intellij.openapi.util.text.StringUtil.isEmptyOrSpaces(response)) {
Document document = new SAXBuilder().build(new StringReader(response));
myMessage.processResponse(document.getRootElement());
}
} catch (JDOMException e) {
LOG.error(e.getMessage(), e);
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
}
Aggregations