Search in sources :

Example 51 with Element

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

the class FogBugzRepository method login.

private void login(@NotNull PostMethod method) throws Exception {
    LOG.debug("Requesting new token");
    int status = getHttpClient().executeMethod(method);
    if (status != 200) {
        throw new Exception("Error logging in: " + method.getStatusLine());
    }
    Document document = new SAXBuilder(false).build(method.getResponseBodyAsStream()).getDocument();
    XPath path = XPath.newInstance("/response/token");
    Element result = (Element) path.selectSingleNode(document);
    if (result == null) {
        Element error = (Element) XPath.newInstance("/response/error").selectSingleNode(document);
        throw new Exception(error == null ? "Error logging in" : error.getText());
    }
    myToken = result.getTextTrim();
}
Also used : XPath(org.jdom.xpath.XPath) SAXBuilder(org.jdom.input.SAXBuilder) Element(org.jdom.Element) Document(org.jdom.Document) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException)

Example 52 with Element

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

the class XPathResponseHandler method selectTasksList.

@NotNull
@Override
protected List<Object> selectTasksList(@NotNull String response, int max) throws Exception {
    Document document = new SAXBuilder(false).build(new StringReader(response));
    Element root = document.getRootElement();
    XPath xPath = lazyCompile(getSelector(TASKS).getPath());
    @SuppressWarnings("unchecked") List<Object> rawTaskElements = xPath.selectNodes(root);
    if (!rawTaskElements.isEmpty() && !(rawTaskElements.get(0) instanceof Element)) {
        throw new Exception(String.format("Expression '%s' should match list of XML elements. Got '%s' instead.", xPath.getXPath(), rawTaskElements.toString()));
    }
    return rawTaskElements.subList(0, Math.min(rawTaskElements.size(), max));
}
Also used : XPath(org.jdom.xpath.XPath) SAXBuilder(org.jdom.input.SAXBuilder) Element(org.jdom.Element) StringReader(java.io.StringReader) Document(org.jdom.Document) JDOMException(org.jdom.JDOMException) NotNull(org.jetbrains.annotations.NotNull)

Example 53 with Element

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

the class ProjectViewContextProvider method saveContext.

public void saveContext(Element toElement) throws WriteExternalException {
    for (AbstractProjectViewPane pane : myPanes) {
        Element paneElement = new Element(pane.getId());
        pane.writeExternal(paneElement);
        toElement.addContent(paneElement);
    }
}
Also used : Element(org.jdom.Element) AbstractProjectViewPane(com.intellij.ide.projectView.impl.AbstractProjectViewPane)

Example 54 with Element

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

the class WorkingContextManager method saveContext.

public void saveContext(Element toElement) {
    for (WorkingContextProvider provider : Extensions.getExtensions(WorkingContextProvider.EP_NAME, myProject)) {
        try {
            Element child = new Element(provider.getId());
            provider.saveContext(child);
            toElement.addContent(child);
        } catch (WriteExternalException e) {
            LOG.error(e);
        }
    }
}
Also used : Element(org.jdom.Element) WriteExternalException(com.intellij.openapi.util.WriteExternalException)

Example 55 with Element

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

the class XDebuggerBreakpointsContextProvider method saveContext.

@Override
public void saveContext(Element toElement) throws WriteExternalException {
    XBreakpointManagerImpl.BreakpointManagerState state = myBreakpointManager.getState();
    Element serialize = XmlSerializer.serialize(state, new SerializationFilter() {

        @Override
        public boolean accepts(@NotNull Accessor accessor, @NotNull Object bean) {
            return accessor.read(bean) != null;
        }
    });
    toElement.addContent(serialize.removeContent());
}
Also used : SerializationFilter(com.intellij.util.xmlb.SerializationFilter) Element(org.jdom.Element) Accessor(com.intellij.util.xmlb.Accessor) XBreakpointManagerImpl(com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl)

Aggregations

Element (org.jdom.Element)1994 BioPaxObject (org.vcell.pathway.BioPaxObject)143 ArrayList (java.util.ArrayList)141 NotNull (org.jetbrains.annotations.NotNull)103 IOException (java.io.IOException)102 Document (org.jdom.Document)102 Nullable (org.jetbrains.annotations.Nullable)98 List (java.util.List)84 File (java.io.File)78 GroupObject (org.vcell.pathway.GroupObject)75 VirtualFile (com.intellij.openapi.vfs.VirtualFile)67 JDOMException (org.jdom.JDOMException)57 Expression (cbit.vcell.parser.Expression)47 SAXBuilder (org.jdom.input.SAXBuilder)47 ExpressionException (cbit.vcell.parser.ExpressionException)45 Iterator (java.util.Iterator)45 PsiElement (com.intellij.psi.PsiElement)44 Attribute (org.jdom.Attribute)42 XMLOutputter (org.jdom.output.XMLOutputter)34 Namespace (org.jdom.Namespace)32