Customizing the Model Explorer
Applies to: Visual Studio Visual Studio for Mac
Note
This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
You can change the appearance and behavior of the explorer for your domain-specific language designer as follows:
Change the window title.
Change the tab icon.
Change the icons for nodes.
Hide nodes.
Changing the Window Title
To change the window title of the generated explorer, select Explorer Behavior in the DSL Explorer, and then in the Properties window, set the Title property to the title you want.
Changing the Tab Icon
To change the tab icon for the explorer, use a 16x16-pixel icon in a .bmp file. Put the icon file in the \DslPackage\Resources\ folder, and then change the file name to ModelExplorerToolWindowBitmaps.bmp. For example, you could change the Visual Studio setup.ico icon file to .bmp format and rename it to DSLLanguageName\DslPackage\Resources\ModelExplorerToolWindowBitmaps.bmp. The generated designer will display this icon on the tab of your explorer when it is docked together with Solution Explorer.
Setting Custom Icons on Explorer Nodes
You can customize nodes in your explorer by using explorer node settings. The following procedure shows how to add an icon to a node.
To add an icon to an explorer node
Create a Domain-Specific Language Tools solution by using the Task Flow solution template.
Put a .bmp file that contains a 16x16-pixel icon in the Dsl\Resources folder in the solution.
In the DSL Explorer, right-click Explorer Behavior and then click Add New Explorer Node Settings.
An ExplorerNodeSettings node appears under the Custom Node Settings node.
Select ExplorerNodeSettings, and then in the Properties window, set Class to Actor.
Set Icon To Display to the path of the icon file.
Transform all templates, and then build and run the solution.
In the generated designer, open the Sample diagram.
The Explorer should show three Actor nodes that have your icon.
Note
If you have set a node icon for any element that is displayed in the generated explorer, all explorer nodes will display the icon. If no icon has been set, the nodes will display the default icon.
Changing the Name Displayed on an Explorer Node
You can change how the names of model elements are displayed in your explorer. The following procedure shows how to display the name of the Task that is referenced by a Comment in the comment node.
To display a property
Open the solution that you created in the earlier procedure.
Make sure that the Comment references only a single domain class by setting the multiplicity of the role with property name Subjects to 0..1. The property name should become Subject, and the relationship name should become CommentReferencesSubject.
In the DSL Explorer, right-click Explorer Behavior and then click Add New Explorer Node Settings.
An ExplorerNodeSettings node appears under the Custom Node Settings node.
Select ExplorerNodeSettings, and then in the Properties window, set Class to Comment.
Right-click the Comment node, and then click Add New Property Path.
A new node appears that is named Property Displayed.
Select Property Displayed, and then in the Properties window, click the value field of Path To Property. Select Comment, then CommentReferencesSubject, then FlowElement. The resulting path should resemble CommentReferencesSubject.Subject/!Subject.
In the value field of Property, select Name.
Transform all templates, and then build and run your solution.
In the generated designer, open the Sample diagram.
Draw a Comment Connector between the comment element and the Task1 element on the diagram.
The Explorer node should display the comment as Task1.
Hiding Nodes
You can hide a node in your explorer by adding its path to the Hidden Nodes node of the DSL Explorer. The following procedure shows how to hide Comment nodes.
To hide an explorer node
Open the solution that you created in the earlier procedure.
In the DSL Explorer, right-click Explorer Behavior and then click Add New Domain Path.
A Domain Path node appears under Hidden Nodes.
Select Domain Path, and then in the Properties window, click the value field of Path Definition. Select FlowGraph, then FlowGraphHasComments. The resulting path should resemble FlowGraphHasComments.Comments
Transform all templates, and then build and run your solution.
In the generated designer, open the Sample diagram.
The explorer should show only an Actors node, and should not show the Comments node.