This project is read-only.

i can't get the DSL Editor PowerToy tool window

Sep 22, 2009 at 9:32 AM

     

       get
            {
                DeptControls.\<#= dslName \#>DslEditorToolWindow toolWindow = null;
                DslShell.ModelingPackage package = this.ServiceProvider.GetService(typeof(VSShell.Package)) as DslShell.ModelingPackage;

                if (package != null)
                    toolWindow = package.GetToolWindow(typeof(DeptControls.\<#= dslName \#>DslEditorToolWindow), true) as DeptControls.\<#= dslName \#>DslEditorToolWindow;

//here the toolWindow is null

                  return toolWindow;

i know there had create on window in vs because in my DSLPackage Project i can see the window with no windowtitle and tab name.

temporary

i edit the template in DslPackage\DetailsEditor\GeneratedCode\CommandSet.tt  like below

 get
            {
                DeptControls.<#= dslName #>DslEditorToolWindow toolWindow = null;
                DslShell.ModelingPackage package = this.ServiceProvider.GetService(typeof(VSShell.Package)) as DslShell.ModelingPackage;

                if (package != null)
				{
                    toolWindow = package.GetToolWindow(typeof(DeptControls.<#= dslName #>DslEditorToolWindow), true) as DeptControls.<#= dslName #>DslEditorToolWindow;
					if (toolWindow == null)
                    {
                        Guid guid = new Guid(typeof(DeptControls.<#= dslName #>DslEditorToolWindow).GUID.ToString());
                        try
                        {
                            package.CreateToolWindow(ref guid, 200);
                            toolWindow = package.GetToolWindow(typeof(DeptControls.<#= dslName #>DslEditorToolWindow), true) as DeptControls.<#= dslName #>DslEditorToolWindow;
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine(e.Message);
                        }
                    }
				}
                return toolWindow;

 

so i can get the detail window for my dsl design.

 

who can tell me the process in this project how to create the window. and why i can't get toolWindow.

Sep 29, 2009 at 10:54 AM
Edited Sep 29, 2009 at 10:54 AM
using VSShell = global::Microsoft.VisualStudio.Shell;
using System;
namespace <#= CodeGenerationUtilities.GetPackageNamespace(this.Dsl) #>
{
    /// <summary>
    /// Extension to language Package class to register toolwindow
    /// </summary>
    [VSShell.ProvideToolWindow(typeof(global::<#= CodeGenerationUtilities.GetPackageNamespace(this.Dsl) #>.DslEditorPowerToy.Controls.<#= dslName #>DslEditorToolWindow), MultiInstances = false, Style = VSShell.VsDockStyle.Tabbed, Orientation = VSShell.ToolWindowOrientation.Right, Window = "{4a9b7e51-aa16-11d0-a8c5-00a0c921a4d2}") /* beneath the diagram */]
    [VSShell.ProvideToolWindowVisibility(typeof(global::<#= CodeGenerationUtilities.GetPackageNamespace(this.Dsl) #>.DslEditorPowerToy.Controls.<#= dslName #>DslEditorToolWindow), Constants.<#= dslName #>EditorFactoryId)]
    partial class <#= dslName #>Package
    {
        protected override void Initialize()
        {
            base.Initialize();

            //Add toolwindows
            this.AddToolWindow(typeof(global::<#= CodeGenerationUtilities.GetPackageNamespace(this.Dsl) #>.DslEditorPowerToy.Controls.<#= dslName #>DslEditorToolWindow));

//here i add code like this   : 

 Debug.Write(this.GetToolWindow(typeof(global::DCMS.EasyBridge.DslPackage.DslEditorPowerToy.Controls.EasyBridgeDslEditorToolWindow))==null);
the result is true;
why? who tell me thanks.