// bug 244174 test property to switch back and forth between working sets
  // as top level and not
  public void testTopLevelChange() throws Exception {

    IExtensionStateModel extensionStateModel =
        _contentService.findStateModel(WorkingSetsContentProvider.EXTENSION_ID);

    // Force the content provider to be loaded so that it responds to the
    // working set events
    INavigatorContentExtension ce =
        _contentService.getContentExtensionById(WorkingSetsContentProvider.EXTENSION_ID);
    ce.getContentProvider();

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

    WorkingSetActionProvider provider =
        (WorkingSetActionProvider)
            TestAccessHelper.getActionProvider(
                _contentService, _actionService, WorkingSetActionProvider.class);
    IPropertyChangeListener l = provider.getFilterChangeListener();
    PropertyChangeEvent event =
        new PropertyChangeEvent(
            this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, workingSet);
    l.propertyChange(event);

    IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage activePage = activeWindow.getActivePage();
    IWorkingSet[] activeWorkingSets = activePage.getWorkingSets();
    activePage.setWorkingSets(new IWorkingSet[] {workingSet});

    extensionStateModel.setBooleanProperty(
        WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, true);
    refreshViewer();

    TreeItem[] items = _viewer.getTree().getItems();

    assertTrue("First item needs to be working set", items[0].getData().equals(workingSet));

    extensionStateModel.setBooleanProperty(
        WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, false);
    refreshViewer();

    items = _viewer.getTree().getItems();
    assertTrue("First item needs to be project", items[0].getData().equals(_p1));

    extensionStateModel.setBooleanProperty(
        WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, true);
    refreshViewer();

    items = _viewer.getTree().getItems();
    assertTrue("First item needs to be working set", items[0].getData().equals(workingSet));

    // Restore active working sets
    activePage.setWorkingSets(activeWorkingSets);
  }
 /* (non-Javadoc)
  * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
  */
 @Override
 public boolean select(Viewer viewer, Object parentElement, Object element) {
   if (element instanceof ILaunchConfigurationType) {
     return true;
   }
   if (element instanceof ILaunchConfiguration) {
     ILaunchConfiguration config = (ILaunchConfiguration) element;
     try {
       IResource[] resources = config.getMappedResources();
       if (resources == null) {
         return true;
       }
       IWorkbenchWindow window = DebugUIPlugin.getActiveWorkbenchWindow();
       if (window == null) {
         return true;
       }
       IWorkbenchPage page = window.getActivePage();
       if (page == null) {
         return true;
       }
       IWorkingSet[] wsets = page.getWorkingSets();
       if (wsets.length < 1) {
         return true;
       }
       // remove breakpoint working sets
       ArrayList<IWorkingSet> ws = new ArrayList<IWorkingSet>();
       for (int i = 0; i < wsets.length; i++) {
         if (!IDebugUIConstants.BREAKPOINT_WORKINGSET_ID.equals(wsets[i].getId())) {
           ws.add(wsets[i]);
         }
       }
       if (ws.isEmpty()) {
         return true;
       }
       for (int i = 0; i < resources.length; i++) {
         if (workingSetContains(ws.toArray(new IWorkingSet[ws.size()]), resources[i])) {
           return true;
         }
       }
     } catch (CoreException e) {
     }
   }
   return false;
 }