Archive for January 19th, 2008

JDT/Text adds a new feature, you all know what that means…

Saturday, January 19th, 2008

Whenever JDT/Text adds a new feature, every other language editor usually buckle up their belts and try to model the same behaviour in their editors. This will probably be no different with the recent advent of them Java editor breadcrumbs that was recently implemented by bug 210830. You can give it a whirl in the N20080119-0010 build if you’re in the mood.

So how hard is it to implement this? If you’re trying to do a quick and dirty hack as a prototype for your product manager for that meeting this coming Monday, have no fear, it’s completely doable! Hell, I just did it this morning.

Look at that, it’s like child’s play.

Here are some tips for the aspiring breadcrumb hacker:

  • in your EditorBreadcrumb subclass, make sure you call setTextViewer(ITextViewer) or your will get an NPE when you return true for the open(Object) or reveal(Object) methods
  • when creating your ITreeContentProvider implementation, make sure you implement getParent(Object) properly, in standard TreeViewers, it never seemed to matter (from my own experience), but it does in this scenario
  • the JDT dependencies can be safely removed, I ended up using a Twistie instead of porting the images over, feel free to do either or
  • the code will even work on Eclipse 3.2 (and possibly lower, but I didn’t try)

Getting the keybindings to work properly and all will probably be difficult, but don’t look at me, because I didn’t even try. ;) Good luck!