index > Visual Studio Team System - Domain-Specific Language Tools > filtering reference dropdowns in the propertygrid

filtering reference dropdowns in the propertygrid


I have a basic model, where I have a Table class, a Key class, a Field class, and a FieldReference class.

The idea is that this can be used to model a database structure.

Tables may have multiple Fields, and Tables may also reference multiple Keys.

Each Key may contain multiple FieldReferences, and a FieldReference can have 1, and only 1 Field selected from a dropdown in the propertygrid.

My problem, is that the dropdown for the Field component of the FieldReference lists ALL Field instances in the entire diagram, I need it to be filtered to show just the set of Fields that belong to the Key classes owning Table class.

This is becuase its not possible for a tables PrimaryKey to contain columns from a different table...

Any ideas how I can do this? I've tries putting a CLR attribute on the reference to use a TypeConverter, where I can provide the list of Attribute classes, but this TypeConverter never gets called....

Any ideas?

Thanks guys.

Nimble
The default behavior is implemented by Microsoft.VisualStudio.Modeling.Design.RolePlayerPropertyDescriptor class. In your own designer, you can create a new property descriptor deriving from the above one, and override property ElementList, in which you can code your filtering mechanism. Thanks!


Frank Fan [MSFT]
Jing Fan

Thanks Jing,

I have subclassed

Microsoft.VisualStudio.Modeling.RolePlayerPropertyDescriptor

however I dont know where to link this into my designer. How do I actually make my designer aware of this new class, and to use it instead of the default RolePlayerPropertyDescriptor?

Thanks

-Adam

Nimble

To make the TypeDescriptor you wrote work, you can write your own TypeDescriptionProvider and TypeDescriptor.

1) Write a class that derives from Microsoft.VisualStudio.Modeling.Design.ElementTypeDescriptor, say MyTypeDescriptor class. In the class, override the base methods you'd like to override. In particular, you want to override CreateRolePlayerPropertyDescriptor() method. The method passes you the source role-player and the target role as parameters. Say you want to filter relationship ARefsBs, then check if the source role-player is an instance of A and the DomainRelationship of the target role is ARefsBs. If so, return an new instance of the RolePlayerPropertyDescriptor that you have written earlier in this thread; if not, just return base.CreateRolePlayerPropertyDescriptor().

2) Write a class that derives from Microsoft.VisualStudio.Modeling.Design.ElementTypeDescriptionProvider, say MyTypeDescriptionProvider class. In the class, override CreateTypeDescriptor() method to return the descriptor in step 1 above.

3) Say you want to filter a relationship ARefsBs. On the source role of the relationship, A in this case, register a CLR attribute:
[System.ComponentModel.TypeDescriptionProvider(typeof(MyTypeDescriptionProvider))]. You can do this by writing a partial class to of generated A to add the attribute, or you can add a ClrAttribute in your DomainModel for DomainClass A, so the attribute is generated for you directly. If you choose the second approach, there's currently a bug in the attribute dialog that you can't type in the parameters easily, so you might want to edit the dsl file in XML editor directly.

The above steps should cause your type descriptor to be called when displaying an instance of A in properties grid, which calls your RolePlayerPropertyDesciptor to display role Bs. So if you have overridden ElementLists property in your role-player property descriptor correctly, you should be able to filter the results. Thanks!




Frank Fan [MSFT]
Jing Fan

Hi Jing,

what version of DSL are you talking about? the April, or June? Im using April, and theres no Microsoft.VisualStudio.Modeling.Design namespace...

(Ill download the June one now just to have a look at the namespaces, but I didnt want to use it due to some particular bugs...)

Thanks

Nimble

Have installed the July CTP and implemented it as you said. Works perfectly.

Im still having issues with the VS2K5 explorer windows flashing and disappearing on me, which doesnt actually happen on my workstation, only my laptop... weird. I've completely reinstalled VS and cleaned the registry to no avail...

Might be time for my 3rd rebuild this year (c;

Nimble
reply 6

You can use google to search for other answers

 

More Articles

Problems with DSL Tools Version 1
When will a release be made available for the RTM?
A Software Factory Newbie Wants To Understand Some Things....
Installing DSL Tools Nov CTP Release
Bug in Edit Attributes editor
Can Visual Studio DSL Designers be hosted?
Error in "Domain-Specific Language Tools" walkthrough
November release Designers compile errors
Additional DSL documentation?
Compartiment with multiple classes to be added
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

How do you Add F1 Help and ToolTips to a…
Using DSL tools outside VS
Unregister DSL file extension
Error Creating DSL Designer Project
How it the class mentioned in directivep…
Custom Command improvements
Multiple viewpoints/ zoom in, zoom out
Tool support for designer definition?
Additional Toolbox Tab
DSL Tools May 2005 with VSTS July CTP?
DSL and XMI interchange format
Workaround: Recovering invalid model fil…
Is there any documentation regarding the…
Come Join the World's Largest Software F…
Atrributes with particular properties

Hot Articles

Bugs (?) in July version
Validation when dropping an element on t…
changing defaults in inherited propeties
Do all custom properties have GUIDs?
Problem Extending Notation with icons
Next CTP
Have problem for the DSL walk-through st…
Suggestion - Context Menu: Override Beha…
Prevent generated DSL code from producin…
Come Join the World's Largest Software F…
DSLTools download moved?
Three mystic symbols
how can i get a reference to a modelelem…
Troubleshooting: duplicate generated files
How to expose domain model objects throu…

Recommend Articles

Can Visual Studio DSL Designers be hosted?
"Static" Swimlanes
bidirectional connectors
Enable/Disable property OnValueChanging/…
.tt files shouldn't be copyrighted
Auto Add Child Elements
How can i associate a textfield with a p…
Copy/Paste
Minor gotcha in the Adding a Compartment…
March CTP DSL uninstall / VS (RC) issue
Load Data designed in another model file
[outdated] September 2005 CTP available
property graphical representation
DSL tools on XP 64 bit
Custom source for connector