// 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); }
@Override public void switchToSolution(String id) { IWorkbenchPage activePage = getWorkbench().getActiveWorkbenchWindow().getActivePage(); // store the state of the current solution closeSolution(session.getCurrentSolution()); IWorkingSetManager wsManager = getWorkbench().getWorkingSetManager(); Map<String, IWorkingSet> workingSetMap = getWorkingSetMap(); IAggregateWorkingSet solutionSet = (IAggregateWorkingSet) workingSetMap.get(id); Assert.isNotNull(solutionSet, "Solution set is null: " + id); // IWorkingSet[] windowSet = new IWorkingSet[]{solutionSet}; IWorkingSet[] windowSet = solutionSet.getComponents(); // HACK: currently the ProcjectExplorer>WorkingSetDialog does // strange things with working sets, i.e., caches aggregate sets that can // get invalid as these are not updated, properly // workaround: delete these aggregate sets when you can :) String eclispeAggId = getAggregateIdForSets(windowSet); if (workingSetMap.containsKey(eclispeAggId)) { wsManager.removeWorkingSet(workingSetMap.get(eclispeAggId)); } activePage.setWorkingSets(windowSet); openSolution(id); session.setCurrentSolution(id); }
// 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); }