Bug 267844 - [JFace] Changeable icon sets by user.
Summary: [JFace] Changeable icon sets by user.
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-10 09:44 EDT by Adam Wehner CLA
Modified: 2019-09-06 16:18 EDT (History)
4 users (show)

See Also:


Attachments
Patch on JFace (23.60 KB, patch)
2009-03-10 09:44 EDT, Adam Wehner CLA
no flags Details | Diff
Patch on JFace - Without formatting changes (3.98 KB, patch)
2009-03-10 11:43 EDT, Adam Wehner CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Wehner CLA 2009-03-10 09:44:16 EDT
Created attachment 128193 [details]
Patch on JFace

I had the requirements to change the complete icon set by selecting the set in a preference page. After evaluating the possibility to play around with fragments and equinox transforms, I decided to patch JFace in order gain the wanted behavior.
The patch involves an extension of the ImageDescriptor.createFromURL() method. The methods asks an OSGi Service called IImageLocationTransformer for transforming the URL to a new location before the ImageDescriptor is made. The service implementation can be registered by a custom plugin and have custom behavior.
A disadvantage is that the client must be restarted in order the get the changes. But this would also be true with equinox transforms and fragments.

I would like to provide the patch, if you think that it could be useful for the platform.
Comment 1 Remy Suen CLA 2009-03-10 11:29:28 EDT
(In reply to comment #0)
> Created an attachment (id=128193) [details]
> Patch on JFace

Would you mind respinning a new patch that doesn't include so many changes? I see a lot of lines that are being removed and subsequently added back because of whitespace changes and/or word wrapping effects.
Comment 2 Adam Wehner CLA 2009-03-10 11:43:35 EDT
Created attachment 128215 [details]
Patch on JFace - Without formatting changes
Comment 3 Adam Wehner CLA 2009-03-10 11:45:21 EDT
New patch without formatting changes is uploaded. Which formatter settings are used in JFace? I formatted it with the built-in eclipse-formatter settings of Eclipse 3.4.1. Sorry for that.

Comment 4 Remy Suen CLA 2009-03-10 11:52:16 EDT
(In reply to comment #3)
> New patch without formatting changes is uploaded. Which formatter settings are
> used in JFace? I formatted it with the built-in eclipse-formatter settings of
> Eclipse 3.4.1. Sorry for that.

No need to apologize. It's all kind of disorganized right now. We hope to resolve this with bug 258729.
Comment 5 Paul Webster CLA 2009-03-11 11:26:04 EDT
See also bug 250432 and bug 246224, which is optional hooks supported in org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin(String, String)

PW
Comment 6 Adam Wehner CLA 2009-03-11 11:38:55 EDT
The Problem with org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin(String,
String)
 is, that it is not called for images declared by the commandImages extension point. 
Comment 7 Boris Bokowski CLA 2009-03-11 13:17:32 EDT
Good idea. This would have to be tested to work even when running JFace standalone (i.e. without OSGi). A simpler way to do this would be to expose API in Policy.java through which you can set the IImageLocationTransformer using a normal method call.

Also, should we allow transforming the other ways of creating an ImageDescriptor as well? 
Comment 8 Adam Wehner CLA 2009-03-12 04:46:07 EDT
An OSGi independent implementation is a good point. I did not mind about that, because we use JFace within a RCP Client. 
So the better way would be to set the IImageLocationTransformer by calling Policy.setIImageLocationTransformer() in my custom plugin, right? Or should Policy.getIImageLocationTransformer() checks an IImageLocationTransformer extension point?
The problem with that would be that you can not know which IImageLocationTransformer is taken, when more than one custom plugin set or register own transformer.

In the current solution you have some kind of control by setting the service priority.
What about the idea to provide a transform() method in the Policy.java (?) which calls the IImageLocationTransfomer.transform() method of all registered transformers by extension points? So you would have a pipe of transformers which can react on the given path/url. Make this approach sense?

As I see there is also a ImageDescriptor.createFromFile() method which should be involved in the transformation. Therefore the IImageLocationTransformer interface could be extended by transform(String path). 



Comment 9 Boris Bokowski CLA 2009-03-12 08:18:52 EDT
This is for RCP apps that would like to re-use existing views, toolbar items, etc but use different icons. Why would it be a problem to decide which transform to use? It's an RCP application, so you should know who is calling that method, and be able to make sure it only gets called once, presumably from your application class. To make it "safer", we could allow it to be set only once, preventing arbitrary plug-ins from overwriting it later. Using an extension point would not work for those people who just put the SWT and JFace jars on their class path but don't run it inside Equinox.
Comment 10 Adam Wehner CLA 2009-03-12 09:23:32 EDT
Ok. 

My suggestions were born because I have seen that the Policy class already imports eclipse specific classes (IStatus and Status). So it seems for me that JFace is at this place not really independent from the Eclipse RCP Platform. Further the JFaceUtil class imports more specific classes (Preferences).
So the extension point check could happen in an IImageLocationTransformer implementation set by the JFaceUtil to the Policy class. The default state would be, that no transformer is set (for standalone swt/jface).

But that are only some thoughts about that. I do not really have an insight view about the integration of JFace in RCP.
Comment 12 Paul Webster CLA 2009-03-13 13:03:56 EDT
(In reply to comment #6)
> The Problem with
> org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin(String,
> String)
>  is, that it is not called for images declared by the commandImages extension
> point. 

This is fixed in 3.5
PW

Comment 13 Adam Wehner CLA 2009-03-24 04:50:53 EDT
Hello,

summaring the comments, the best way would be to remove OSGi dependencies from JFace and create a setter and getter in Policy.java. Further, the interface should be extended by a method for transforming a file path.

In RCP the set IImageLocationTrasformer implemetation could be one which consider an extension point or any other needed mechanism (perhaps in ui.workbench?).

Okay? Any other suggestions?

Adam
Comment 14 Paul Webster CLA 2009-03-24 09:55:01 EDT
Why not do this with shared images?  Every RCP app gets the opportunity to add to the shared image cache using org.eclipse.ui.internal.WorkbenchConfigurer.declareImage(String, ImageDescriptor, boolean) on startup.

Swapping images would be easy.

PW
Comment 15 Adam Wehner CLA 2009-03-30 03:06:26 EDT
Hi,

are the images declared in the plugin.xml (action and commands) also managed via shared images? So these images could also be replaced?

Adam
Comment 16 Paul Webster CLA 2009-03-30 09:26:00 EDT
(In reply to comment #15)
> Hi,
> 
> are the images declared in the plugin.xml (action and commands) also managed
> via shared images? So these images could also be replaced?

org.eclipse.ui.commandImages are managed by the CommandImagesManager.  All other images are managed by whatever local extension point does.  But most images that come in this way come through org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin(String, String) (which is how we added ISharedImages support to most plugin.xml images).

PW
Comment 17 Susan McCourt CLA 2010-01-24 16:44:49 EST
see also bug 299717 which discusses this problem from an e4 perspective.
I'm wondering if we can close that bug as a duplicate of this one?

(Boris, this bug is currently assigned to you and marked for 3.6????)
Comment 18 Paul Webster CLA 2010-06-09 08:17:38 EDT
Removed from 3.6.  Owners can re-assess.

PW
Comment 19 Eclipse Webmaster CLA 2019-09-06 16:18:13 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.