示例#1
0
  public void testUpdateQueryHits() {
    MockTask hit1 = new MockTask("1");
    MockTask hit2 = new MockTask("2");
    MockTask hit3 = new MockTask("3");

    MockTask hit1twin = new MockTask("1");
    MockTask hit2twin = new MockTask("2");
    MockTask hit3twin = new MockTask("3");

    MockRepositoryQuery query1 = new MockRepositoryQuery("query1");
    taskList.addQuery(query1);

    taskList.addTask(hit1, query1);
    taskList.addTask(hit2, query1);
    taskList.addTask(hit3, query1);

    taskList.addTask(hit1twin, query1);
    taskList.addTask(hit2twin, query1);
    taskList.addTask(hit3twin, query1);

    assertEquals(3, query1.getChildren().size());
    for (ITask child : query1.getChildren()) {
      taskList.removeFromContainer(query1, child);
    }
    assertEquals(0, query1.getChildren().size());
    taskList.addTask(hit1, query1);
    taskList.addTask(hit2, query1);
    assertEquals(2, query1.getChildren().size());
    hit1.setNotified(true);

    taskList.addTask(hit1twin, query1);
    taskList.addTask(hit2twin, query1);
    taskList.addTask(hit3twin, query1);
    assertEquals(3, query1.getChildren().size());
    assertTrue(query1.getChildren().contains(hit1twin));
    assertTrue(query1.getChildren().contains(hit2twin));
    assertTrue(query1.getChildren().contains(hit3twin));
    for (ITask hit : query1.getChildren()) {
      if (hit.equals(hit1twin)) {
        assertTrue(((AbstractTask) hit).isNotified());
      } else {
        assertFalse(((AbstractTask) hit).isNotified());
      }
    }
  }
 public void containersChanged(Set<TaskContainerDelta> containers) {
   // update label in case task changes
   if (activeTask != null) {
     for (TaskContainerDelta taskContainerDelta : containers) {
       if (activeTask.equals(taskContainerDelta.getElement())) {
         if (taskContainerDelta.getKind().equals(TaskContainerDelta.Kind.CONTENT)) {
           Display.getDefault()
               .asyncExec(
                   new Runnable() {
                     public void run() {
                       if (activeTask != null && activeTask.isActive()) {
                         indicateActiveTask();
                       }
                     }
                   });
           return;
         }
       }
     }
   }
 }