Bug 84004 OpenCloseWorkingSetAction actions visible when no selection
Version: 3.1.0 Build id: I20050125-0800 When there is no selection in the package explorer (when you have collapsed a tree item for example) the context menu contains actions for "open project", "open projects" and "close projects". The only one that does anything is "open project", although it shouldn't be visible. OpenCloseWorkingSetAction#getProjects (both of them) are returning an empty array and the actions are enabled if the election is != null. Forcing the getProjects methods to return null when the list is empty fixed the problem for me. ie: if (selection.isEmpty()) return null; for the one that takes a structured selection and if (set.getElements().length == 0) return null; for the one taht takes a working set
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/workingsets/OpenCloseWorkingSetAction.java
protected abstract String getErrorTitle();
	protected abstract String getErrorMessage();
	
	private List getProjects(IStructuredSelection selection) {
		List result= new ArrayList();
		List elements= selection.toList();
		for (Iterator iter= elements.iterator(); iter.hasNext();) {
			Object element= iter.next();
			if (!(element instanceof IWorkingSet))
				return null;
			List projects= getProjects((IWorkingSet)element);
			if (projects == null)
				return null;
			result.addAll(projects);
		}
		return result;
	}
	private List getProjects(IWorkingSet set) {
		List result= new ArrayList();
		IAdaptable[] elements= set.getElements();
		for (int i= 0; i < elements.length; i++) {
			Object element= elements[i];
			IProject project= null;
			if (element instanceof IProject) {
				project= (IProject)element;
			} else if (element instanceof IJavaProject) {
				project= ((IJavaProject)element).getProject();
			}
			if (project == null || !validate(project))
				return null;