Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make eclipse (Indigo) collapse empty (parent) packages?

Tags:

eclipse

What I want to do is simply use the eclipse package explorer in hierarchical view but with empty packages being collapsed so I don't have to open 5+ packages to find the first Java file.

I'm not even sure how I did it in previous versions, but I've never had any trouble finding it before, it just seems to be gone now. I have a feeling there was a "flatten hierarchy" tick-box somewhere.

To clarify I get this:

com
  example
    etc
      file1.java

Rather than:

com.example.etc
  file1.java

I'm using Eclipse Indigo (v. 3.7.1)

Requested settings screenshot

like image 519
Thor84no Avatar asked Jan 18 '12 16:01

Thor84no


4 Answers

Open the View menu (small triangle in top right corner), open filters and check Empty parent packages.

In most cases it works, but in case of existing projects it does not always work as expected. If you seem to have troubles, try to export the project, remove it, then re-add the exported version (or re-checkout from your VCS).

like image 77
Zoltán Ujhelyi Avatar answered Nov 13 '22 03:11

Zoltán Ujhelyi


Assuming the view filter is engaged properly, perhaps your source folders are not as "empty" as you think.

For example, on Apple OS X, Eclipse will detect .DS_STORE entires along your src/package/hierarchy, making the parent packages technically non-empty.

Delete any such hidden files and refresh your project.

like image 34
Jonathan Drake Avatar answered Nov 13 '22 02:11

Jonathan Drake


Window - Preferences - Java - Appearance - Abbreviate package names

And enter the following rule:

com.example.etc={cee}

like image 2
JB Nizet Avatar answered Nov 13 '22 02:11

JB Nizet


I don't know what the problem actually was, but I couldn't get it fixed until I gave up altogether and reinstalled the OS (it was a fresh install anyway), and eclipse. It was completely fine after that. :\

like image 2
Thor84no Avatar answered Nov 13 '22 02:11

Thor84no