Customize my Workspace Perspectives
Customize my Workspace Perspectives
Join the DZone community and get the full member experience.Join For Free
Eclipse and CodeWarrior are great. But as with most great things, they get even better if I can customize it for my needs. As outlined in my earlier posts (Eclipse Full Screen Plugin, Hide and Show Eclipse Toolbar, Maximize Eclipse Views) there is already great flexibility.
But one thing is still not ideal for me: when I create a new Eclipse workspace, I end up with the Eclipse/CodeWarrior default perspectives. Nothing wrong with that, but there are many views which I need less than others. And especially for someone new to eclipse, the amount of views can be confusing at the beginning. So why not limit and customize the views as default for every new workspace? Or even better for an existing workspace? Having less views, buttons or menus should make things easier. I still can open the views/etc later if I need them. But I want to start with the most essential set of views. That set might vary, but here is what I do:
For CodeWarrior for MCU10.2, this is the default C/C++ Perspective for a new workspace:
In the default C/C++ perspective I have a total of 9 views. What I want is to get it down just to what I need. That means removing views and toolbar buttons.
Perspectives and new Workspace
A simple way is to close the views I do not need. That’s it. Eclipse keeps that setting for that workspace. But when I create a new workspace, the old default setting is back. In Copy my workspace settings I have found a good way to transfer my workspace settings. Want is a way to apply my view and perspective settings globally, so they are the default.
So here is how to do this, with the example of the C/C++ perspective:
- Create a new workspace. That way you have a clean start and not already changes from an existing workspace.
- Configure the perspective interactively. I close all the views I don’t want.
- I do the same for buttons I do not want. For this I use the menu Window > Customize Perspective: this gives me a dialog where I can configure buttons and menus:
- Use the menu Save Perspective As…:
- Select the perspective to overwrite:
- Confirm to overwrite it:
- Now I follow the steps outlined in Copy my workspace settings: I export my workspace settings into a file: Menu File > Export > General > Preferences:
- In the Export settings, I select ‘All’ and give a file name:
- Now comes the difficult part: I need to find the portion of the settings file what applies to the new perspective settings. See for more details Eclipse Global Preferences.
- I open the exported preferences text file from the previous step in Eclipse. In my new default view setup I still have the “Problems” view open. So I search for label\=”Problems” in the file. Alternatively I search for the word ‘perspective’. This gives me a very long line as it has all the view settings plus the toolbar items. And that line should start with /instance/org.eclipse.ui.workbench/org.eclipse.cdt.ui.CPerspective_persp
- CodeWarrior is using the file eclipse\cwide.properties inside the installation folder for global preferences. Open that file and add the line from above *without* the /instance/ part. For example I have added the two last lines to my cwide.properties file (extract):
org.eclipse.debug.ui/org.eclipse.debug.ui.switch_perspective_on_suspend=always org.eclipse.debug.ui/org.eclipse.debug.ui.switch_to_perspective=always org.eclipse.ui.editors/spellingEngine=org.eclipse.cdt.internal.ui.text.spelling.CSpellingEngine # my new default C/C++ perspective: org.eclipse.ui.workbench/org.eclipse.cdt.ui.CPerspective_persp=
<!--?<span class="hiddenSpellError" pre=""-->xml version\="1.0" .... \r\n
- Restart Eclipse
The result is a much smaller set of views (and/or buttons):
So instead of 9 different views, I have reduced it to 4 . And the amount of buttons in the toolbar are reduced to the things I use most.
So far so good. This was just one perspective. But I can do this as well for other perspectives like the Debug perspective. What I want is this as the default:
The same steps as above can be applied (change the perspective, export it and put things into the cwide.properties file).
Somehow exporting preferences did not export all modified perspectives. But if I am in the Debug perspective, and then exported the preferences, then things were exported. I think that might be a bug, as I have seen on the web several reports and forum discussions on this subject.
Then I have 3 lines in my cwide.properties file (extract):
org.eclipse.debug.ui/org.eclipse.debug.ui.switch_perspective_on_suspend=always org.eclipse.debug.ui/org.eclipse.debug.ui.switch_to_perspective=always org.eclipse.ui.editors/spellingEngine=org.eclipse.cdt.internal.ui.text.spelling.CSpellingEngine # my new default C/C++ and Debug perspective: org.eclipse.ui.workbench/org.eclipse.cdt.ui.CPerspective_persp=<!--?<span class="hiddenSpellError" pre=""-->xml version\="1.0" .... \r\n org.eclipse.ui.workbench/org.eclipse.cdt.ui.DebugPerspective_persp=<!--?<span class="hiddenSpellError" pre=""-->xml version\="1.0" .... \r\n org.eclipse.ui.workbench/perspectives=org.eclipse.cdt.ui.CPerspective org.eclipse.debug.ui.DebugPerspective
There is now the org.eclipse.cdt.ui.DebugPerspective_persp which defines the Debug perspective. Plus an entry for org.eclipse.ui.workbench/perspectives which lists all the perspectives I have changed.
Resetting Perspectives to the new Default
The cool thing is: I can apply the new default to an already existing workspace. Inside the perspective, I just select ‘Reset Perspective’ and it is using my new optimized default:
Eclipse allows me to change things the way I want it. Applying my perspective changes as a default for new workspaces is a bit complicated. But once things are defined properly in the cwide.properties file, then I can easily apply that to any existing workspace.
Published at DZone with permission of Erich Styger , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.