This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I want (let's say better, I have to! ) to implement an eclipse plugin which has to receive as input an xml file having hundreds of elements of this type:
that is, this xml file contains a lot of alias for methods of classes which are disseminated through the workspace (in several different projects). My plugin should add a new view tab to eclipse containing an (ordered) list of all the aliases. Upon double-clicking an alias, a new tab pointed at the method definition should be automatically opened (something similar to what happens when using "Open Type", but pointing to a method declaration). In addition to this, since the list is really huge, I would add the possibility of filtering the aliases exactly as it happens with method names when you click CTRL+O within a class.
I have seen that there is a wizard to create a plugin which adds a new view to eclipse, so that can be my starting point. Furthermore, the unmarshaling of the xml should not be that difficult with JAXB. My only problem is "just" to understand how can I add the filtering function within the view and of course the behavior of automatically opening a java file (at a specified position) upon double clicking.. Maybe you know some example which may help me? Is the source code of the 2 plugins I mentioned ("open type", "search method") available?
I will rellay appreciate any suggestion/help!
Thank you in advance!
Christophe Verré wrote:Eclipse Plug-ins, Third Edition is a great book to learn about Plug-ins development. The "Favorites" application made in this book would help you understand how to make your view.
hi and thank you for your hint! Unfortunately I don't find that book that great.. It makes an example which is quite interesting and related to my problem, but it doesn't give all the instruments to understand and modify the favorites plugin.. Chapter 7 (the one about views) makes just a copy and paste of the source code with a very few (generics) comments.. So for example I didn't understand if I can use the fully qualified name (my.package.ClassName) coming from my xml to retrieve (and open upon double clicking) the corrisponding file? Is this conversion possible at all?
The Type selector (Ctrl+O) opens files that way, so it must be possible I made a plugin which opened files too, but I used the resource path instead : <name of project>/<path to source/my/package/ClassName. I don't know if there's a simple way to open a file by its fully qualified name. Sorry.>
Joined: Jan 16, 2010
Finally I solved my first issue in the following way :
I use then a method which returns a IJavaElement (both IType and IMethod are IJavaElements) after calling both the methods above (it could happen I find the class but not the method, so I want to open just the class file).. Finally, I call
I am not sure if this is the best approach possible (I guess not! ), but it works!
I implemented also a filter following the example of the book, which uses a (static) InputDialog.. Maybe you know how may I implement such filter making it a dynamic filter (exactly as it happens with Ctrl+O within a java file)?
Another question: do you know how to search the workspace for a given file? I googled for a solution and I thought something like:
would do the trick, but it doesn't.. What I want to achieve is something like this: