How to populate a TreeModelBrowser?

Hello,

I could use a bit of help here. I am not quite clear on how to get my collection of TextRange instances to appear in the TreeModelBrowser.

I've attached a code sample where I expected to get a window with a list of all the cs files in my solution, and clicking on one would navigate to the top of that file. Instead I'm getting an empty window. I'm thinking that in my OccurenceBrowserDescriptor subclass I need to be somehow connecting the TreeModel with the IOccurence list, but I can't seem to nail it.

Can someone give me a nudge in the right direction?

Thanks,
Josh



Attachment(s):
ExploreJoshAction.cs
4 comments
Comment actions Permalink

Hello jbuedel,

You are overriding Model property and providing just empty model for it.
So, resulting tree is empty, as model is. You don't need to override Model
property in this case, OccurenceBrowserDescriptor already has its own model
which it populates.

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


IR> Hello,
IR>
IR> I could use a bit of help here. I am not quite clear on how to get
IR> my collection of TextRange instances to appear in the
IR> TreeModelBrowser.
IR>
IR> I've attached a code sample where I expected to get a window with a
IR> list of all the cs files in my solution, and clicking on one would
IR> navigate to the top of that file. Instead I'm getting an empty
IR> window. I'm thinking that in my OccurenceBrowserDescriptor subclass
IR> I need to be somehow connecting the TreeModel with the IOccurence
IR> list, but I can't seem to nail it.
IR>
IR> Can someone give me a nudge in the right direction?
IR>
IR> Thanks,
IR> Josh


0
Comment actions Permalink

OccurenceBrowserDescriptor is abstract, and does not implement the abstract Model property inherited from TreeModelBrowserDescriptor. I have to implement Model since my class in not abstract.

0
Comment actions Permalink

Hello jbuedel,

Ah, sorry, looked in wrong place. I'm not sure you should use OccurenceBrowserDescriptor,
if you are not doing something like search. If you do, you can look at Find
Text PowerToy, download here: http://www.jetbrains.net/confluence/display/ReSharper/ReSharper3.0Plugin+Development

As for OccurenceBrowserDescriptor, it is designed to work with several sections,
like targets, results, textual results, late-bound results and so on, as
found in Find Results View. If this is what you want, you should:

1. Create TreeSectionModel and store it in the field myModel
2. Return it in Model property implementation, as you already do
3. Override SetResults as follows:

protected override void SetResults(ICollection items) { base.SetResults(items); var sections = new List]]>();
foreach (OccurenceSection section in OccurenceSections)
sections.Add(new TreeSection(section.Model, "Title for section"));

myModel.Sections = sections;
RequestUpdate(UpdateKind.Structure, true);
}


Hope this helps

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


0
Comment actions Permalink

That's what I needed. Thanks!

0

Please sign in to leave a comment.