Vala
Vala

Reputation: 5674

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

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

Upvotes: 6

Views: 5512

Answers (6)

Jonathan Drake
Jonathan Drake

Reputation: 51

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.

Upvotes: 5

Vala
Vala

Reputation: 5674

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. :\

Upvotes: 2

Has QUIT--Anony-Mousse
Has QUIT--Anony-Mousse

Reputation: 77495

Try to restart Eclipse once in a while. I had trouble getting it to work, and after an Eclipse restart it suddenly was working again.

Upvotes: 0

Zoltán Ujhelyi
Zoltán Ujhelyi

Reputation: 13858

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).

Upvotes: 7

JB Nizet
JB Nizet

Reputation: 692121

Window - Preferences - Java - Appearance - Abbreviate package names

And enter the following rule:

com.example.etc={cee}

Upvotes: 2

Baldrick
Baldrick

Reputation: 24350

Click on the arrow at the top right of the "Package explorer" and choose "Package presentation -> flat"

Upvotes: 1

Related Questions