11

I want to change my custom perspective's icon in eclipse. I have searched a lot but I didn't find any solution.

fatihsuat
  • 111
  • 1
  • 5
  • replace icons in plugins folder and rewrite their corresponding plugins.xml – Tamil Selvan C Mar 16 '13 at 12:23
  • Unfortunately, the last comment, dated 2007-10-04 12:34:27 EDT, on this (still open) bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=10999 is "There are no plans to work on this or bug 118296 in 3.4. However, I would consider patches if submitted.". – levant pied Mar 03 '15 at 22:47

3 Answers3

6

The icon for a perspective can be changed by updating the iconURI attribute of the perspective's definition in workbench.xmi file. This file is located inside the .metadata directory of the workspace. e.g. /My-Workspace/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi.

There are usually two lines with the iconURI attribute. For example:

<children xsi:type="advanced:Perspective" ... iconURI="platform:/plugin/com.atlassian.clover.eclipse.core/icons/cview16/clover.gif" tooltip="Clover">

and

<snippets xsi:type="advanced:Perspective" ... iconURI="platform:/plugin/com.atlassian.clover.eclipse.core/icons/cview16/clover.gif" tooltip="Clover">

The icon URI is a path to an image within an Eclipse plugin. (Plugins are located at {ECLIPSE_HOME}/plugins directory.)

The workbench.xmi file needs to be edited after closing the Eclipse IDE, because the file gets overwritten when you exit from Eclipse.

In this example I created a custom perspective named Clover by modifying the Java Perspective available in Eclipse, and saving it as "Clover". Initially my perspective had the same icon as the Java perspective:

initial icon of the custom perspective

So I closed Eclipse, changed the icon paths in workbench.xmi, saved the file, reopened the IDE, and got the new icon displayed:

new icon of the custom perspective

Note: I use Eclipse 4.6.0 (Neon) but this solution would work for all Eclipse 4 versions.

Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
sudeep
  • 735
  • 1
  • 9
  • 8
  • hm, I wasn't able to make these work (also using 4.6.0). I added my image file to `C:\eclipse\plugin\icons\scala.png` then I modified the `workbench.xml` in the path you mentioned above as follows `` Did I do anything wrong? Thanks! PS: I couln't find a `snippets` tag in my xml – Fawix Oct 23 '16 at 15:35
  • 1
    @Fawix I wasn't able to achieve this in Mars.2 (4.5.2), too. Maybe it's the `elementId="org.eclipse.jst.j2ee.J2EEPerspective.JUnit"` in `` and `` that keeps the Java EE icon here. (I did _Save as..._ from the _Java EE_ perspective.) For the _Git_ perspective, which has its own icon, it's `elementId="org.eclipse.egit.ui.GitRepositoryExploring"`. – Gerold Broser Mar 13 '17 at 16:25
  • @Gerold, I tried that too; to add to both the snippet tag and the element_id. Did you have any luck? It still didn't work for me (btw, good idea doing a save as on the git view!) – Fawix Mar 14 '17 at 17:45
3

If you stored an existing perspective under a different name as your custom perspective, then it is not possible to change the icon.

You would have to define the perspective by writing a small Eclipse plugin to be able to change the icon.

Bananeweizen
  • 21,797
  • 8
  • 68
  • 88
0

Open plugin.xml for your plugin; go to the Extensions page; and select your perspective extension (in org.eclipse.ui.perspectives: you should have your custom prspective entered in here). There is an icon attribute you can set for your custom perspective. (I am using Neon2)