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
result.add(project);
		}
		return result;
	}
	
	/**
	 * {@inheritDoc}
	 */
	public void resourceChanged(IResourceChangeEvent event) {
		IResourceDelta delta = event.getDelta();
		if (delta != null) {
			IResourceDelta[] projDeltas = delta.getAffectedChildren(IResourceDelta.CHANGED);
			for (int i = 0; i < projDeltas.length; ++i) {
				IResourceDelta projDelta = projDeltas[i];
				if ((projDelta.getFlags() & IResourceDelta.OPEN) != 0) {
					Shell shell= getShell();
					if (!shell.isDisposed()) {
						shell.getDisplay().asyncExec(new Runnable() {
							public void run() {
								update(getSelection());
							}
						});
					}
					return;
				}
			}
		}
	}
}