Search in sources :

Example 81 with Element

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

the class TaskManagerTest method testSharedServers.

public void testSharedServers() throws Exception {
    TaskRepository repository = new YouTrackRepository(new YouTrackRepositoryType());
    repository.setShared(true);
    myTaskManager.setRepositories(Collections.singletonList(repository));
    TaskProjectConfiguration configuration = ServiceManager.getService(getProject(), TaskProjectConfiguration.class);
    TaskProjectConfiguration state = configuration.getState();
    assertNotNull(state);
    assertEquals(1, state.servers.size());
    Element element = XmlSerializer.serialize(state);
    configuration.servers.clear();
    myTaskManager.setRepositories(Collections.emptyList());
    configuration.loadState(XmlSerializer.deserialize(element, TaskProjectConfiguration.class));
    assertEquals(1, state.servers.size());
    myTaskManager.projectOpened();
    TaskRepository[] repositories = myTaskManager.getAllRepositories();
    assertEquals(1, repositories.length);
    assertTrue(repositories[0].isShared());
}
Also used : TaskProjectConfiguration(com.intellij.tasks.impl.TaskProjectConfiguration) YouTrackRepositoryType(com.intellij.tasks.youtrack.YouTrackRepositoryType) YouTrackRepository(com.intellij.tasks.youtrack.YouTrackRepository) Element(org.jdom.Element)

Example 82 with Element

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

the class PivotalTrackerRepository method setTaskState.

@Override
public void setTaskState(@NotNull Task task, @NotNull TaskState state) throws Exception {
    final String realId = getRealId(task.getId());
    if (realId == null)
        return;
    final String stateName;
    switch(state) {
        case IN_PROGRESS:
            stateName = "started";
            break;
        case RESOLVED:
            stateName = "finished";
            break;
        // may add some others in future
        default:
            return;
    }
    String url = API_URL + "/projects/" + myProjectId + "/stories/" + realId;
    url += "?" + encodeUrl("story[current_state]") + "=" + encodeUrl(stateName);
    LOG.info("Updating issue state by id: " + url);
    final HttpMethod method = doREST(url, HTTPMethod.PUT);
    final InputStream stream = method.getResponseBodyAsStream();
    final Element element = new SAXBuilder(false).build(stream).getRootElement();
    if (!element.getName().equals("story")) {
        if (element.getName().equals("errors")) {
            throw new Exception(extractErrorMessage(element));
        } else {
            // unknown error, probably our fault
            LOG.warn("Error setting state for: " + url + ", HTTP status code: " + method.getStatusCode());
            throw new Exception(String.format("Cannot set state '%s' for issue.", stateName));
        }
    }
}
Also used : SAXBuilder(org.jdom.input.SAXBuilder) InputStream(java.io.InputStream) Element(org.jdom.Element) HttpMethod(org.apache.commons.httpclient.HttpMethod) ParseException(java.text.ParseException)

Example 83 with Element

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

the class YouTrackIntegrationTest method checkSpentTime.

private void checkSpentTime(@NotNull HttpClient client, @NotNull String issueId, @NotNull String expectedTime) throws IOException, JDOMException {
    // Endpoint /rest/issue/BTYT4TT-8/timetracking/workitem/ doesn't work on this instance of YouTrack for some reason
    final GetMethod method = new GetMethod(myRepository.getUrl() + "/rest/issue/" + issueId);
    final int statusCode = client.executeMethod(method);
    assertEquals(HttpStatus.SC_OK, statusCode);
    final Element root = JDOMUtil.load(method.getResponseBodyAsStream());
    for (Element field : root.getChildren("field")) {
        if ("Spent time".equals(field.getAttributeValue("name"))) {
            final Element value = field.getChild("value");
            assertNotNull(value);
            assertEquals(expectedTime, value.getText().trim());
            return;
        }
    }
    fail("Field 'Spent time' not found in issue " + issueId);
}
Also used : Element(org.jdom.Element) GetMethod(org.apache.commons.httpclient.methods.GetMethod)

Example 84 with Element

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

the class EditorsContextTest method testDockableContainer.

public void testDockableContainer() throws Exception {
    VirtualFile file = getFile("/foo.txt");
    myManager.openFile(file, false);
    DockManager dockManager = DockManager.getInstance(getProject());
    assertEquals(1, dockManager.getContainers().size());
    myManager.initDockableContentFactory();
    myManager.openFileInNewWindow(file);
    assertEquals(2, dockManager.getContainers().size());
    Element context = new Element("context");
    WorkingContextManager contextManager = WorkingContextManager.getInstance(getProject());
    contextManager.saveContext(context);
    assertEquals(2, context.getChild("editors").getChildren().size());
    assertEquals(2, EditorFactory.getInstance().getAllEditors().length);
    contextManager.clearContext();
    assertEquals(1, dockManager.getContainers().size());
    assertEquals(0, EditorFactory.getInstance().getAllEditors().length);
//contextManager.loadContext(context);
//assertEquals(2, dockManager.getContainers().size());
//Editor[] editors = EditorFactory.getInstance().getAllEditors();
//assertEquals(2, editors.length);
//
//contextManager.clearContext();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DockManager(com.intellij.ui.docking.DockManager) Element(org.jdom.Element)

Example 85 with Element

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

the class XPathProjectComponent method getState.

public Element getState() {
    Element element = new Element("xpathview");
    writeHistory(element, HISTORY, history);
    writeHistory(element, FIND_HISTORY, findHistory);
    return element;
}
Also used : Element(org.jdom.Element)

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