Categorise Projects in the Package Explorer to Reduce Clutter in Eclipse
Join the DZone community and get the full member experience.
Join For Freeif you’ve been hanging onto one eclipse workspace for the last couple of years, you’ll probably have dozens of projects cluttering up your workspace. if you’re an eclipse rcp developer, you may be sitting with around 50+ projects easily.
the thing is that you’ll often only work with 1 or 2 at a time, not the whole lot. and sometimes you want a convenient way of only browsing projects belonging to a specific product/feature/layer/any-other-grouping-that-makes-sense. having all projects in a long list makes it difficult to manage and more difficult to browse.
that’s why the package explorer and project explorer have a nice feature that reduces the clutter and allows you to organise your project into categories that make sense. so instead of the package explorer looking unwieldy and flat like this,
it could look like this:
how to categorise projects
this feature works closely with another eclipse feature called working sets. a working set is just a grouping of resources (ie. files, folders and projects). each category is just a working set.
to categorise projects, we’ll first create some working sets and then enable the feature in the package explorer.
to create a working set do the following:
- open the package explorer (or project explorer) and in the view menu (triangle in the upper, right corner), click select working set…
- click new… in the select working set dialog.
- select resource working set type and click next.
- on the next page select all the projects you want to include in the working set and pick a descriptive name for your working set. repeat the process for any other working sets you want.
- click finish.
here’s an example of what the working set dialog should look like:
now to enable the grouping feature. open the package explorer’s view menu again and enable top level elements > working sets . if it’s the first time you do this, eclipse will prompt you to configure working sets – a way to ask you which working sets to display in the package explorer. select all the working sets you created and click ok.
you should now see your working sets in the package explorer and if you expand it, all the projects you selected will be shown.
here’s a quick video to give you an example of how this works and looks. in the example, there are 8 projects, 3 belonging to the ui and 3 to the model. the working sets will group them according to ui and model. there are also 2 projects that are scratchpad projects, so for now they won’t be categorised.
notes:
- a project can belong to as many working sets as you want , so it can appear in a number of categories.
- you can choose which working sets display in the package explorer by choosing configure working sets … from the view menu and then selecting/deselecting the relevant working sets. nb! this menu item is not available if you’re not in the working set layout.
- to get back to the normal view, select top level elements > projects from the view menu.
- any project not assigned to a working set goes to a category called other projects . this isn’t really a working set, but a default category that eclipse assigns to group unassigned projects.
- you can reorder working sets by dragging and dropping them anywhere.
- new projects can quickly be assigned to working sets by either dragging and dropping them onto the working set or right-clicking on the project and selecting assign working sets .
limitations: although working sets help you organise resources, any new resources won’t automatically be added to a working set, even if their parent already belongs to that working set . in our case, this means that any new project needs to be explicitly added to a working set, otherwise it will appear in the other projects category. normally you can do this on new project wizards, so watch out for these.
some good reasons why you should categorise your projects
now that you know how to group projects, you might be wondering why you should.
well, apart from just looking a lot cleaner and less cluttered, it also means that you can act on a group of projects at a time. for example, you can right-click on a working set in package explorer and open, close or refresh all projects in that working set. the same applies to team commands (nice for selective updates).
another reason is that you can now selectively search only those projects by telling eclipse to only search certain working sets. now you don’t have to pick up occurrences in test or scratchpad projects if you don’t want to. there are a host of other eclipse commands that act only on individual working sets (eg. build, problems, etc).
and the last reason is that now it’s a lot easier to navigate the package explorer with the keyboard. another reason to start learning eclipse keyboard shortcuts and also impress your colleagues.
Opinions expressed by DZone contributors are their own.
Comments