zoukankan      html  css  js  c++  java
  • (转)Getting rid of the DSL model explorer

    http://www.ticklishtechs.net/2008/07/27/getting-rid-of-the-dsl-model-explorer/

     

    Every DSL you create with DSL Tools has a model explorer. This model explorer is a tool window in Visual Studio displaying the elements of your model in a hierarchical way. This is often a nice feature but sometimes a hierarchical view of your data is not appropriate. So I came to the question: How to remove the explorer from the generated code?

    I could not find any option in the DSL design to remove the model explorer, but if you look at some of the .tt files you will find somewhere a query for this.Dsl.Explorer != null. For example in the package.tt file that generates the package.cs which is responsible for registering the tool window for the model explorer:

    <#

    if(this.Dsl.Explorer != null)

    {

    #>

    [VSShell::ProvideToolWindow( typeof(<#= dslName #>ExplorerToolWindow), MultiInstances = false, Style = VSShell::VsDockStyle.Tabbed, Orientation = VSShell::ToolWindowOrientation.Right, Window = "{3AE79031-E1BC-11D0-8F78-00A0C9110057}")]

    [VSShell::ProvideToolWindowVisibility( typeof(<#= dslName #>ExplorerToolWindow), Constants.<#= dslName #>EditorFactoryId)]

    <#

    }

    #>

    Even if I did not find any option to set the Dsl.Explorer property of the model to null (you did not see the Explorer property anywhere in the DSL diagram) it seems that the developers of the DSL Tools had this use case in mind.

    To remove the Dsl.Explorer from your DSL model open the .dsl file with a text editor and go to the end. There you will find some XML tags like the following:

    <Explorer ExplorerGuid="6c276297-6acd-4e9a-8740-b61ba834004b" Title="HardwareDescription Explorer">

    <ExplorerBehaviorMoniker Name="HardwareDescription/HardwareDescriptionExplorer" />

    </Explorer>

    Just delete these three lines and generate your code once again. Maybe you should reset your Experimental Hive, too.

    I tested a DSL with a removed Model Explorer without any problems. It seems the developers of the DSL Tools did a very good job on the code generation templates . The generated ModelExplorer.cs file contains only a single line:

    // This source file is empty because this DSL does not define a model explorer.

    That should be a good proof that a DSL can run without the model explorer even if it might be not supported by the DSL Tools.

  • 相关阅读:
    codeforces 455B A Lot of Games(博弈,字典树)
    HDU 4825 Xor Sum(二进制的字典树,数组模拟)
    hdu 1800 Flying to the Mars(简单模拟,string,字符串)
    codeforces 425A Sereja and Swaps(模拟,vector,枚举区间)
    codeforces 425B Sereja and Table(状态压缩,也可以数组模拟)
    HDU 4148 Length of S(n)(字符串)
    codeforces 439D Devu and Partitioning of the Array(有深度的模拟)
    浅谈sass
    京东楼层案例思维逻辑分析
    浅谈localStorage和sessionStorage
  • 原文地址:https://www.cnblogs.com/default/p/2261913.html
Copyright © 2011-2022 走看看