コード例 #1
0
  public void testPreferenceMigration() throws Exception {
    final TaskListSorter sorter = new TaskListSorter();
    TaskListView view = new TaskListView();
    XMLMemento memento = XMLMemento.createWriteRoot(MEMENTO_KEY_SORT_INDEX);
    IMemento child = memento.createChild(MEMENTO_KEY_SORTER);
    child.putInteger(MEMENTO_KEY_SORT_INDEX, 0);
    child.putInteger(MEMENTO_KEY_SORT_DIRECTION, 1);
    child = memento.createChild(MEMENTO_KEY_SORTER2);
    child.putInteger(MEMENTO_KEY_SORT_INDEX, 1);
    child.putInteger(MEMENTO_KEY_SORT_DIRECTION, -1);
    view.migrateSorterState(sorter, memento);
    assertEquals(
        SortCriterion.SortKey.PRIORITY, sorter.getComparator().getSortCriterion(0).getKey());
    assertEquals(1, sorter.getComparator().getSortCriterion(0).getDirection());
    assertEquals(
        SortCriterion.SortKey.SUMMARY, sorter.getComparator().getSortCriterion(1).getKey());
    assertEquals(-1, sorter.getComparator().getSortCriterion(1).getDirection());

    memento = XMLMemento.createWriteRoot(MEMENTO_KEY_SORT_INDEX);
    child = memento.createChild(MEMENTO_KEY_SORTER);
    child.putInteger(MEMENTO_KEY_SORT_INDEX, 3);
    child.putInteger(MEMENTO_KEY_SORT_DIRECTION, -1);
    child = memento.createChild(MEMENTO_KEY_SORTER2);
    child.putInteger(MEMENTO_KEY_SORT_INDEX, 2);
    child.putInteger(MEMENTO_KEY_SORT_DIRECTION, -1);
    view.migrateSorterState(sorter, memento);
    assertEquals(
        SortCriterion.SortKey.TASK_ID, sorter.getComparator().getSortCriterion(0).getKey());
    assertEquals(-1, sorter.getComparator().getSortCriterion(0).getDirection());
    assertEquals(
        SortCriterion.SortKey.DATE_CREATED, sorter.getComparator().getSortCriterion(1).getKey());
    assertEquals(-1, sorter.getComparator().getSortCriterion(1).getDirection());
  }
コード例 #2
0
 @Override
 public void run() {
   if (taskListView.getViewer() != null) {
     taskListView.getViewer().collapseAll();
   }
 }