locked
How to make a virtual/roll-up node in a custom project using MPF? RRS feed

  • Question

  • I am making a custom project type for VS2010 and I'm using MPF10.  Part of the necessary physical directory structure looks like this:

     

    \src
     \com
      \company1
       \namespace1
        \file1.txt
        \file2.txt
      \company2
       \namespace2
        \file3.txt
        \file4.txt
    

     

    In the solution explorer, I want this to show up like this:

    \src
     \com.company1.namespace1
      \file1.txt
      \file2.txt
     \com.company2.namespace2
      \file3.txt
      \file4.txt
    


    I'm currently doing that by setting a custom property on the FolderNode for src specifying that it should return packages.  Then I overrode GetProperty to return the package virtual node when asked for FirstChild or FirstVisibleChild when appropriate.  The package virtual nodes route most commands to the leaf folder node for whatever they represent so that the child items of the package show up correctly.  I have had to subclass FolderNode andFileNode.  I have had to override several functions.

    And that, basically, works.  But I'm running into a lot of glitches and I'm wondering if I'm missing the easy approach.  So far it has been my experience that when I'm fighting the system, it is because I'm overlooking the easy way to do it.

    Specific glitches that I've seen:
    - There are several areas where uiHierarchy.ExpandItem is called to select the recently changed item.  That fails often.
    - Renaming a package correctly renames and moves the physical directories/files and changes the virtual node, but when I'm not changing the underlying nodes so the project doesn't get saved right.

    So far I have been fighting this for a couple weeks and I figure now it is time to ask for help.  Any suggestions would be appreciated.  I am happy to provide any and all of my source if that helps you help me. :-)

    Jere

     

    Thursday, November 11, 2010 2:11 PM

Answers

  • Thanks for the reply Ed.

    This actually wasn't that difficult to do once I started thinking about it correctly.  The key was that I want the "\src" node to act differently.  So I subclassed FolderNode as PackageContainerNode.  That gave me the flexibility and entry points to do what I needed.

    After copying WiX's "ShowAllFiles" implementation and having it work, I'm fairly certain my solution is robust.

    BTW, if anyone wants to see code, I'm happy to post it.

    Jere

    Thursday, November 18, 2010 2:21 PM

All replies

  • Hi Jere,

    Unfortunately, there isn't an easy approach to implementing something like this. The only project system I've seen that does this is the C++ project system, which implements the ECMD_SHOWALLFILES command to regroup the items under virtual folders like (Header Files, Resource Files, etc).

    This sort of operation should not change the underlying project file in any way though. You don't want to be forcing a checkout on your project file everytime you switch between view modes.

    Sincerely,


    Ed Dore
    Wednesday, November 17, 2010 9:51 PM
  • Thanks for the reply Ed.

    This actually wasn't that difficult to do once I started thinking about it correctly.  The key was that I want the "\src" node to act differently.  So I subclassed FolderNode as PackageContainerNode.  That gave me the flexibility and entry points to do what I needed.

    After copying WiX's "ShowAllFiles" implementation and having it work, I'm fairly certain my solution is robust.

    BTW, if anyone wants to see code, I'm happy to post it.

    Jere

    Thursday, November 18, 2010 2:21 PM
  • Thanks for the follow up post Jere. I wasn't aware the WIX project implementation actually supported this. Good to know.

    Sincerely,


    Ed Dore
    Monday, November 22, 2010 10:26 PM