none
How to programmatically force a file node's name to become editable in Solution Explorer?

    Question

  • I'm trying to implement a rename operation in a VS package whose behavior is the same as "standard" projects like C#.  For example, if I have a C# file in the solution explorer and I click on the file node's name, the name becomes editable. And when I finish editing the name, the file is automatically renamed. Similarly, when I bring up the file node's context menu and select Rename, the name becomes editable.

     

    I'd like to duplicate this behavior in my new file node type.  The renaming behavior when I click on the file node's name seems to come for free without any programming on my end -- the name becomes editable, and when I'm done the file is renamed.  That's fine.  Now, I want to implement the same behavior when accessed through the context menu: when Rename is selected, I want my file node's name to become editable in the same way that a C# file node's name becomes editable.  However, I can't find any API in the VS 2005 SDK that will allow this to happen.  Can anybody point me in the right direction?  Thanks!

    Sunday, March 09, 2008 12:52 AM

Answers

  • Are you trying to create your own project type using MPF?

    Based on my research, this function has been implemented by the MPF classes(
    ProjectNode Class, FileNode). And you can check out the IronPython integrithon sample in the VSSDK.  By the way, source code of these classes are available in %VSSDK%\VisualStudioIntegration\Common\Source\CSharp\Project\.
    Monday, March 10, 2008 12:10 PM
  • Ok, I solved the problem.  The problem was that I was trying to implement the entire context menu myself.  Looking at the Iron Python example code, I realized that I only need to implement a subset of the commands in the context menu (the ones whose functionality is specific to my package) and allow the plugin framework to handle all the other menu items.

     

    Tuesday, March 11, 2008 12:20 AM

All replies

  • Are you trying to create your own project type using MPF?

    Based on my research, this function has been implemented by the MPF classes(
    ProjectNode Class, FileNode). And you can check out the IronPython integrithon sample in the VSSDK.  By the way, source code of these classes are available in %VSSDK%\VisualStudioIntegration\Common\Source\CSharp\Project\.
    Monday, March 10, 2008 12:10 PM
  • Thanks for the note.  All the rename methods seem to require the new file name, which seems to imply that the name field edit operation has already occurred.

     

    Looking at the C# FileNode.cs source, ExecCommandOnNode() -- which presumably would be called on a context menu operation -- does not implement the rename operation.  Going up the chain to HierarchyNode.ExecCommandOnNode(), I find that the rename operation is not specifically handled, and OLECMDERR_C_NOTSUPPORTED is returned. So the question remains -- where is the rename operation handled from a context menu operation?  Looking in the IronPython example, I see the same thing.  I am using the 2006.09 version of the VS 2005 VSSDK, for compatibility reasons.  Are things different in the newer SDKs?

     

    Monday, March 10, 2008 4:33 PM
  • Ok, I solved the problem.  The problem was that I was trying to implement the entire context menu myself.  Looking at the Iron Python example code, I realized that I only need to implement a subset of the commands in the context menu (the ones whose functionality is specific to my package) and allow the plugin framework to handle all the other menu items.

     

    Tuesday, March 11, 2008 12:20 AM