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

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!

4 Responses to “JDT/Text adds a new feature, you all know what that means…”

  1. kumar Says:

    Hi,

    It’s great to see your implementation. Can you please provide me your code for the above feature as I was stuck in the middle of this. It will be very helpful as I’m a beginner.

    Thanx

    Kumar

  2. Remy Says:

    Hi Kumar, you should file an enhancement request to get the breadcrumbs concept exposed as an API. I implemented the above a long time ago and I believe I have deleted the code since then.

  3. ubersoldat Says:

    Hi,

    Following the breadcrumb on Eclipse I created one for my app on PyGTK but I’m not very satisfied with the way it works. I would like to see the source code but I’m unable to find it in dev.eclipse.org/viewcvs so if you can point me out in a direction I’ll appreciate it.

    Thanks! Bye!

  4. Remy Says:

    ubersoldat, JDT’s implementation resides in the org.eclipse.jdt.ui bundle.

Leave a Reply