Creating a hierarchical package tree when creating a class [duplicate] - java

OK here's what I would like: in the Eclipse package explorer, I see the following: (dot represents a clickable arrow that I can use to expand the folder)
PROJECT
Source Folder
Package
Class Package.SubPackageFooBarPackage.OtherSubPackagePackage.OtherSubPackage.VerySubPackage
OtherPackage Foobar OtherPackage.SubPackage
Baz
Long story short, I want to have many packages, each with many subpackages, in a source folder (and several source folders, so making more won't solve the problem)--so on the order of a couple hundred packages per source folder--ten to twenty packages each with fifteen subpackages. Therefore, I want the hierarchy to look like this:
PROJECT
Source Folder
Package
Class
Package.SubPackage
Foo
BarPackage.OtherSubPackagePackage.OtherSubPackage.VerySubPackage
OtherPackage Foobar
OtherPackage.SubPackage
Baz
so I can open or close a package and see a list of subpackages instead of having package and subpackage all at the same level in the hierarchy--which again makes far too many packages simultaneously displayed. Note this is not a question about filesystem; the file system works fine as far as I can tell--it is only a question about the visual display in the Eclipse package explorer.
So: is there a way to add levels to the hierarchy? Thanks!! (Eclipse Helios on OS X 10.6)

Package Explorer / View Menu / Package Presentation... / Hierarchical
The "View Menu" can be opened with Ctrl + F10, or the small arrow-down icon in the top-right corner of the Package Explorer.

Here is representation of screen eclipse to make hierarachical.

For Eclipse in Macbook it is just 2 click process:
Click on view menu (3 dot symbol) in package explorer -> hover over package presentation -> Click on Hierarchical

Related

Eclipse doesns't show project explorer properly

I'm using eclipse neon. I have created a maven project and create a package com.prueba.account and then I have created many packages inside.
But eclipse shows me all packages as an independent project and without the full path like in the image. Notice that checking package is inside com.prueba.account
Just Click on the Drop Down in Project explorer. All you need is to change Package presentation from Hierarchical to Flat.
Hope it helps !!!!
First of all, welcome to Stack Overflow Gary.
Then to extend on Adyas Answer:
In Eclipse there are two ways to display the package-structure.
Hierarchical :
And Flat:
I personally find the Hierarchical view way more convenient, for when you're working on a bigger project, you often get really long package names which, when in Flat view, might clutter the whole window.
But in the end, it's up to your personal taste.
The way to change between this two modes is to click on the down arrow icon at the top of the Project Explorer and under Package Presentation you can choose between the two.

View Package Dependencies in Eclipse

Is there any way to view package dependencies in Eclipse? I seem to remember a long time ago that it was possible. I have a packageX and want to see what packages refer to it. Ie packageY references it, but not packageZ.
There seem to be some outdated plugins out there, for example Java Dependency Viewer, but the comments for the plugin say 'don't bother'.
If you mean a java package, there is a possibility: You right-click the package in the project explorer, select References → Workspace and get ... a list of almost no results.
Then you go into the search menu (the small triangle ▿ at the top right border of the search view), select "filters" and uncheck the "imports" box. Then all references to your package within your workspace should appear in the view.

How to fix package names in IntelliJ?

Is it possible to fix all the package names in a given folder in IntelliJ?
If files are manually imported into IntelliJ, and their package names are all wrong (including the sub-folders), how can I mass fix the package names?
This has caused me a lot of grief so far....
moving to a package or renaming a package
This has to be a bug.
Example:
If I am on a package in the project explorer, and rename the package, say it is:
com.example.xml.xml
Now I want to change this (and all the files under it) to:
com.example.xml
I can't seem to do it!
When it says "rename package com.example.xml.xml to":
If I enter "com.example.xml" it won't work. I'm not sure what it is going on, I have spent a over an hour trying this as I have more files to import/fix.
It seems you can't change a full package name like this one: "com.example.xml.xml", but you can change each fragment, for that you can go to "View Options" (a little wheel) in the project view, disable "compact empty middle packages" options, and do something like renaming the second "xml" from the end, so the final package could get into something like:
com
-example
-bar
-xml
Then you can drag and drop all contents in the last "xml" to "bar" package and finally delete the last "xml". In your case it seems you won't need to rename the package just move the contents
In project view change layout to Flatten packages. Then in same menu unselect Hide empty middle packages. Then create the new package you want. And then using drag'n'drop move the root package which contains your code to a newly created package (when the pop-up appears, select the second option, i.e. move everything ...). Delete old, unused packages

White package icons in my Eclipse's package explorer

I am getting these strange white package icons in my testing project. From what I've seen # http://jamie.ideasasylum.com/images/icons.pdf, they signal "empty packages", but I don't know why.
My src/ folder is set is includedin the build path, so I don't get what the problem might be:
Thanks
This is most likely because you have chosen hierarchical package views. The hierarchical package view will show empty package icons for packages without any classes.
Switching to flat package views will allow Eclipse to display only packages that have classes in them.
Create at least one class in the 'empty' package 'white package' and refresh the project, the color should change to Golden.
When Package does not contain any class, then the color is white.

Project Directory Structure Problem in Eclipse

I am facing this weird problem ..When i checked out project from svn my whole project was in directory kind of structure
ie. my package was like (folder inside another folder)
MainProject
+
+
+++project_1_name
++++++++src
++++++++++++com
++++++++++++++companyname
++++++++++++++++++ClassName
+
+++project_2_name
++++++++src
++++++++++++com
++++++++++++++companyname
++++++++++++++++++ClassName
but i want it to be like
MainProject
+
project_1_name
+++++src.com.companyname.className
project_2_name
+++++src.com.companyname.className
when i am importing a particular sub project from the main project separately on my workspace then the project is appearing as package structure as i see..I am using eclipse for the first time ..Kindly pardon me for asking some thing stupid like this ..But please help me
thanks in advance
The structure/folder hierarchy is as expected, a java package is a folder.
In Eclipse, Package Explorer, click on a small arrow-like icon pointing downwards and select Package Presentation 'Flat' or 'Hierarchical'.
Possibly you would like to have 'Flat'.
Do you mean you want the Package Explorer view instead of the Navigator view?
Window > Show View > Package Explorer
Or maybe you want the Project Explorer view:
Window > Show View > Project Explorer
Either of those views has a "flat" and a "hierarchical" package style. The "flat" package style sounds like what you want.
When you import projects from SVN, after selecting the base url, you should check the "find projects in the children of the selected resource" box.

Categories