This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 187098 - Can't create parent packages after child packages have been created.
Summary: Can't create parent packages after child packages have been created.
Status: REOPENED
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords:
: 201115 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-06-02 17:07 UTC by jonescb
Modified: 2011-08-23 19:21 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jonescb 2010-06-02 17:07:17 UTC
I believe I've found a bug in the way Netbeans 6.8 creates packages for Java.

I had an existing project, and I started creating Unit Tests.  I created a new source directory for the tests.  The package names of my production code were in this form: com.foo.bar, and com.foo.bar.baz.  And my unit tests packages were test.com.foo.bar and test.com.foo.bar.baz.

I started creating tests for classes in no particular order, so I ended up creating test.foo.bar.baz before test.foo.bar.  So when I needed to create the latter, the dialog for creating new packages told me the package already existed, and wouldn't let me proceed.  Technically yes it did exist, but Netbeans wouldn't add it to my project so I could work with it.

I had to shut down Netbeans, and put the .java file into my_project/testsrc/test/com/foo/bar/ and restart Netbeans to get the package to show up.

I don't know if this matters, but the project is a free-form type.  And I haven't tested this in Netbeans 6.9-dev

So just to make sure everything is clear, the problem is that Netbeans won't let you create packages that are parents to existing packages.

I might be able to put together a patch for this later as it seems simple enough.
Comment 1 Tomas Zezula 2010-06-21 12:19:44 UTC
You don't have to create the existing package. When you need to create a file in it just type the package name (or select a child package and delete the child part of the name) in the new (Class|File) wizard and the package will appear. The IDE shows only non empty packages, when the package will contain a file it will be shown. You can also switch the package view to the folder view by View Java Packages As action in the Project's View.
Comment 2 jonescb 2010-06-21 18:04:00 UTC
You are correct that entering the package name in the New Class Wizard works, however when a new package is created via the New Package wizard, the package is shown even though it's empty.  You stated that empty packages aren't shown, but they are.

So the wizard should not say that the package already exists.  It should simply make the non-visible package visible.  And it would be greyed out like any other empty package created by the Wizard.

Yes, there are workarounds.  But using the New Package wizard is an obvious choice for most users for making new packages, and it shouldn't show errors for something that it can easily work around.

It isn't broken functionality, but I think by implementing this it would create a better user experience.  By closing this as wontfix you're essentially saying that all users should be aware of semi-obscure workarounds, even if it isn't what would first come to mind.
Comment 3 Tomas Zezula 2010-06-21 19:20:05 UTC
>You stated that empty packages aren't shown, but they are.
Sorry, I've meant non leaf packages.
>By closing this as wontfix you're essentially saying that all users should be aware of semi-obscure >workarounds, even if it isn't what would first come to mind.
I don't think that the workarounds are obscure. You specify the non leaf package in the wizard and when it contains a file IDE will split it. I agree that the error message is strange and should be changed.
Splitting the package by new package wizard is also possible but it may slowdown and complicate the PackageViewChildren. Also what should happen after IDE restart when only package was created but it's still empty? Should it be persistent? This will slow down the package view even more.
But I can reopen it as an ENHANCEMENT when more users complain about this.
Comment 4 jonescb 2010-06-21 21:13:11 UTC
For the persistence issue, I don't think it needs to be persistent.  If Netbeans gets restarted the worst case scenario is that the user needs to run through the Wizard again, which AFAIK shouldn't duplicate anything.

However, it might create bug reports like "Where did my package go?"

Just my workflow is that I create a package when needed using the package wizard, then I immediately put a class in it by right clicking the new package and select New Java Class.  But when I couldn't get the package to be visible (and right clickable), I didn't really know what to do.
Comment 5 Jan Lahoda 2011-08-23 19:21:22 UTC
*** Bug 201115 has been marked as a duplicate of this bug. ***