Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 308740 - Properly restore icon set in editor
Summary: Properly restore icon set in editor
Status: CLOSED DUPLICATE of bug 207443
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-10 20:26 EDT by Fabio Zadrozny CLA
Modified: 2010-04-12 14:04 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fabio Zadrozny CLA 2010-04-10 20:26:44 EDT
Build Identifier: Build id: I20100312-1448

I'm trying to change the editor image depending on the file name (my use case is that some files always have the same name -- e.g.: __init__.py or models.py, etc) and I'd like to show an icon that represents that file and show the name of the folder where it lies instead of that name...

Now, I can change the editor name and image without any problems in my subclass of TextEditor with setPartName/setTitleImage, and all goes well, but when the eclipse session is restored, although the title is properly persisted, the icon is not (it seems that the WorkbenchPartReference always gets the default icon for the editor even though it was changed).

Right now, the only way for me to make it right is by restoring all the editors on startup, but this makes the startup much slower if many editors are opened (so, it's not an acceptable solution).

I've looked a way to change the icon for an IEditorReference (so, at least I could compute it and set it myself from the outside), but that also didn't seem possible.

Reproducible: Always

Steps to Reproduce:
Create an editor that changes its icon on doSetInput, open many editors and restart eclipse. I'd expect the editors to have the same icons, but they don't.
Comment 1 Remy Suen CLA 2010-04-10 21:13:29 EDT
Not sure what we can do here. WorkbenchPart's setTitleImage(Image) takes an SWT Image. It wouldn't make sense for us to persist the bytes of said image. Think this would only be feasible by introducing new API.

Could you workaround this by contributing new editor extensions for files named __init__.py that uses a different icon?
Comment 2 Fabio Zadrozny CLA 2010-04-10 21:28:41 EDT
Not really, because it's something actually configurable... the initial request is for django files that repeat in each project (models.py, views.py, tests.py, etc), and I extended that to __init__.py files 

A solution would be being able to decorate the images (and have a way to ask for refreshing it when some configuration changes).

For that to work the steps would be the following:

1. Provide an extension that changes the initial image from the default image descriptor (based on the current input it has).

2. Whenever the input changes that decorator is called again with the default image.

3. If some configuration changes, I'd use a service and ask it to refresh the images.

Another solution would be having a setTitleImage in IWorkbenchPartReference which I'd call to update the icons upon startup (note that there's a setImageDescriptor in WorkbenchPartReference, but for some reason, calling it has no effect -- it's a protected API, but if it worked, it could be just a matter of making it public, that way I could change the image without needing to create an editor, just updating the image on the reference, and when the actual editor comes into place, it'd replace that image).
Comment 3 Remy Suen CLA 2010-04-12 14:04:52 EDT

*** This bug has been marked as a duplicate of bug 207443 ***