Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsChanging the icon of a CompilationUnitEditor at runtime
https://www.eclipse.org/forums/index.php/mv/msg/1105570/1833508/#msg_1833508
I came up with the idea to change the icon of the "main editor" I'm working in. I created a subclass of CompilationUnitEditor and working my way from there via JavaEditorErrorTickUpdater and JavaUILabelProvider I was able to install a custom subclass of JavaElementImageProvider that allows me to switch out the icon.
While that approach works (I've been using that plugin for quite some time now) it's a faily hacky thing to do. I have to poke around with reflection in the various classes because most of the fields are private and instantiated from within the class that holds it.
Does anyone have a better solution to this? Or would there be a chance to open up the JDT API a bit so I can implement my plugin using more "legal" APIs?
]]>Dirk Olmes2020-10-15T11:19:31-00:00Re: Changing the icon of a CompilationUnitEditor at runtime
https://www.eclipse.org/forums/index.php/mv/msg/1105570/1833523/#msg_1833523
Are you perhaps referring to the problem of being able to get back to the CUT (code under test) when you're looking at the unit test for a class? This is one nice feature of the "MoreUnit" plugin. that makes it easy to jump back and forth between the unit test and the CUT (it also has intelligence to figure out which unit test methods and which CUT methods to go to, depending on the current method in focus).]]>David M. Karr2020-10-15T16:10:42-00:00Re: Changing the icon of a CompilationUnitEditor at runtime
https://www.eclipse.org/forums/index.php/mv/msg/1105570/1833529/#msg_1833529
David M. Karr wrote on Thu, 15 October 2020 12:10
I'm not familiar with the internals, but I'm just trying to figure out what you're asking for. It doesn't seem like it has any relation to JDT. What do you mean by "where I'm actually editing"? Obviously, that is the currently focused editor tab, but you must be referring to something else.
Thanks for you reply, David.
Maybe I need to explain my motivation a bit better. When I'm programming I typically have quite a few editor tabs open. One editor tab contains the code that I'm actually writing while the other tabs are open because I need to look at some different parts of the code, Maven POMs, XML config files, whatever.
It's all about editor tab navigation - once I leave the tab that contains the code that I'm writing and look at a different editor tab I have a hard time jumping back. Was it the first editor tab? The second one? Or the second last one? This is what sparked the idea for the plugin: if I could change the icon of the editor tab that I'm currently working in it would be very easy to jump back where I came from.
A picture probably tells more than a thousand words so I have attached a screenshot with my plugin in action. It should be fairly obvious which is the editor I'm currently writing code in :-)]]>Dirk Olmes2020-10-16T06:51:10-00:00Re: Changing the icon of a CompilationUnitEditor at runtime
https://www.eclipse.org/forums/index.php/mv/msg/1105570/1833531/#msg_1833531
It seems to me though that what you're describing as a solution is much more general than just JDT. I.e., it seems to me that it would indeed be useful to have a general UI capability to mark any editor tab (one or more?) as "favorite" such that it is visibly decorated in a somewhat eye-catching way so that one can easily find it visually. But rather than implementing that as a separate plugin, where you'll always have the problem of digging deep in the internals, instead contributing such a thing directly to the Platform UI project so it's generally available everywhere (via the context menu on the editor tabs).
It's a very welcoming community for contributions:
It seems to me though that what you're describing as a solution is much more general than just JDT. I.e., it seems to me that it would indeed be useful to have a general UI capability to mark any editor tab (one or more?) as "favorite" such that it is visibly decorated in a somewhat eye-catching way so that one can easily find it visually. But rather than implementing that as a separate plugin, where you'll always have the problem of digging deep in the internals, instead contributing such a thing directly to the Platform UI project so it's generally available everywhere (via the context menu on the editor tabs).
Thanks for the heads up, Ed. I'm afraid, though that such an extension of the Platform UI is a bit over my head. I wouldn't even know where to start digging into it.
If you could give me any tips (in addition to those you already gave) I'd be very thankful.]]>Dirk Olmes2020-10-20T06:47:36-00:00Re: Changing the icon of a CompilationUnitEditor at runtime
https://www.eclipse.org/forums/index.php/mv/msg/1105570/1833675/#msg_1833675
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform&component=UI&version=4.18
Describe what you would like to enhance and make it clear that you want to do the work of doing the enhancing yourself as a contribution. Ask those folks where the best place would be to get started (assuming they agree this would be a good enhancement).]]>Ed Merks2020-10-21T06:45:44-00:00