In 3.2, You would use org.eclipse.ui.popupMenus to add to the context
menu. Either an objectContribution if you want it to appear anywhere
you can "get" have an object in your desired state, or a
viewerContribution if you want to target a specific part (like the
package explorer).
You can then use objectClass to narrow down your objectContribution, or
the visibility element for your viewerContribution to narrow it down.
If you really need to implement something like "for the selection
resource, find the project, for the project, find this file and check
the data" you are probably looking at an IActionFilter ... but be
careful, you don't want to make calls to your IActionFilter to be too
expensive.
In 3.3, you can do similar with org.eclipse.ui.menus to place commands
in the context menu you want, and the visibleWhen clause to make the
visible or not.