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
inside the installation folder for global preferences. open that file and add the line from above
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.