.NET Forum / Visual Studio.NET / Extensibility / February 2006
Launching a fileless editor without using VsHierarchy?
|
|
Thread rating:  |
Reggie Burnett - 07 Feb 2006 16:44 GMT I have developed a package that includes a toolwindow that shows various objects. I want to be able to create/edit these objects. They are not files and I do not wish to register any type of file extension for them. I have already implemented a treeview and would like to avoid having to implement VsHierarchy or VsUIHierarchy if possible as I am implementing this using the managed extensions.
I would like my editor to live inside a real document window so I can get proper save behavior when the user attempts to close the window. Is OpenSpecificEditor the best way to do this? If so, how can I avoid needing a VsUIHierarchy? Is there another way to launch an editor in a document window? It seems that there should be since the VS core editor allows editing files that are not part of the currently loaded solution.
Thanks for your time. Reggie
"Gary Chang[MSFT]" - 08 Feb 2006 07:32 GMT Hi Reggie,
Currently, we are looking into this problem. We will reply here with more information as soon as possible. If you have any more concerns on it, please feel free to post here.
Thanks for your understanding!
Best regards,
Gary Chang Microsoft Community Support ====================================================== PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00 AM PST, February 14, 2006. Please complete a re-registration process by entering the secure code mmpng2006 when prompted. Once you have entered the secure code mmpng2006, you will be able to update your profile and access the partner newsgroups. ====================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from this issue. ====================================================== This posting is provided "AS IS" with no warranties, and confers no rights. ======================================================
"Gary Chang[MSFT]" - 10 Feb 2006 02:10 GMT Hi Reggie,
I have consulted this issue with our development team members, it appears there hasn't any other approach to launch an editor in the document window without implementing a VsUIHierarchy.
Thanks for your understanding!
Best regards,
Gary Chang Microsoft Community Support ====================================================== PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00 AM PST, February 14, 2006. Please complete a re-registration process by entering the secure code mmpng2006 when prompted. Once you have entered the secure code mmpng2006, you will be able to update your profile and access the partner newsgroups. ====================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from this issue. ====================================================== This posting is provided "AS IS" with no warranties, and confers no rights. ======================================================
"Ed Dore [MSFT]" - 14 Feb 2006 01:43 GMT Hi Reggie,
You could potentially use the IVsUIShellOpenDocument::OpenDocumentViaProjectWithSpecific to do this. Another option would be to reimplement your toolwindow as a UIHierarchyWindow (similar to solution and server explorer toolwindows) and launch your editor using your custom hierarchy integrated into a VsUIHierarchyWindow based toolwindow.
When using IVsUIShellOpenDocument::OpenDocumentViaProjectIWithSpecific though, your document will most likely be added to the hierarchy under the Miscellaneous Files project. But I suspect you can keep that project (or at least your "document") hidden by way of setting the VSHPROPID_IsHiddenItem to false.
Sincerely, Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.
Reggie Burnett - 17 Feb 2006 14:01 GMT Ed
I think I am doing what you mention as option 2. Before I was hosting a UserControl in my toolwinodw but now I am setting the Cls_Id of the toolwindow to some special Guid (don't have the code in front of me) and this apparently uses a treeview implementation that is "baked in". I then implemented IVsUIHierarchy in a class and used that for my root node. All the objects that are my child nodes all derive from a base class and expose such options as MenuId, IconIndex, OpenIconIndex, etc. The root node handles the IVsUIHierarchy methods like ExecCommand and GetProperty and passes them off the the appropriate child node. Does this sound appropriate?
Is this the "preferred" way to do what I am trying to do? Now that I have this, I'm assuming that OpenWithSpecific would be the best way to launch an editor?
> Hi Reggie, > [quoted text clipped - 14 lines] > Ed Dore [MSFT] > This post is 'AS IS' with no warranties, and confers no rights. "Ed Dore [MSFT]" - 17 Feb 2006 17:36 GMT Hi Reggie,
This is pretty much the same way we've implemented the Server Explorer toolwindow. One thing you may also want to do is add IVsProject to your hierarchy implementation, and call IVsSolution::AddVirtualProject. I had custom editor (VsCodeWindow based) that I was invoking from a similar toolwindow, and couldn't set breakpoints in the editor. Come to find out the shell was looking to validate the document as being owned by a project, and couldn't find a project associated with the document, so the command was disabled.
But to answer your question, your approach is probably the one I'd use as well. The only problem is that you have to implement the hierarchy from scratch (as you've alread discovered). The MPF hierarchy stuff pretty specific to the solution explorer and implementing a project system for a language. Consequently, it's not really usable in a generic VsUIHierarchWindow based toolwindow.
Sincerely, Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.
Reggie Burnett - 17 Feb 2006 22:58 GMT Ed
Would you be able to give me some advice on how to launch OpenSpecificEditor? Here's the code that I've written so far:
protected void OpenEditor(Guid editorGuid) { IVsUIShellOpenDocument openDoc = (IVsUIShellOpenDocument) PackageSingleton.Package.GetMyService(typeof(SVsUIShellOpenDocument));
IVsWindowFrame winFrame; Guid logicalView = VSConstants.LOGVIEWID_Primary; int result = openDoc.OpenSpecificEditor((uint)__VSOSPEFLAGS.OSPE_OpenAsNewFile, null, ref editorGuid, null, ref logicalView, Caption, GetHierNode(), this.ItemId, IntPtr.Zero, PackageSingleton.Package, out winFrame); }
GetHierNode() returns the root node of my Hierarchy which implements IVsUIHierarchy. this.ItemId is the item id in that hierarchy. PackageSingleton is a singleton class and Package is a property that returns my Package derived class. This call returns failure. one of the error codes returned indicates "file not found" which I do not understand.
The document I am trying to edit is not really a file. It's a virtual document like creating a new database table, etc.
Do I need to OR in RDT flags into my editor flags to indicate that it's a virtual document or something like that? Also, I am not sure what I need to pass in for the filename parameter.
Thanks!
> Hi Reggie, > [quoted text clipped - 17 lines] > Ed Dore [MSFT] > This post is 'AS IS' with no warranties, and confers no rights. Reggie Burnett - 21 Feb 2006 16:03 GMT Ed
I've got my editor working. Not using OpenSpecificEditor. I've got my editor launching ok but seem to be having some problem with the dirty flag on the document. Here is how I am launching my editor (based on a UserControl).
IVsUIShellOpenDocument openDoc = (IVsUIShellOpenDocument)PackageSingleton.Package.GetMyService(typeof (SVsUIShellOpenDocument));
IVsUIShell uiShell = (IVsUIShell) PackageSingleton.Package.GetMyService(typeof(SVsUIShell));
IVsWindowFrame winFrame; Guid editor = Guid.Empty; Guid cmdGui = Guid.Empty; IntPtr viewAndDataPunk =Marshal.GetIUnknownForObject(editorObj);
int result = openDoc.InitializeEditorInstance(0,viewAndDataPunk, viewAndDataPunk, editorObj.Filename, ref editor, null, ref editor, "owner caption", "editor caption", GetHierNode(), ItemId, IntPtr.Zero, PackageSingleton.Package, ref cmdGui, out winFrame); ErrorHandler.ThrowOnFailure(result);
if (winFrame != null) winFrame.Show();
This brings up the editor (not using an editor factory here). When the text of my editor changes, I am calling something like this: vsUIShell.UpdateDocDataIsDirtyFeedback(cookie, value ? 1
: 0); This adds the * to the end of my doc title and the title bar but the * immediately disappears and when I close the editor, it doesn't prompt me to save. Can you direct me as to what I might be doing wrong?
Thanks!
> Ed > [quoted text clipped - 54 lines] >> Ed Dore [MSFT] >> This post is 'AS IS' with no warranties, and confers no rights "Gary Chang[MSFT]" - 23 Feb 2006 02:23 GMT Hi Reggie,
Currently, we are still perform some research on this problem. We will update you as soon as we get anything out.
Thanks for your understanding!
Best regards,
Gary Chang Microsoft Community Support ====================================================== PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00 AM PST, February 14, 2006. Please complete a re-registration process by entering the secure code mmpng06 when prompted. Once you have entered the secure code mmpng06, you will be able to update your profile and access the partner newsgroups. ====================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from this issue. ====================================================== This posting is provided "AS IS" with no warranties, and confers no rights. ======================================================
Sam - 24 Feb 2006 05:31 GMT Hi Reggie,
What was the format that you used for the parameter "editorObj.Filename" in your code patches to invoke the function of "openDoc.InitializeEditorInstance"? Actually in my project I also intended to implement a kind of virtual document that needs to be managed via RDT, so I also encountered the same problem when I was calling the API function vsUIShell.UpdateDocDataIsDirtyFeedback(dwCookie, fDirty). In my case I coded the file name in the format of "File:///D|SomeCompoundFileName.abc?EntryName.def", however the particular API function SVsRunningDocumentTable::RegisterAndLockDocument(RDT_NoLock | RDT_VirtualDocument, bstrFileName, GetIVsUIHierarchy(), GetVsItemID(), NULL, &dwCookie) reported me that the assigned argument was invalid, as a result I could not get the corresponding dwCookie for use.
I hope that we could get some help from MS to workaround it.
Thanks & Regards, Sam
> Ed > [quoted text clipped - 93 lines] > >> Ed Dore [MSFT] > >> This post is 'AS IS' with no warranties, and confers no rights. "Gary Chang[MSFT]" - 24 Feb 2006 09:02 GMT Hi Reggie,
One thing we need to confirm--Is your package in VS2003 or VS2005?
There was a bug just like this where dirtying the editor¡¯s dirty bit is being set back to the unmodified state in VS2003. This bug should be fixed in VS2005.
Thanks!
Best regards,
Gary Chang Microsoft Community Support ====================================================== PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00 AM PST, February 14, 2006. Please complete a re-registration process by entering the secure code mmpng06 when prompted. Once you have entered the secure code mmpng06, you will be able to update your profile and access the partner newsgroups. ====================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from this issue. ====================================================== This posting is provided "AS IS" with no warranties, and confers no rights. ======================================================
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|