Search in sources :

Example 21 with Attribute

use of org.jdom.Attribute in project freud by LMAX-Exchange.

the class MethodCallJdom method getMethodName.

@SuppressWarnings("unchecked")
public String getMethodName() {
    if (methodName == null) {
        final Attribute idAttr = methodCallElement.getAttribute(JdomTreeAdaptor.ID_ATTR);
        if (idAttr != null) {
            methodName = idAttr.getValue();
            instanceReferences = EMPTY_ARRAY;
        } else {
            JXPathContext context = JXPathContext.newContext(methodCallElement);
            final List<Element> identElementList = context.selectNodes("//" + JavaSourceTokenType.IDENT.getName());
            Collections.sort(identElementList, JdomTreePositionComparator.getInstance());
            final int methodNameIndex = identElementList.size() - 1;
            methodName = identElementList.get(methodNameIndex).getText();
            instanceReferences = new String[methodNameIndex];
            for (int i = 0, size = instanceReferences.length; i < size; i++) {
                instanceReferences[i] = identElementList.get(i).getText();
            }
        }
    }
    return methodName;
}
Also used : JXPathContext(org.apache.commons.jxpath.JXPathContext) Attribute(org.jdom.Attribute) Element(org.jdom.Element)

Example 22 with Attribute

use of org.jdom.Attribute in project intellij-community by JetBrains.

the class LwXmlReader method getColorDescriptor.

public static ColorDescriptor getColorDescriptor(final Element element) throws Exception {
    Attribute attr = element.getAttribute(UIFormXmlConstants.ATTRIBUTE_COLOR);
    if (attr != null) {
        return new ColorDescriptor(new Color(attr.getIntValue()));
    }
    String swingColor = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_SWING_COLOR);
    if (swingColor != null) {
        return ColorDescriptor.fromSwingColor(swingColor);
    }
    String systemColor = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_SYSTEM_COLOR);
    if (systemColor != null) {
        return ColorDescriptor.fromSystemColor(systemColor);
    }
    String awtColor = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_AWT_COLOR);
    if (awtColor != null) {
        return ColorDescriptor.fromAWTColor(awtColor);
    }
    return new ColorDescriptor(null);
}
Also used : Attribute(org.jdom.Attribute)

Example 23 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 24 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 25 with Attribute

use of org.jdom.Attribute in project intellij-community by JetBrains.

the class UnknownRunConfiguration method writeExternal.

@Override
public void writeExternal(final Element element) throws WriteExternalException {
    if (myStoredElement != null) {
        final List attributeList = myStoredElement.getAttributes();
        for (Object anAttributeList : attributeList) {
            final Attribute a = (Attribute) anAttributeList;
            element.setAttribute(a.getName(), a.getValue());
        }
        final List list = myStoredElement.getChildren();
        for (Object child : list) {
            final Element c = (Element) child;
            element.addContent((Element) c.clone());
        }
    }
}
Also used : Attribute(org.jdom.Attribute) Element(org.jdom.Element) List(java.util.List)

Aggregations

Attribute (org.jdom.Attribute)40 Element (org.jdom.Element)30 DataConversionException (org.jdom.DataConversionException)6 ArrayList (java.util.ArrayList)4 Document (org.jdom.Document)3 SAXBuilder (org.jdom.input.SAXBuilder)3 NotNull (org.jetbrains.annotations.NotNull)3 PathMacrosImpl (com.intellij.application.options.PathMacrosImpl)2 PathMacroFilter (com.intellij.openapi.application.PathMacroFilter)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 EntityResolver (org.xml.sax.EntityResolver)2 AbstractColorsScheme (com.intellij.openapi.editor.colors.impl.AbstractColorsScheme)1 DefaultColorsScheme (com.intellij.openapi.editor.colors.impl.DefaultColorsScheme)1 SchemeImportException (com.intellij.openapi.options.SchemeImportException)1 VirtualFileManager (com.intellij.openapi.vfs.VirtualFileManager)1 ReplacementVariableDefinition (com.intellij.structuralsearch.ReplacementVariableDefinition)1 LwRootContainer (com.intellij.uiDesigner.lw.LwRootContainer)1 THashSet (gnu.trove.THashSet)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1