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 256443 - Create class dialog creates class in default package when using pasted fully qualified class name
Summary: Create class dialog creates class in default package when using pasted fully ...
Status: RESOLVED WONTFIX
Alias: None
Product: ide
Classification: Unclassified
Component: Code (show other bugs)
Version: 8.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: issues@ide
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-08 00:20 UTC by mclaborn
Modified: 2015-11-10 16:04 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mclaborn 2015-11-08 00:20:17 UTC
Product Version = NetBeans IDE 8.1 (Build 201510222201)
Operating System = Linux version 3.13.0-67-generic running on amd64
Java; VM; Vendor = 1.8.0_51
Runtime = Java HotSpot(TM) 64-Bit Server VM 25.51-b03

Reproducibility: Happens every time

STEPS:
- In project view, right click on a package name that is not the default package and choose New -> Java Class
- In the class name field paste in a fully qualified class name (e.g. com.mitchclaborn.gf.lib.ClientCustomerFlagDef.Cache)
- Manipulate the new class name so that it is not fully qualified (e.g. ClientCustomerFlagDefCache)
- Click Finish to create the class

ACTUAL:
- The dialog shows the warning "Warning: It is highly recommended that you do not place Java classes in the default package
- The new class is created in the default package

EXPECTED:
- Should not show warning
- Class should be created in the correct package
Comment 1 Jiri Prox 2015-11-10 15:37:29 UTC
The class is created in the package specified in the wizard - e.g. default package, since after the manipulation the Package field is empty.

This behavior is IMHO correct. The user has full control of the package.
Comment 2 mclaborn 2015-11-10 16:04:27 UTC
Here is a more detailed example.  

1. Right click on the package node
2. new -> Java class
3. Paste in name of com.mitchclaborn.gf.app.CustomerFunctions.Fred  (Fred is an inner class)
4. The package name field below is disabled
5. Change name to com.mitchclaborn.gf.app.CustomerFunctionsFred  (remove the last dot)
6. Package name field is still disabled
7. Change the name to CustomerFunctionsFred
8. The package field is blanked out and enabled

Step 8 is where the problem is.  This same behaviour is evident any time there is something that looks like a package name that is then removed. 

I understand the problem in handling this situation in the dialog.  The only way I can think of to solve it would be to add a checkbox or similar that would "lock" the package field so that manipulations to the class name would not automatically affect the package input. This checkbox could be checked by default when the dialog is invoked from a right click on a package node. 

This seems like a lot of work for a very infrequent situation. I'll close this.