There are many actions allowed / disabled depending on the type of item selected.
See, for example, the Copy action for an item that is not intended to be copied:

This means that you can check how org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart manages its context menu and its associated actions.
Start with the menuAboutToShow() method using PackageExplorerActionGroup , including CCPActionGroup , which manage to copy, cut and paste actions.
This last class does not control the registration of actions, including CopyToClipboardAction :
It implements the selectionChanged method.
public void selectionChanged(IStructuredSelection selection) { try { List JavaDoc elements= selection.toList(); IResource[] resources= ReorgUtils.getResources(elements); IJavaElement[] javaElements= ReorgUtils.getJavaElements(elements); if (elements.size() != resources.length + javaElements.length) setEnabled(false); else setEnabled(canEnable(resources, javaElements)); } catch (JavaModelException e) { //no ui here - this happens on selection changes // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253 if (JavaModelUtil.isExceptionToBeLogged(e)) JavaPlugin.log(e); setEnabled(false); } }
source share