public void testMultipleWorkingSets() throws Exception { // 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 workingSet1 = new WorkingSet("ws1", "ws1", new IAdaptable[] {_p1}); IWorkingSet workingSet2 = new WorkingSet("ws2", "ws2", new IAdaptable[] {_p1}); AggregateWorkingSet agWorkingSet = new AggregateWorkingSet( "AgWs", "Ag Working Set", new IWorkingSet[] {workingSet1, workingSet2}); WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper.getActionProvider( _contentService, _actionService, WorkingSetActionProvider.class); IPropertyChangeListener l = provider.getFilterChangeListener(); PropertyChangeEvent event = new PropertyChangeEvent( this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, agWorkingSet); l.propertyChange(event); assertEquals( WorkbenchNavigatorMessages.WorkingSetActionProvider_multipleWorkingSets, _commonNavigator.getWorkingSetLabel()); }
// 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()); }
// 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 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); }
/** * Informs this field editor's listener, if it has one, about a change to one of this field * editor's properties. * * @param property the field editor property name, such as <code>VALUE</code> or <code>IS_VALID * </code> * @param oldValue the old value object, or <code>null</code> * @param newValue the new value, or <code>null</code> */ protected void fireValueChanged(String property, Object oldValue, Object newValue) { if (propertyChangeListener == null) { return; } propertyChangeListener.propertyChange( new PropertyChangeEvent(this, property, oldValue, newValue)); }
/** update views (in particular, display resource configurations) */ public static void updateViews(IResource res) { if (res == null) return; IWorkbenchPartReference refs[] = CUIPlugin.getActiveWorkbenchWindow().getActivePage().getViewReferences(); for (IWorkbenchPartReference ref : refs) { IWorkbenchPart part = ref.getPart(false); if (part != null && part instanceof IPropertyChangeListener) ((IPropertyChangeListener) part) .propertyChange( new PropertyChangeEvent( res, PreferenceConstants.PREF_SHOW_CU_CHILDREN, null, null)); } }
// bug 262096 [CommonNavigator] Changing *any* filter breaks working sets // filter public void testWorkingSetFilter() throws Exception { _contentService.bindExtensions(new String[] {COMMON_NAVIGATOR_RESOURCE_EXT}, false); _contentService .getActivationService() .activateExtensions(new String[] {COMMON_NAVIGATOR_RESOURCE_EXT}, true); 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); ViewerFilter vf[]; vf = _viewer.getFilters(); boolean found = false; for (int i = 0; i < vf.length; i++) { if (vf[i] instanceof ResourceWorkingSetFilter) found = true; } assertTrue(found); _contentService .getFilterService() .activateFilterIdsAndUpdateViewer(new String[] {TEST_FILTER_P1, TEST_FILTER_P2}); vf = _viewer.getFilters(); found = false; for (int i = 0; i < vf.length; i++) { if (vf[i] instanceof ResourceWorkingSetFilter) found = true; } assertTrue("Working set filter is gone, oh my!", found); }
public void setMode(int mode) { fMode = mode; fActiveActionGroup.cleanViewMenu(fMenuManager); PropertyChangeEvent event; if (mode == SHOW_PROJECTS) { fActiveActionGroup = fFilterActionGroup; event = new PropertyChangeEvent(this, MODE_CHANGED, INT_SHOW_WORKING_SETS, INT_SHOW_PROJECTS); } else { fActiveActionGroup = fShowActionGroup; event = new PropertyChangeEvent(this, MODE_CHANGED, INT_SHOW_PROJECTS, INT_SHOW_WORKING_SETS); } fActiveActionGroup.fillViewMenu(fMenuManager); fMenuManager.updateAll(true); if (fChangeListener != null) fChangeListener.propertyChange(event); }
// Bug 157877 when using empty window working set, it should show all public void testEmptyWindowWorkingSet() throws Exception { WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper.getActionProvider( _contentService, _actionService, WorkingSetActionProvider.class); IWorkingSet workingSet = PlatformUI.getWorkbench() .getActiveWorkbenchWindow() .getActivePage() .getAggregateWorkingSet(); // Set the filter to window working set (which should be empty) IPropertyChangeListener l = provider.getFilterChangeListener(); PropertyChangeEvent event = new PropertyChangeEvent( this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, workingSet); l.propertyChange(event); TreeItem[] items = _viewer.getTree().getItems(); assertTrue("There should be some items.", items.length > 0); assertEquals(null, _commonNavigator.getWorkingSetLabel()); }
// bug 220090 test that working sets are shown when selected locally (not // using the window working set) public void testTopLevelWorkingSet() throws Exception { WorkingSetActionProvider provider = (WorkingSetActionProvider) TestAccessHelper.getActionProvider( _contentService, _actionService, WorkingSetActionProvider.class); IExtensionStateModel extensionStateModel = _contentService.findStateModel(WorkingSetsContentProvider.EXTENSION_ID); extensionStateModel.setBooleanProperty( WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, true); IWorkingSet workingSet = new WorkingSet("ws1", "ws1", new IAdaptable[] {_p1}); IPropertyChangeListener l = provider.getFilterChangeListener(); PropertyChangeEvent event = new PropertyChangeEvent( this, WorkingSetFilterActionGroup.CHANGE_WORKING_SET, null, workingSet); l.propertyChange(event); // DisplayHelper.sleep(Display.getCurrent(), 10000000); _viewer.expandAll(); 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 working set", items[0].getData().equals(workingSet)); assertEquals("ws1", _commonNavigator.getWorkingSetLabel()); // bug 268250 [CommonNavigator] Project labels missing in Project // Explorer when working sets are top level elements TreeItem projectItem = items[0].getItem(0); assertEquals("p1", projectItem.getText()); }
/** * Broadcast a Team property change. * * @param event The event to broadcast */ public static synchronized void broadcastPropertyChange(PropertyChangeEvent event) { for (IPropertyChangeListener listener : propertyChangeListeners) listener.propertyChange(event); }