Eclipse Zone is brought to you in partnership with:

Erich is Professor at Lucerne University of Applied Sciences and Arts and Distinguished Member of Technical Staff at Freescale Semiconductor. Erich has a MsCS degree and 18+ years of experience in the embedded software and tools world. He created many embedded cross C/C++ compilers and debuggers. Additionally he is researching in the domain of programming languages, real time and mechatronic systems. Erich is a DZone MVB and is not an employee of DZone and has posted 105 posts at DZone. You can read more from them at their website. View Full User Profile

Eclipse Working Sets Explained

05.30.2012
| 14472 views |
  • submit to reddit

Eclipse comes with a large set of different views: They allow the developer to represent the information in various forms and with different angles. Most of these views are navigation oriented: a perfect example for this is the projects view or the Outline view. But over time I add more projects, more resources to my project, and at a certain time things get overwhelming. I have a lot of projects, and I do not want to switch between workspace too often. Yes, I can open and close projects, but this gets cumbersome too. Thankfully, there is a solution in Eclipse: Working Sets.

Working sets allow me to group elements for display in views. With that, I can do operations on a set of elements in that working set. Especially as I’m using many projects the same time, working sets are a big help to focus on the right set of things at a time. I can define a set of things I want to look at, work with, or whatever: it allows me to get be productive in the universe of my environment.

Building/compiling a Working Set

A nice feature of using working sets is to build a set of projects. Instead of selecting a set of projects and then to compile them together, I use a Working Set.

I use the menu Project > Build Working Set > Select Working Set… to create or change working sets:

Menu to select working set

Menu to select working set

If I have no working set defined, then this will show the following dialog where I can press New… to create a new one:

Creating new working set

Creating new working set

To create a working set of C/C++ projects, I select C/C++ and press Next:

New C C++ working set

New C C++ working set

Next I give a name and select the project(s) which shall be in my working set, and press Finish:

Defining working set

Defining working set

To build my set of projects, I can select the working set and press OK:

Selected working set

Selected working set

Search in a Working Set

It is possible to limit the search to a working set. For this I can choose a working set as scope in the search dialogs:

Search in a working set

Search in a working set

Managing Working Sets

To manage working sets, I press CTRL+3 (see Quick Access) and choose Manage Working Sets…:

CTRL+3 with Manage Working Sets...

CTRL+3 with Manage Working Sets…

Note: I can add extra tool-bars and menus for working sets too (this is explained later).

Then I can manage my working sets:

Manage Working Set Configuration

Manage Working Set Configuration

Project View Filtering with Working Sets

I can filter the projects shown in the project view based on working sets. For this I select the small triangle and select/define a working set or choose one from the most recently used sets:

Working Sets for Project View

Working Sets for Project View

With this I can easily filter and focus on a subset of projects:

Project view with applied working set

Project view with applied working set

Really cool :-)

Tip: I’m using Working Sets as well to avoid too many workspaces. Instead of having projects spread over different workspaces, I can keep them in one workspace and use working sets instead. There is an added benefit of using working sets: having too many projects open at the same time in eclipse can slow down the IDE: using working sets allows me just to switch quickly between the set of projects I’m working on.

But it does not stop at filtering by projects: you can filter even things inside the project structure. I simply deselect things I don’t want to see and can focus on what is important for me:

Filtering project files

Filtering project files

Export and Import of Working Sets

Note: Import and Export of Working Sets is not part of the standard CodeWarrior Eclipse distribution. You get the import/export feature installed with the MQX plugins (www.freescale.com/mqx) or with the AnyEdit plugins (http://andrei.gmxhome.de/anyedit/index.html).

To export a working set, I use the menu File > Export > Other > Export Working Set:

Export Working Set

Export Working Sets with MQX plugins

Note: The AnyEdit plugins come as well with an import/expert working set wizard. The file format is different, and the MQX plugin allows drag&drop of the file into Eclipse.

This gives the following dialog where I can specify the file name and the root of projects:

Export Working Set Dialog

Export Working Set Dialog

This will store the settings in an XML file.

Importing the working set is done with File > Import > Other > Import Working Set.

Tip: I’m using *.wsd extension for working sets. That way I can simply drag&drop the file into Eclipse to import it.

Other Kinds of Working Sets

Working Sets do not stop at projects and files:

Select working set type

Select working set type

I can create working sets of breakpoints or analysis/trace points. Or I can create working sets of any resource files or tasks. The possibilities are nearly endless and depend as well on the extra plugins installed.

Window Working Sets

And now back to the really cool part. One question remains: what are Window Working Sets?

Window Working Sets

Window Working Sets

The thing is that every view and dialog has its own working set setting. In my example below I use a working set ‘ColdFire’ for the projects view, but my Search dialog has a ‘Kinetis’ working set configured:

Two different working sets

Two different working sets

Sometimes I want this, but not always. What I need is a ‘global’ working set. And here the Window Working Sets comes to rescue me. For this I’m going to add some menus and toolbars to make it really easy…

For this I choose the menu Window > Customize Perspective. In the Command Groups I enable ‘Window Working Set’. Additionally it is a good idea to enable ‘Working Set Manipulation’ as well:

Window Working Set commands

Window Working Set commands

The same way I can enable the Toolbar and Menu Visibility. This gives me added tool-bars to switch between working sets and to add/remove things from a working set quickly:

Working Set Toolbars

Working Set Toolbars

In a similar way, it gives me menu access as well:

Working Sets menu

Working Sets menu

And here is the trick: Using ‘Window Working Set‘ really means ‘Using the global workbench working set‘. To select the global workbench working set, I use the toolbar icon to switch between Window (or Workbench) working sets:

Selecting global Window or Workbench Working Set

Selecting global Window or Workbench Working Set

In the individual views I choose to use the Window Working Sets instead a selection of working sets:

Selected global Window or Workbench Working Set

Selected global Window or Workbench Working Set

Now my working set settings are shared and common for all views: if I switch the working set, it will switch for all views where I have set it to ‘Window Working Set’:

Window Working Set applied to multiple views

Window Working Set applied to multiple views

That way my working set is the same across views, and switching between different project settings is done with a simple mouse click.

Summary

Working sets are an extremely powerful feature to get focus on a subset of things inside Eclipse, based on my workflow. As with many great Eclipse features, I need to know about it until you really appreciate the power of it. Who knows how many other hidden treasures are buried in Eclipse ;-)

I hope this article helps to save you a few mouse clicks.

Happy Work-Setting :-)But over time I add more projects, more resources to my project, and at a certain time things get overwhelming. I have a lot of projects, and I do not want to switch between workspace too often.

Published at DZone with permission of Erich Styger, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)