Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366974 - ICElement items for files and folders in project explorer should have project nature property for creating context menus
Summary: ICElement items for files and folders in project explorer should have project...
Status: RESOLVED INVALID
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 8.1.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Doug Schaefer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-16 15:03 EST by John Eblen CLA
Modified: 2012-02-23 11:30 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Eblen CLA 2011-12-16 15:03:40 EST
For CDT projects, folders in the project explorer are CContainer (ICContainer) objects rather than Folder (IFolder) objects. CContainer objects do not have the
org.eclipse.core.resources.projectNature property. Thus, it is not possible to populate the context menu (right click on the folder) with items that should only appear for certain project types.

For Navigator and other file viewers, this can be done with the org.eclipse.ui.menus extension point using, for example:
(menuContribution) -> (menu) -> (visibleWhen) -> (test)

Specifically, this functionality is needed by PTP synchronized projects to activate the "Synchronization" context menu for folders in a synchronized project.
Comment 1 Sergey Prigogin CLA 2011-12-16 15:24:00 EST
CContainer doesn't have to have the projectNature property itself, it just has to be adaptable to IFolder.
Comment 2 John Eblen CLA 2012-02-07 12:41:29 EST
This bug applies to all ICElement objects representing files and folders. I changed the title accordingly.

Such objects are adaptable to IResource, so it is simple to find the project nature. Specifically, use the "adapt" option for the org.eclipse.ui.menus extension point and adapt it to org.eclipse.core.resources.IResource prior to testing the project nature. You can also use the IAdaptable interface to adapt an element in code.

Since there is a reasonable and simple solution to this problem, I'll mark this bug as "Resolved" and "Invalid".