Customize my Workspace Perspectives

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:

C/C++ Perspective

For CodeWarrior for MCU10.2, this is the default C/C++ Perspective for a new workspace:

Default C C++ Perspective Views

Default C C++ Perspective Views

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.

C/C++ Perspective

So here is how to do this, with the example of the C/C++ perspective:

  1. Create a new workspace. That way you have a clean start and not already changes from an existing workspace.
  2. Configure the perspective interactively. I close all the views I don’t want.
  3. 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:

    Customize Perspective

    Customize Perspective

  4. Use the menu Save Perspective As…:

    Save Perspective Menu

    Save Perspective Menu

  5. Select the perspective to overwrite:

    Overwrite default perspective

    Overwrite default perspective

  6. Confirm to overwrite it:

    Overwrite Perspective

    Overwrite Perspective

  7. Now I follow the steps outlined in Copy my workspace settings: I export my workspace settings into a file: Menu File > Export > General > Preferences:

    Exporting Preferences

    Exporting Preferences

  8. In the Export settings, I select ‘All’ and give a file name:

    Export Preferences Details

    Export Preferences Details

  9. 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.
  10. 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
  11. 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
    
  12. Restart Eclipse

The result is a much smaller set of views (and/or buttons):

Optimized perspective with less views and buttons

Optimized perspective with less views and 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.

Debug Perspective

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:

Optimized Debug Perspective

Optimized Debug Perspective

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:

Reset Perspective

Reset Perspective

Summary

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.

Happy Customizing 🙂

Advertisements

6 thoughts on “Customize my Workspace Perspectives

    • This has been bothering me for years now. I read through this post, but my custom perspective doesn’t appear to be captured in the export process. At least re-importing those preferences does nothing for my customer perspective. Is this a bug with CW, or did I perhaps miss something simple?

      Like

      • I used that approach with CW for MCU V10.2 (Eclipse Juno if I remember it correctly). I realized that things are somehow different in later Eclipse releases, but I had not investigated in details. So it really could be because later Eclipse version are handling it differently. I ended up doing my settings in the workspace settings.

        Like

  1. Hello,
    What I’d like to see in the “Debug Perspective” and in “C/C++ perspective” is the auto switch between them when debugging start and stop.

    For example, TI’s “Code Composer Studio” automatically switches between Perspectives.
    Is there any chance to have that in CodeWarrior?

    Thanks.

    Like

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s