Ejemplo n.º 1
0
 public void testContextFileRepair() throws Exception {
   WorkingContextManager manager = getContextManager();
   manager.saveContext("foo", "bar");
   File file = manager.getContextFile();
   assertTrue(file.length() > 0);
   FileUtil.writeToFile(file, "123"); // corrupt it
   manager.saveContext("foo", "bar");
 }
  @Override
  public LocalTask activateTask(@NotNull final Task origin, boolean clearContext) {
    LocalTask activeTask = getActiveTask();
    if (origin.equals(activeTask)) return activeTask;

    saveActiveTask();

    if (clearContext) {
      myContextManager.clearContext();
    }
    myContextManager.restoreContext(origin);

    final LocalTask task = doActivate(origin, true);

    return restoreVcsContext(task);
  }
Ejemplo n.º 3
0
 public void testPack() throws Exception {
   WorkingContextManager contextManager = getContextManager();
   for (int i = 0; i < 5; i++) {
     contextManager.saveContext("context" + Integer.toString(i), null);
     Thread.sleep(2000);
   }
   List<ContextInfo> history = contextManager.getContextHistory();
   ContextInfo first = history.get(0);
   System.out.println(first.date);
   ContextInfo last = history.get(history.size() - 1);
   System.out.println(last.date);
   contextManager.pack(3, 1);
   history = contextManager.getContextHistory();
   assertEquals(3, history.size());
   System.out.println(history.get(0).date);
   assertEquals("/context2", history.get(0).name);
 }
 @Override
 public void removeTask(LocalTask task) {
   if (task.isDefault()) return;
   if (myActiveTask.equals(task)) {
     activateTask(myTasks.get(LocalTaskImpl.DEFAULT_TASK_ID), true);
   }
   myTasks.remove(task.getId());
   myDispatcher.getMulticaster().taskRemoved(task);
   myContextManager.removeContext(task);
 }
Ejemplo n.º 5
0
  public void testSaveContext() throws Exception {
    WorkingContextManager manager = getContextManager();

    manager.saveContext("first", "comment");
    manager.clearContext();
    manager.loadContext("first");

    manager.saveContext(myTaskManager.getActiveTask());
    manager.clearContext();
    manager.restoreContext(myTaskManager.getActiveTask());
  }
  public void projectOpened() {

    TaskProjectConfiguration projectConfiguration = getProjectConfiguration();

    servers:
    for (TaskProjectConfiguration.SharedServer server : projectConfiguration.servers) {
      if (server.type == null || server.url == null) {
        continue;
      }
      for (TaskRepositoryType<?> repositoryType : TaskRepositoryType.getRepositoryTypes()) {
        if (repositoryType.getName().equals(server.type)) {
          for (TaskRepository repository : myRepositories) {
            if (!repositoryType.equals(repository.getRepositoryType())) {
              continue;
            }
            if (server.url.equals(repository.getUrl())) {
              continue servers;
            }
          }
          TaskRepository repository = repositoryType.createRepository();
          repository.setUrl(server.url);
          myRepositories.add(repository);
        }
      }
    }

    myContextManager.pack(200, 50);

    // make sure the task is associated with default changelist
    LocalTask defaultTask = findTask(LocalTaskImpl.DEFAULT_TASK_ID);
    LocalChangeList defaultList = myChangeListManager.findChangeList(LocalChangeList.DEFAULT_NAME);
    if (defaultList != null && defaultTask != null) {
      ChangeListInfo listInfo = new ChangeListInfo(defaultList);
      if (!defaultTask.getChangeLists().contains(listInfo)) {
        defaultTask.addChangelist(listInfo);
      }
    }

    // remove already not existing changelists from tasks changelists
    for (LocalTask localTask : getLocalTasks()) {
      for (Iterator<ChangeListInfo> iterator = localTask.getChangeLists().iterator();
          iterator.hasNext(); ) {
        final ChangeListInfo changeListInfo = iterator.next();
        if (myChangeListManager.getChangeList(changeListInfo.id) == null) {
          iterator.remove();
        }
      }
    }

    myChangeListManager.addChangeListListener(myChangeListListener);
  }
Ejemplo n.º 7
0
  public void testXDebugger() throws Exception {
    final WorkingContextManager manager = getContextManager();
    final XBreakpointManager breakpointManager =
        XDebuggerManager.getInstance(getProject()).getBreakpointManager();

    ApplicationManager.getApplication()
        .runWriteAction(
            new Runnable() {
              public void run() {
                XLineBreakpointImpl<XBreakpointProperties> breakpoint =
                    (XLineBreakpointImpl<XBreakpointProperties>)
                        breakpointManager.addLineBreakpoint(
                            new XsltBreakpointType(), "foo", 0, null);

                final String name = "foo";
                manager.saveContext(name, null);
                breakpointManager.removeBreakpoint(breakpoint);
              }
            });
    manager.loadContext("foo");
    XBreakpoint<?>[] breakpoints = breakpointManager.getAllBreakpoints();
    assertEquals(1, breakpoints.length);
    manager.clearContext();
  }
Ejemplo n.º 8
0
 private WorkingContextManager getContextManager() {
   return WorkingContextManager.getInstance(getProject());
 }
 private void saveActiveTask() {
   myContextManager.saveContext(myActiveTask);
   myActiveTask.setUpdated(new Date());
 }