It's all about the answers!

Ask a question

RepositoryFilesView - API ?

Gidi Gal (961734) | asked Jul 18 '16, 11:08 a.m.
edited Jul 19 '16, 3:11 p.m. by David Lafreniere (4.6k7)
Hello to the forum members,

I want to write code that will display specific file in repository files view, based on its local path.
I found out that the view does not provide method to get the tree viewer of the view, so it seems that I'm unable to implement the requested behavior.

Is this correct ? Is there a way to get access to the tree viewer ?


Ralph Schoon commented Jul 19 '16, 2:43 a.m.

Gidi, that are internal API's that very few people will have ever looked at. As it is internal API why should it provide the internals?

Gidi Gal commented Jul 19 '16, 3:39 a.m. | edited Jul 19 '16, 3:39 a.m.

Hi Ralph,
Thanks for your reply. I wanted to add automation that will receive file path and will focus on the related element in repository files' view. Such functionality does not exists in RTC UI: for example, if you are looking at a file in the pending changes view and you want to find the related file in the repository files, you have to click on a component, show it in repository files and then manually find it inside. I understand that the repository files view is internal, I hoped there's still a way to get access to its tree. I added a similar capability to the pending changes view. Luckily, this view is not internal and does supply access to its tree viewer.

Accepted answer

permanent link
David Lafreniere (4.6k7) | answered Jul 19 '16, 3:25 p.m.
edited Jul 19 '16, 3:26 p.m.
'' is internal and there is no method to get the tree viewer that is used in this class. In fact, even the Pending Changes view code should have bee put in a package that has 'internal' in it (however it looks like this was missed). In general though, all UI code should be treated as internal as it can and will change in future releases. As a rule of thumb, unless the code is included in the downloadable "Plain Java Client Libraries API documentation" zip (ex: it should be treated as internal (Note: the SCM UI code does not exist in that download). However you could always take a slightly hacky approach, and use Java reflection to pull out the tree viewer (which is stored as a Java field of the class) (but always remember that all UI code might change in the future).
Michael Valenta selected this answer as the correct answer

Gidi Gal commented Jul 24 '16, 8:56 a.m.

Hi David,
Thanks for your reply.
Is there a public way to select an element (IVersionable, I guess) in the repository files view ? When I try to do so with reflections through the tree viewer I face lots of issues.


David Lafreniere commented Aug 05 '16, 3:14 p.m. | edited Aug 05 '16, 3:15 p.m.

There is no public way to select an element in the Repository Files view. Also keep in mind that initially the Repository Files view is collapsed. It uses a lazy fetching approach, where a query is run against the server only when the user expands a particular node (folder or component), so not all 'nodes' are known upfront.
The TreeViewer that this view uses is in this field:
   private SimpleTreeViewer viewer;
If the node that you want to select is known somehow, then I see there is a method
   SimpleTreeviewer.selectAndReveal(ITreeSelection ss)

Your answer

Register or to post your answer.