Bug 296728 [CommonNavigator] Problem with enablement on navigatorContent extension point
If I use the enablement node with the expression "WITH", no variable was found because no real context is given. example : <extension point="org.eclipse.ui.navigator.navigatorContent"> <commonWizard type="new" wizardId="com.mywizard"> <enablement> <with variable="activeWorkbenchWindow.activePerspective"> <equals value="com.myperpective"> </equals> </with> </enablement> </commonWizard> make this error : org.eclipse.core.runtime.CoreException: The variable activeWorkbenchWindow.activePerspective is not defined at org.eclipse.core.internal.expressions.WithExpression.evaluate(WithExpression.java:65) at org.eclipse.core.internal.expressions.CompositeExpression.evaluateAnd(CompositeExpression.java:53) at org.eclipse.core.internal.expressions.EnablementExpression.evaluate(EnablementExpression.java:53) at org.eclipse.ui.internal.navigator.wizards.CommonWizardDescriptor.isEnabledFor(CommonWizardDescriptor.java:145) at org.eclipse.ui.internal.navigator.wizards.CommonWizardDescriptorManager.getEnabledCommonWizardDescriptors(CommonWizardDescriptorManager.java:158) at org.eclipse.ui.navigator.WizardActionGroup.setContext(WizardActionGroup.java:193) at org.eclipse.ui.internal.navigator.resources.actions.NewActionProvider.fillContextMenu(NewActionProvider.java:107) You could do use the currentState of the IEvaluationService. (see WorkbenchWindow line 3035)
tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/ProgrammaticOpenTest.java
_contentService.getVisibleExtensionIds().length);
		_contentService.getActivationService().activateExtensions(
				new String[] { COMMON_NAVIGATOR_RESOURCE_EXT }, true);
		_contentService.getActivationService().activateExtensions(new String[] {}, true);
		refreshViewer();
		_viewer.expandAll();
		TreeItem[] items = _viewer.getTree().getItems();
		assertTrue("There should be NO items.", items.length == 0); 
		_contentService.getActivationService().deactivateExtensions(new String[] {}, true);
		_viewer.expandToLevel(2);
		items = _viewer.getTree().getItems();
		assertTrue("There should be some items.", items.length > 0); 
	}
	public void testNavigatorSorterAccess() throws Exception {
		INavigatorSorterService sorterService = _contentService.getSorterService();
		INavigatorContentDescriptor testDescriptor = _contentService
				.getContentDescriptorById(TEST_CONTENT);
		Map sorters = sorterService.findAvailableSorters(testDescriptor);
		assertEquals(1, sorters.size());
		for (Iterator iter = sorters.entrySet().iterator(); iter.hasNext();) {
			Map.Entry entry = (Map.Entry) iter.next();
			assertTrue(entry.getValue() instanceof TestSorterData);
		}
	}
	
	public void testChangeNceActivation() throws Exception {
		_contentService.bindExtensions(new String[] { TEST_CONTENT_OVERRIDDEN1,
				TEST_CONTENT_OVERRIDE1, TEST_CONTENT_OVERRIDDEN2, TEST_CONTENT_OVERRIDE2 }, false);
		_contentService.getActivationService().activateExtensions(
				new String[] { TEST_CONTENT_OVERRIDDEN2, TEST_CONTENT_OVERRIDE2 }, true);