views:

37

answers:

1

Hi, how would I go about updating the title bar of an Eclipse editor when the file input changes to reflect the new filename? For instance, when the file is renamed but you still have an editor open on the file. Everything I've done so far has failed, even when following the official guidelines on doing this (using special interfaces, classes, etc). The Java editor can seemingly do this fine. If I update the title and post the status update, it just doesn't update. Calling the update methods after this also doesn't update the editor title. Confusing.

Cheers, Chris

A: 

This probably isn't the answer you are looking for but it does work.

Cast your editor to WorkbenchPart (not IWorkbenchPart) and call setPartName(String name).

rancidfishbreath
Maybe, I need to test it out. I'm sure I tried this ages ago, though. It's for a long-running bug in one of our products, ahem :)
Chris Dennett
I forgot to mention this before. setPartName(String name) is a protected method so I call it through reflection.Method method = WorkbenchPart.class.getDeclaredMethod("setPartName", String.class);method.setAccessible(true);method.invoke(part, name);
rancidfishbreath
Ahh, maybe it'll work then. Seems a bit dodgy though :)
Chris Dennett
It is, but this is the only way I have been able to get it to work. Of course if you access it from within you part then you can call the protected method directly. If you need to access it outside of your part you can always override setPartName() and make it public. I needed a general way to access it without specific knowledge of subclasses which is why I used reflection.
rancidfishbreath