Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 143082

Summary: Property tester for facets should include testing resources inside of projects
Product: [WebTools] WTP Common Tools Reporter: Amy Wu <for.work.things>
Component: wst.commonAssignee: Konstantin Komissarchik <konstantin>
Status: CLOSED FIXED QA Contact: Konstantin Komissarchik <konstantin>
Severity: enhancement    
Priority: P3 CC: jeffliu
Version: 1.5   
Target Milestone: 1.5 RC4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
org.eclipse.wst.common.project.facet.core.patch
none
Patch none

Description Amy Wu CLA 2006-05-22 18:06:14 EDT
I noticed bug 126223 was opened for a property tester to test projects.  It would be nice if the property tested resources in general, not just specifically projects.  That way, clients could also check if folders or files inside of their projects are all inside of a specific project facet.

That appears to be how the eclipse.core.resources's resourcepropertytester works when testing projectNature.
<extension
   point="org.eclipse.core.expressions.propertyTesters">
   <propertyTester
      id="org.eclipse.core.resources.resourcePropertyTester"
      class="org.eclipse.core.internal.propertytester.ResourcePropertyTester"
      namespace="org.eclipse.core.resources"                    
==>      properties="name,path,extension,readOnly, projectNature, 
                persistentProperty, projectPersistentProperty, sessionProperty, 
                projectSessionProperty"
==>      type="org.eclipse.core.resources.IResource"/>
</extension>
Comment 1 Konstantin Komissarchik CLA 2006-05-22 18:12:51 EDT
Amy, 

Are you blocked on this? Do you need this in 1.5 or is this a nice-to-have for 2.0?
Comment 2 Amy Wu CLA 2006-05-22 18:23:14 EDT
Created attachment 42191 [details]
org.eclipse.wst.common.project.facet.core.patch

The fix is pretty small, but the outcome should be very beneficial to clients.  For example, I currently have the new JSP wizard action showing up in project explorer on web projects, all folders, all files.  It would much better if the new JSP wizard action only showed up on all folders and files *within* a web project.

Fix details:
plugin.xml
  <extension point="org.eclipse.core.expressions.propertyTesters">
    <propertyTester
      id="org.eclipse.wst.common.project.facet.core.internal.FacetedProjectPropertyTester"
==>      type="org.eclipse.core.resources.IResource"
      namespace="org.eclipse.wst.common.project.facet.core"
      properties="projectFacet"
      class="org.eclipse.wst.common.project.facet.core.internal.FacetedProjectPropertyTester">
    </propertyTester>
  </extension>

FacetedProjectPropertyTester#test
add the following:
    		if (!(receiver instanceof IResource))
    			return false;
            final IProject pj = ((IResource) receiver).getProject();
Comment 3 Amy Wu CLA 2006-05-22 18:27:52 EDT
It's not blocking, but it would greatly improve usability, so I'd prefer it be put in for 1.5.  Especially since the fix is pretty simple.  Plus, I think other clients would be interested in this as well.
Comment 4 Konstantin Komissarchik CLA 2006-05-22 19:15:44 EDT
Sounds good. I will get it in.
Comment 5 Konstantin Komissarchik CLA 2006-05-23 10:51:37 EDT
Created attachment 42265 [details]
Patch

Essentially Amy's patch. I just added an extra check to handle one IResource that returns null for getProject... IWorkspaceRoot.
Comment 6 David Williams CLA 2006-05-23 11:52:05 EDT
+1 (if you still need it :) 
Comment 7 Konstantin Komissarchik CLA 2006-05-24 12:26:34 EDT
Fix approved by Chuck Bridgham and released into the RC4 stream.
Comment 8 Amy Wu CLA 2006-06-15 15:30:43 EDT
verified in 1.5rc5
Comment 9 John Lanuti CLA 2006-09-26 10:10:15 EDT
Closing.