Search in sources :

Example 41 with Attribute

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;
}
Also used : DefaultColorsScheme(com.intellij.openapi.editor.colors.impl.DefaultColorsScheme) Attribute(org.jdom.Attribute) Element(org.jdom.Element) ArrayList(java.util.ArrayList)

Example 42 with Attribute

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;
}
Also used : XPath(org.jaxen.XPath) JDOMXPath(org.jaxen.jdom.JDOMXPath) SAXBuilder(org.jdom.input.SAXBuilder) JDOMXPath(org.jaxen.jdom.JDOMXPath) Attribute(org.jdom.Attribute) ArrayList(java.util.ArrayList) EntityResolver(org.xml.sax.EntityResolver) Document(org.jdom.Document) URL(java.net.URL)

Example 43 with Attribute

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;
        }
    }
}
Also used : Attribute(org.jdom.Attribute) Element(org.jdom.Element)

Example 44 with Attribute

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);
            });
        }
    }
}
Also used : Attribute(org.jdom.Attribute) Element(org.jdom.Element)

Example 45 with Attribute

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;
}
Also used : Attribute(org.jdom.Attribute) Element(org.jdom.Element)

Aggregations

Attribute (org.jdom.Attribute)57 Element (org.jdom.Element)40 ArrayList (java.util.ArrayList)10 DataConversionException (org.jdom.DataConversionException)7 Iterator (java.util.Iterator)4 List (java.util.List)4 Document (org.jdom.Document)4 Namespace (org.jdom.Namespace)3 SAXBuilder (org.jdom.input.SAXBuilder)3 NotNull (org.jetbrains.annotations.NotNull)3 MacroscopicRateConstant (cbit.vcell.math.MacroscopicRateConstant)2 ExpressionException (cbit.vcell.parser.ExpressionException)2 PathMacrosImpl (com.intellij.application.options.PathMacrosImpl)2 PathMacroFilter (com.intellij.openapi.application.PathMacroFilter)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Content (org.jdom.Content)2 Text (org.jdom.Text)2 BioPaxObject (org.vcell.pathway.BioPaxObject)2 RdfObjectProxy (org.vcell.pathway.persistence.BiopaxProxy.RdfObjectProxy)2 JDOMTreeWalker (cbit.util.xml.JDOMTreeWalker)1