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

Bug 300182

Summary: Expose convert to faceted form action from configure menu
Product: [WebTools] WTP Common Tools Reporter: Paul Webster <pwebster>
Component: Faceted Project FrameworkAssignee: Konstantin Komissarchik <konstantin>
Status: RESOLVED FIXED QA Contact: Konstantin Komissarchik <konstantin>
Severity: enhancement    
Priority: P3 CC: darryl, remy.suen
Version: unspecifiedKeywords: plan
Target Milestone: 3.2 M5   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
ConvertToFacetHandler konstantin: iplog+

Description Paul Webster CLA 2010-01-20 08:19:34 EST
Created attachment 156638 [details]
ConvertToFacetHandler

Bug 295544 introduces functionality that should be available from the Configure submenu in the context menu.

A first-pass implementation could look like:

   <extension
         point="org.eclipse.ui.commands">
      <command
            categoryId="org.eclipse.ui.category.file"
            defaultHandler="org.eclipse.example.ConvertToFacetHandler"
            id="org.eclipse.example.convertToFacets"
            name="Convert Project to Faceted Form">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
         <menuContribution
           locationURI="popup:org.eclipse.ui.projectConfigure?after=additions">
         <command commandId="org.eclipse.example.convertToFacets" style="push">
            <visibleWhen checkEnabled="false">
               <and>
                  <count value="1"/>
                  <iterate  ifEmpty="false"  operator="and">
                     <adapt type="org.eclipse.core.resources.IProject"/>
                  </iterate>
               </and>
            </visibleWhen>
         </command>
      </menuContribution>
   </extension>


The visibleWhen could be extended with a test if you need a specific project nature before you can turn it into a project that understands facets:
<adapt type="org.eclipse.core.resources.IResource">
  <test property="org.eclipse.core.resources.projectNature" 
     value="the.nature.you.expect"/>
</adapt>

http://wiki.eclipse.org/Command_Core_Expressions describes some more project properties that can be tested.

PW
Comment 1 Darryl Miles CLA 2010-01-20 09:19:44 EST
To help whomever implements this.  The test to make it _INVISIBLE_ is to check the .project configure file has _BOTH_ of the following set:

<buildSpec>
  <buildCommand>
    <name>org.eclipse.wst.common.project.facet.core.builder</name>
    <arguments><!-- no need to test the existance or contents of this element is empty -->
    </arguments>
  </buildCommand>
</buildSpec>

 AND

<natures>
  <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>


Otherwise if the .project file only has one or neither of the above two items then the action should be visible to the user for the project.

The action is a per-project action.

The action once executed successfully will instate the above two configuration settings into ".project".



The action _MUST_ never fail in its primary goal, that is to ensure "Faceted Enablement" of the project.

Some of the possible secondary goals maybe to attempt auto-detection to produce a list of "Facet Attributes" to form an initial list to be set on the project (a kind of guessed initial state).  However if there is a problem or error doing this secondary goal then that must be aborted to allow to primary goal to succeed.  This secondary goal failure can be manually corrected afterwards by the user (but only once the primary goal has been completed).



I'm not sure any "conversion" takes place, this action is more "Enablement" (if there is such a word).  Conversion implies something is being taken away / lost (in the process) and that then implies it is an irreversible action.  When it should be possible to Disable facets on a project by removing the above two .project configuration sections.  The primary goal is actually reversible.
Comment 2 Paul Webster CLA 2010-01-20 09:28:37 EST
(In reply to comment #1)
> 
> The action _MUST_ never fail in its primary goal, that is to ensure "Faceted
> Enablement" of the project.

Agreed.  To avoid code duplication, this command does nothing except open the properties dialog on the new enable page provided by bug 295544

PW
Comment 3 Konstantin Komissarchik CLA 2010-01-20 13:59:13 EST
Paul,

I have to admire your persistence. The patch is not what I had hoped for, but hey it's something. Since good behavior must be rewarded, I have implemented this enhancement request and released changes for Helios M5 build.

Thanks for playing. ;)
Comment 4 Paul Webster CLA 2010-01-20 14:30:29 EST
(In reply to comment #3)
> Paul,
> 
> I have to admire your persistence. The patch is not what I had hoped for, but

In my case persistence is not necessarily a virtue.  Sorry about the lack of true patch, and thank you for considering it.

PW