Search in sources :

Example 16 with Attribute

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

the class JstdRunSettingsSerializationUtils method readFilesExcludedFromCoverage.

@SuppressWarnings("unchecked")
private static List<String> readFilesExcludedFromCoverage(@NotNull Element root) {
    List<String> excludedPaths = Lists.newArrayList();
    Element coverageElement = root.getChild(Key.COVERAGE.getKey());
    if (coverageElement != null) {
        List<Element> excludedElements = coverageElement.getChildren(Key.COVERAGE_EXCLUDED.getKey());
        for (Element excludedElement : excludedElements) {
            Attribute pathAttr = excludedElement.getAttribute(Key.COVERAGE_EXCLUDED_PATH.getKey());
            if (pathAttr != null) {
                String path = pathAttr.getValue();
                if (StringUtil.isNotEmpty(path)) {
                    excludedPaths.add(FileUtil.toSystemDependentName(path));
                }
            }
        }
    }
    return excludedPaths;
}
Also used : Attribute(org.jdom.Attribute) Element(org.jdom.Element)

Example 17 with Attribute

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

the class FlashBuilderSdkFinder method initSdksConfiguredInWorkspace.

private boolean initSdksConfiguredInWorkspace(final String fbWorkspacePath) {
    final Element sdkInfoDocument = loadSdkInfoDocument(fbWorkspacePath);
    if (sdkInfoDocument == null) {
        return false;
    }
    final Element sdksElement = sdkInfoDocument;
    if (!sdksElement.getName().equals(SDKS_ELEMENT))
        return false;
    //noinspection unchecked
    for (final Element sdkElement : sdksElement.getChildren(SDK_ELEMENT)) {
        final Attribute defaultSdkAttr = sdkElement.getAttribute(DEFAULT_SDK_ATTR);
        final Attribute sdkNameAttr = sdkElement.getAttribute(SDK_NAME_ATTR);
        final Attribute sdkLocationAttr = sdkElement.getAttribute(SDK_LOCATION_ATTR);
        if (sdkLocationAttr != null) {
            if (defaultSdkAttr != null && defaultSdkAttr.getValue().equalsIgnoreCase("true")) {
                mySdkNameToRootPath.put(DEFAULT_SDK_NAME, FileUtil.toSystemIndependentName(sdkLocationAttr.getValue()));
            }
            if (sdkNameAttr != null) {
                mySdkNameToRootPath.put(sdkNameAttr.getValue(), FileUtil.toSystemIndependentName(sdkLocationAttr.getValue()));
            }
        }
    }
    return true;
}
Also used : Attribute(org.jdom.Attribute) Element(org.jdom.Element)

Example 18 with Attribute

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

the class SplitTextEditorProvider method readState.

@NotNull
@Override
public FileEditorState readState(@NotNull Element sourceElement, @NotNull Project project, @NotNull VirtualFile file) {
    Element child = sourceElement.getChild(FIRST_EDITOR);
    FileEditorState firstState = null;
    if (child != null) {
        firstState = myFirstProvider.readState(child, project, file);
    }
    child = sourceElement.getChild(SECOND_EDITOR);
    FileEditorState secondState = null;
    if (child != null) {
        secondState = mySecondProvider.readState(child, project, file);
    }
    final Attribute attribute = sourceElement.getAttribute(SPLIT_LAYOUT);
    final String layoutName;
    if (attribute != null) {
        layoutName = attribute.getValue();
    } else {
        layoutName = null;
    }
    return new SplitFileEditor.MyFileEditorState(layoutName, firstState, secondState);
}
Also used : Attribute(org.jdom.Attribute) Element(org.jdom.Element) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with Attribute

use of org.jdom.Attribute in project beast-mcmc by beast-dev.

the class GraphMLUtils method dotFormat.

public static String dotFormat(Element graphElement) {
    StringBuilder sb = new StringBuilder();
    String graphName = graphElement.getAttributeValue(ARGModel.ID_ATTRIBUTE);
    sb.append(GRAPH_NAME);
    space(sb);
    if (graphName != null) {
        sb.append(graphName);
        space(sb);
    }
    startSection(sb);
    newLine(sb);
    tab(sb);
    sb.append(ARGModel.GRAPH_SIZE);
    endLine(sb);
    //		newLine(sb);
    tab(sb);
    sb.append(ARGModel.DOT_EDGE_DEF);
    endLine(sb);
    //		newLine(sb);
    tab(sb);
    sb.append(ARGModel.DOT_NODE_DEF);
    endLine(sb);
    // Fill in graph details
    List<Element> nodeList = graphElement.getChildren(ARGModel.NODE_ELEMENT);
    List<String> tipNames = new ArrayList<String>();
    for (Element nodeElement : nodeList) {
        String nodeName = nodeElement.getAttributeValue(ARGModel.ID_ATTRIBUTE);
        tab(sb);
        sb.append(nodeName);
        List<Attribute> attributes = nodeElement.getAttributes();
        int cnt = 1;
        boolean started = false;
        boolean isTip = false;
        int length = attributes.size();
        for (Attribute attribute : attributes) {
            String name = attribute.getName();
            if (name.compareTo(ARGModel.ID_ATTRIBUTE) != 0) {
                if (name.compareTo(ARGModel.IS_TIP) == 0) {
                    isTip = true;
                    try {
                        if (attribute.getBooleanValue()) {
                            tipNames.add(nodeName);
                        }
                    } catch (DataConversionException e) {
                        //To change body of catch statement use File | Settings | File Templates.
                        e.printStackTrace();
                    }
                    cnt++;
                } else {
                    if (!ignore(name)) {
                        if (!started) {
                            space(sb);
                            startAttribute(sb);
                            started = true;
                        } else
                            nextAttribute(sb);
                        sb.append(translate(name) + "=" + attribute.getValue());
                        cnt++;
                    //							if (cnt < length)
                    //								nextAttribute(sb);
                    //							else {
                    //							}
                    }
                }
            }
        }
        if (!isTip) {
            if (!started) {
                space(sb);
                startAttribute(sb);
                started = true;
            } else {
                nextAttribute(sb);
            }
            sb.append("label=\"\",shape=circle,height=0.02,width=0.2,fontsize=1");
        }
        if (started) {
            endAttribute(sb);
        }
        //			if (!isTip) {
        //
        //			}
        endLine(sb);
    }
    List<Element> edgeList = graphElement.getChildren(ARGModel.EDGE_ELEMENT);
    for (Element edgeElement : edgeList) {
        String fromName = edgeElement.getAttributeValue(ARGModel.EDGE_FROM);
        String toName = edgeElement.getAttributeValue(ARGModel.EDGE_TO);
        tab(sb);
        sb.append(fromName + " -> " + toName);
        String edgeLength = edgeElement.getAttributeValue(ARGModel.EDGE_LENGTH);
        if (edgeLength != null && printLengths) {
            space(sb);
            startAttribute(sb);
            sb.append(ARGModel.EDGE_LENGTH + "=" + edgeLength + ",weight=1000.0");
            endAttribute(sb);
        }
        String partitions = edgeElement.getAttributeValue(ARGModel.EDGE_PARTITIONS);
        if (partitions != null) {
            space(sb);
            startAttribute(sb);
            sb.append("label=\"" + partitions + "\"");
            endAttribute(sb);
        }
        endLine(sb);
    }
    //newLine(sb);
    if (tipNames.size() > 0) {
        tab(sb);
        startSection(sb);
        sb.append("rank=same;");
        for (String name : tipNames) {
            space(sb);
            sb.append(name);
        }
        endSection(sb);
        newLine(sb);
    }
    endSection(sb);
    return sb.toString();
}
Also used : Attribute(org.jdom.Attribute) Element(org.jdom.Element) ArrayList(java.util.ArrayList) DataConversionException(org.jdom.DataConversionException)

Example 20 with Attribute

use of org.jdom.Attribute in project che by eclipse.

the class JdomUtil method getHash.

private static int getHash(int hash, Element element) {
    hash = sumHash(hash, element.getName());
    for (Object object : element.getAttributes()) {
        Attribute attribute = (Attribute) object;
        hash = sumHash(hash, attribute.getName());
        hash = sumHash(hash, attribute.getValue());
    }
    for (Object o : element.getContent()) {
        if (o instanceof Element) {
            hash = getHash(hash, (Element) o);
        } else if (o instanceof Text) {
            String text = ((Text) o).getText();
            if (!isNullOrWhitespace(text)) {
                hash = sumHash(hash, text);
            }
        }
    }
    return hash;
}
Also used : Attribute(org.jdom.Attribute) Element(org.jdom.Element) Text(org.jdom.Text)

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