mrcaramori
mrcaramori

Reputation: 2503

How to automatically expand empty packages in Eclipse with hierarchical presentation?

I have been often working on projects with huge namespaces on Eclipse. Since I think that hierarchical package presention seems more visually helpful, I have the issue of selecting every package until the core classes, for example:

-br
-br.com
-br.com.company
-br.com.company.server.core
-br.com.company.server.core.web.common
-br.com.company.server.core.web.common.Utils.java (yay!) 

Is there a way to automatically and recursivelly expand empty packages when using hierarchical package presentation?

So, when I click

+br

It would expand to:

-br
  -com
    -company
      -server
        -core
          -web
            -common
              +Utils.java

Upvotes: 4

Views: 1408

Answers (2)

steve
steve

Reputation: 21

For me, the hierarchical representation flattens multiple empty directories (e.g.: com.company.project) into one expandable and collapsible entry. The one trick I found that causes this to NOT be true (on OSX anyway) is that .DS_Store files will cause Eclipse to see the directory as "not empty". It then won't compress them into one entry. Removing these files (and any other hidden but present files in the directory) resolves this issue.

I can thus have com.company.project expandable with one click and all the packages appear hierarchically under it. It's a nice combination of the two views!

Upvotes: 2

Boris
Boris

Reputation: 7132

Use the "Project explorer" view and change the "Package Presentation" from "Flat" to "Hierarchical". You find this setting in the view's menu.

Upvotes: 1

Related Questions