Search in sources :

Example 1 with JpsSdkPropertiesSerializer

use of org.jetbrains.jps.model.serialization.library.JpsSdkPropertiesSerializer in project intellij-plugins by JetBrains.

the class JpsFlexmojosSdkType method createSdkPropertiesSerializer.

public static JpsSdkPropertiesSerializer<JpsSimpleElement<JpsFlexmojosSdkProperties>> createSdkPropertiesSerializer() {
    return new JpsSdkPropertiesSerializer<JpsSimpleElement<JpsFlexmojosSdkProperties>>(ID, INSTANCE) {

        @NotNull
        public JpsSimpleElement<JpsFlexmojosSdkProperties> loadProperties(@Nullable final Element propertiesElement) {
            final Collection<String> flexCompilerClasspath = new ArrayList<>();
            String adlPath = "";
            String airRuntimePath = "";
            if (propertiesElement != null) {
                final Element compilerClasspathElement = propertiesElement.getChild(COMPILER_CLASSPATH_ELEMENT_NAME);
                if (compilerClasspathElement != null) {
                    for (Object classpathEntryElement : compilerClasspathElement.getChildren(CLASSPATH_ENTRY_ELEMENT_NAME)) {
                        flexCompilerClasspath.add(((Element) classpathEntryElement).getText());
                    }
                }
                adlPath = FileUtil.toSystemIndependentName(StringUtil.notNullize(propertiesElement.getChildText(ADL_PATH_ELEMENT_NAME)));
                airRuntimePath = FileUtil.toSystemIndependentName(StringUtil.notNullize(propertiesElement.getChildText(AIR_RUNTIME_PATH_ELEMENT_NAME)));
            }
            final JpsFlexmojosSdkProperties properties = new JpsFlexmojosSdkProperties(flexCompilerClasspath, adlPath, airRuntimePath);
            return JpsElementFactory.getInstance().createSimpleElement(properties);
        }

        public void saveProperties(@NotNull final JpsSimpleElement<JpsFlexmojosSdkProperties> propertiesElement, @NotNull final Element element) {
            final JpsFlexmojosSdkProperties properties = propertiesElement.getData();
            final Element compilerClasspathElement = new Element(COMPILER_CLASSPATH_ELEMENT_NAME);
            for (final String classpathEntry : properties.getFlexCompilerClasspath()) {
                final Element classpathEntryElement = new Element(CLASSPATH_ENTRY_ELEMENT_NAME);
                classpathEntryElement.setText(classpathEntry);
                compilerClasspathElement.addContent(classpathEntryElement);
            }
            element.addContent(compilerClasspathElement);
            final Element adlPathElement = new Element(ADL_PATH_ELEMENT_NAME);
            adlPathElement.setText(properties.getAdlPath());
            element.addContent(adlPathElement);
            final Element airRuntimePathElement = new Element(AIR_RUNTIME_PATH_ELEMENT_NAME);
            airRuntimePathElement.setText(properties.getAirRuntimePath());
            element.addContent(airRuntimePathElement);
        }
    };
}
Also used : JpsSimpleElement(org.jetbrains.jps.model.JpsSimpleElement) Element(org.jdom.Element) JpsSdkPropertiesSerializer(org.jetbrains.jps.model.serialization.library.JpsSdkPropertiesSerializer) ArrayList(java.util.ArrayList) JpsSimpleElement(org.jetbrains.jps.model.JpsSimpleElement) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ArrayList (java.util.ArrayList)1 Element (org.jdom.Element)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 JpsSimpleElement (org.jetbrains.jps.model.JpsSimpleElement)1 JpsSdkPropertiesSerializer (org.jetbrains.jps.model.serialization.library.JpsSdkPropertiesSerializer)1