// Bug 224703 - Project explorer doesn't show recreated working set
  // (this test does not show the problem since it was in the
  // WorkingSetSelectionDialog, but still it's nice to have)
  public void testDeletedAndRecreated() throws Exception {

    INavigatorContentExtension ce =
        _contentService.getContentExtensionById(WorkingSetsContentProvider.EXTENSION_ID);
    ce.getContentProvider();

    IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();

    IWorkingSet ws1 = workingSetManager.createWorkingSet("ws1", new IAdaptable[] {_p1});
    workingSetManager.addWorkingSet(ws1);
    IWorkingSet ws2 = workingSetManager.createWorkingSet("ws2", new IAdaptable[] {_p2});
    workingSetManager.addWorkingSet(ws2);

    WorkingSetActionProvider provider =
        (WorkingSetActionProvider)
            TestAccessHelper.getActionProvider(
                _contentService, _actionService, WorkingSetActionProvider.class);

    IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage activePage = activeWindow.getActivePage();
    activePage.setWorkingSets(new IWorkingSet[] {ws1, ws2});

    IPropertyChangeListener l = provider.getFilterChangeListener();
    PropertyChangeEvent event =
        new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, ws2);
    l.propertyChange(event);

    DisplayHelper.runEventLoop(Display.getCurrent(), 100);

    TreeItem[] items = _viewer.getTree().getItems();
    assertTrue(items[0].getData().equals(_p2));

    l = provider.getFilterChangeListener();
    event =
        new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, ws1);
    l.propertyChange(event);
    DisplayHelper.runEventLoop(Display.getCurrent(), 100);
    items = _viewer.getTree().getItems();
    assertTrue(items[0].getData().equals(_p1));

    workingSetManager.removeWorkingSet(ws2);

    ws2 = workingSetManager.createWorkingSet("ws2", new IAdaptable[] {_p2});
    workingSetManager.addWorkingSet(ws2);

    l = provider.getFilterChangeListener();
    event =
        new PropertyChangeEvent(this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, ws2);
    l.propertyChange(event);
    DisplayHelper.runEventLoop(Display.getCurrent(), 100);
    items = _viewer.getTree().getItems();
    assertTrue(items[0].getData().equals(_p2));

    if (SLEEP_LONG) DisplayHelper.sleep(Display.getCurrent(), 10000000);
  }
  // Bug 212389 projects are not shown when they are not in the working set,
  // but their children are
  public void testMissingProjectsInWorkingSet() throws Exception {

    IFile f1 = _p1.getFile("f1");

    WorkingSetActionProvider provider =
        (WorkingSetActionProvider)
            TestAccessHelper.getActionProvider(
                _contentService, _actionService, WorkingSetActionProvider.class);

    IWorkingSet workingSet = new WorkingSet("ws1", "ws1", new IAdaptable[] {f1});

    AggregateWorkingSet agWorkingSet =
        new AggregateWorkingSet("AgWs", "Ag Working Set", new IWorkingSet[] {workingSet});

    IPropertyChangeListener l = provider.getFilterChangeListener();
    PropertyChangeEvent event =
        new PropertyChangeEvent(
            this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, agWorkingSet);
    l.propertyChange(event);

    DisplayHelper.runEventLoop(Display.getCurrent(), 100);

    // DisplayHelper.sleep(Display.getCurrent(), 10000000);

    TreeItem[] items = _viewer.getTree().getItems();
    // The bug is here where the first item is a IFile, not the enclosing
    // project
    assertTrue("First item needs to be project", items[0].getData().equals(_p1));
    assertEquals("ws1", _commonNavigator.getWorkingSetLabel());
  }