Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Package or folder icon?
Package or folder icon? [message #1749196] Fri, 02 December 2016 22:07 Go to next message
Chris Barlock is currently offline Chris BarlockFriend
Messages: 32
Registered: July 2009
Member
We have a number of folders in the src tree of a project that have the "package" icon next to the folder name, but they are not really Java package folders -- just plain folders. I expect they got that way from copy/paste over the years. What is it that tells the Package Explorer to use the package icon rather than the "plain folder" icon? The properties for either says that the resource is of type "Folder".

Thanks,

Chris
Re: Package or folder icon? [message #1749197 is a reply to message #1749196] Fri, 02 December 2016 22:45 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Any folder inside a source folder is potentially a package.

It's not shown as that when the source folder has an exclusion filter of "**".

Additionally, the package icon is greyed out, when the package contains no .java files. This is what JLS would call an unobservable package (s.t. like a ghost package Smile ).

OTOH, creating a package is nothing else then creating a folder (plus perhaps placing package-info.java into it).

Finally, "Folder" is what the Eclipse Platform sees, only JDT will then consider some folders as packages.

Confused? Smile


Do you have specific reasons why the package icon worries you?
Re: Package or folder icon? [message #1749201 is a reply to message #1749197] Sat, 03 December 2016 01:04 Go to previous messageGo to next message
Chris Barlock is currently offline Chris BarlockFriend
Messages: 32
Registered: July 2009
Member
Yes, confused. I checked a "plain folder," a "package folder" and a "package folder with no .java files." None of them have any filters defined in Properties > Resource > Resource Filters. The question came up because I did New > Folder for some files that were not .java. The folder was ordered after all the "package folders" in the Package Explorer. I'm OK with that -- but I have this whole collection of "package folders" that have nothing to do with Java files. I don't want this one, new folder ordered differently than all the rest of the package folders that don't have any .java files.

Based on the information in your response, Stephan, I think I'd like to "reconfigure" the non-package folders to appear that way in Package Explorer -- but unclear to me how to do that.
Re: Package or folder icon? [message #1749217 is a reply to message #1749201] Sat, 03 December 2016 12:27 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
First let me repeat: "Do you have specific reasons why the package icon worries you?"

This distinction should in no way affect the functionality of the IDE.

The filter I spoke of is configured via the Java Build Path configuration in tab Source.
The idea here is to select which resources will be copied to your output folder (typically "bin", or "target/classes").

OK, here's one thing I can reproduce: If inside a source folder you create a folder with a name that is not a legal name for a Java package, then the folder is shown as folder, not package. And this makes perfect sense, because JDT can see that this will never legally be used as a package. For folders with a name that is legal as a package name, the tool cannot guess what you want to use it for, so when inside a source folder we assume : "package".

Finally: there is no secret property where we record that a folder is a package - on disk it's just a folder. All this is only how the physical structure is represented in the IDE.

Ergo: just don't worry about the icon, but if you still want to force a folder to be shown as a plain folder, not a package, give it a name that is illegal in Java (use any special character like "-", "." etc...)
Re: Package or folder icon? [message #1749237 is a reply to message #1749217] Sat, 03 December 2016 21:16 Go to previous message
Chris Barlock is currently offline Chris BarlockFriend
Messages: 32
Registered: July 2009
Member
Stephan, it was not the icon that bothered me, it was the sort order. In fact, the folder had a "-" in the name and it sorted below all of the other folders, out of alphabetical order. Thanks for the explanation.
Previous Topic:Java Content Assist automatically inserts nonsens
Next Topic:Unable to import gradle project
Goto Forum:
  


Current Time: Tue Apr 23 13:21:12 GMT 2024

Powered by FUDForum. Page generated in 0.03374 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top