use of org.jdom.Attribute in project intellij-community by JetBrains.
the class DefaultColorSchemesManager method loadState.
@Override
public void loadState(Element state) {
List<DefaultColorsScheme> schemes = new ArrayList<>();
for (Element schemeElement : state.getChildren(SCHEME_ELEMENT)) {
boolean isUpdated = false;
Attribute nameAttr = schemeElement.getAttribute(NAME_ATTR);
if (nameAttr != null) {
for (DefaultColorsScheme oldScheme : mySchemes) {
if (StringUtil.equals(nameAttr.getValue(), oldScheme.getName())) {
oldScheme.readExternal(schemeElement);
schemes.add(oldScheme);
isUpdated = true;
}
}
}
if (!isUpdated) {
DefaultColorsScheme newScheme = new DefaultColorsScheme();
newScheme.readExternal(schemeElement);
schemes.add(newScheme);
}
}
schemes.add(EmptyColorScheme.INSTANCE);
mySchemes = schemes;
}
use of org.jdom.Attribute in project Asqatasun by Asqatasun.
the class KbCsvMojo method getUrls.
private List<String> getUrls(String url) throws JDOMException, JaxenException, IOException {
SAXBuilder builder = new SAXBuilder();
EntityResolver resolver = new XhtmlEntityResolver();
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
builder.setEntityResolver(resolver);
Document document = builder.build(new URL(url));
XPath xpath = new JDOMXPath("//*[@id='resultat']//*[@href]/@href");
List<Attribute> results = xpath.selectNodes(document);
List<String> urls = new ArrayList<String>();
for (Attribute attr : results) {
urls.add(attr.getValue());
}
return urls;
}
use of org.jdom.Attribute in project intellij-elixir by KronicDeth.
the class MixRunConfigurationBase method readExternal.
@Override
public void readExternal(Element element) throws InvalidDataException {
super.readExternal(element);
XmlSerializer.deserializeInto(this, element);
EnvironmentVariablesComponent.readExternal(element, getEnvs());
/*
* Reading <= 4.6.0 format
*/
List<Element> options = element.getChildren("option");
for (Element option : options) {
Attribute nameAttribute = option.getAttribute("name");
if (nameAttribute.getValue().equals("command")) {
Attribute valueAttribute = option.getAttribute("value");
setProgramParameters(valueAttribute.getValue());
break;
}
}
}
use of org.jdom.Attribute in project intellij-plugins by StepicOrg.
the class StudySerializationUtils method replaceLanguages.
private static void replaceLanguages(@Nullable Element collection, @NotNull String collectionType, @NotNull String itemType, @NotNull String valueAttrName) {
if (collection != null) {
Element items = collection.getChild(collectionType);
if (items != null) {
List<Element> itemList = items.getChildren(itemType);
itemList.forEach(entry -> {
Attribute value = entry.getAttribute(valueAttrName);
replaceLanguage(value);
});
}
}
}
use of org.jdom.Attribute in project intellij-plugins by StepicOrg.
the class StudySerializationUtils method convertToThirdVersion.
public static Element convertToThirdVersion(@NotNull Element state) throws StudyUnrecognizedFormatException {
Element stepManager = getStepManager(state);
Element courseNode = getCourseNode(stepManager);
removeOption(courseNode, DESCRIPTION);
removeOption(courseNode, NAME);
removeOption(courseNode, ID);
removeOption(courseNode, ADAPTIVE);
removeOption(stepManager, USER);
List<Element> sectionNodes = getSectionNodes(stepManager);
if (sectionNodes == null) {
return state;
}
sectionNodes.forEach(sectionNode -> {
removeOption(sectionNode, ID);
removeOption(sectionNode, NAME);
removeOption(sectionNode, POSITION);
});
sectionNodes.stream().map(sectionNode -> getListFieldWithNameOrNull(sectionNode, LESSON_NODES, LESSON_NODE_CLASS)).filter(Objects::nonNull).forEach(lessonNodes -> {
lessonNodes.forEach(lessonNode -> {
removeOption(lessonNode, ID);
removeOption(lessonNode, NAME);
removeOption(lessonNode, POSITION);
});
lessonNodes.stream().map(lessonNode -> getListFieldWithNameOrNull(lessonNode, STEP_NODES, STEP_NODE_CLASS)).filter(Objects::nonNull).forEach(stepNodes -> {
stepNodes.forEach(stepNode -> {
removeOption(stepNode, ID);
removeOption(stepNode, NAME);
removeOption(stepNode, POSITION);
removeOption(stepNode, STEP_FILES);
removeOption(stepNode, TEXT);
removeOption(stepNode, TIME_LIMITS);
});
stepNodes.forEach(stepNode -> {
Element currentLang = getFieldWithNameOrNull(stepNode, CURRENT_LANG);
if (currentLang != null) {
Attribute currentLangValue = currentLang.getAttribute(VALUE);
replaceLanguage(currentLangValue);
}
Element limits = getFieldWithNameOrNull(stepNode, LIMITS);
replaceLanguages(limits, MAP, ENTRY, KEY);
Element supportedLanguages;
supportedLanguages = getFieldWithNameOrNull(stepNode, SUPPORTED_LANGUAGES);
replaceLanguages(supportedLanguages, LIST, OPTION, VALUE);
});
});
});
return state;
}
Aggregations