Exemplo n.º 1
0
  public void testLocalTaskAddToSelf() {
    LocalTask task = new LocalTask("1", "summary");

    taskList.addTask(task);
    assertFalse(taskList.addTask(task, task));
    assertEquals(0, task.getChildren().size());
    assertEquals(1, task.getParentContainers().size());
  }
Exemplo n.º 2
0
  public void testLocalSubTaskAdd() {
    LocalTask task = new LocalTask("1", "summary");
    LocalTask subTask = new LocalTask("2", "subTask");

    taskList.addTask(task);
    taskList.addTask(subTask, task);

    assertEquals(1, task.getChildren().size());
    assertEquals(subTask, task.getChildren().iterator().next());
  }
Exemplo n.º 3
0
  @Override
  public void run() {
    if (selectedTask == null) {
      return;
    }

    if (selectedTask instanceof LocalTask) {
      // XXX code copied from NewLocalTaskWizard.performFinish() and
      // TaskListManager.createNewLocalTask()
      TaskList taskList = TasksUiPlugin.getTaskList();
      LocalTask newTask =
          new LocalTask(
              "" + taskList.getNextLocalTaskId(), // $NON-NLS-1$
              LocalRepositoryConnector.DEFAULT_SUMMARY);
      newTask.setPriority(PriorityLevel.P3.toString());
      TasksUiInternal.scheduleNewTask(newTask);
      taskList.addTask(newTask, selectedTask);
      TasksUiUtil.openTask(newTask);
      return;
    }

    AbstractRepositoryConnector connector =
        TasksUi.getRepositoryManager().getRepositoryConnector(selectedTask.getConnectorKind());
    IWizard wizard = getNewSubTaskWizard();
    if (wizard != null) {
      WizardDialog dialog = new WizardDialog(WorkbenchUtil.getShell(), wizard);
      dialog.setBlockOnOpen(true);
      dialog.open();
      return;
    }
    TaskData taskData = createTaskData(connector);
    if (taskData != null) {
      try {
        TasksUiInternal.createAndOpenNewTask(taskData);
      } catch (CoreException e) {
        StatusHandler.log(
            new Status(
                IStatus.ERROR,
                TasksUiPlugin.ID_PLUGIN,
                "Failed to open new sub task",
                e)); //$NON-NLS-1$
        TasksUiInternal.displayStatus(
            Messages.NewSubTaskAction_Unable_to_create_subtask,
            new Status(
                IStatus.ERROR,
                TasksUiPlugin.ID_PLUGIN,
                Messages.NewSubTaskAction_Failed_to_create_new_sub_task_ + e.getMessage()));
      }
    }
  }
Exemplo n.º 4
0
  public void testLocalSubTaskAddDeepCycle() {
    LocalTask task = new LocalTask("1", "summary");
    LocalTask subTask1 = new LocalTask("2", "subTask");
    LocalTask subTask2 = new LocalTask("3", "subTask");
    LocalTask subTask3 = new LocalTask("4", "subTask");
    LocalTask subTask4 = new LocalTask("5", "subTask");
    LocalTask subTask5 = new LocalTask("6", "subTask");
    LocalTask subTask6 = new LocalTask("7", "subTask");
    LocalTask subTask7 = new LocalTask("8", "subTask");
    LocalTask subTask8 = new LocalTask("9", "subTask");
    LocalTask subTask9 = new LocalTask("10", "subTask");
    LocalTask subTask10 = new LocalTask("11", "subTask");

    taskList.addTask(task);
    taskList.addTask(subTask1, task);
    taskList.addTask(subTask2, subTask1);
    taskList.addTask(subTask3, subTask2);
    taskList.addTask(subTask4, subTask3);
    taskList.addTask(subTask5, subTask4);
    taskList.addTask(subTask6, subTask5);
    taskList.addTask(subTask7, subTask6);
    taskList.addTask(subTask8, subTask7);
    taskList.addTask(subTask9, subTask8);
    taskList.addTask(subTask10, subTask9);

    taskList.addTask(task, subTask10);

    assertEquals(11, taskList.getAllTasks().size());
    assertEquals(1, taskList.getCategories().size());
    assertEquals(1, taskList.getCategories().iterator().next().getChildren().size());
    assertEquals(1, task.getChildren().size());
    assertEquals(subTask1, task.getChildren().iterator().next());

    assertEquals(1, subTask1.getChildren().size());
    assertEquals(subTask2, subTask1.getChildren().iterator().next());

    assertEquals(1, subTask2.getChildren().size());
    assertEquals(subTask3, subTask2.getChildren().iterator().next());

    assertEquals(1, subTask3.getChildren().size());
    assertEquals(subTask4, subTask3.getChildren().iterator().next());

    assertEquals(1, subTask4.getChildren().size());
    assertEquals(subTask5, subTask4.getChildren().iterator().next());

    assertEquals(1, subTask5.getChildren().size());
    assertEquals(subTask6, subTask5.getChildren().iterator().next());

    assertEquals(1, subTask6.getChildren().size());
    assertEquals(subTask7, subTask6.getChildren().iterator().next());

    assertEquals(1, subTask7.getChildren().size());
    assertEquals(subTask8, subTask7.getChildren().iterator().next());

    assertEquals(1, subTask8.getChildren().size());
    assertEquals(subTask9, subTask8.getChildren().iterator().next());

    assertEquals(1, subTask9.getChildren().size());
    assertEquals(subTask10, subTask9.getChildren().iterator().next());

    assertEquals(0, subTask10.getChildren().size());
  }