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 239243 - [Rename] Add option to rename subpackages
Summary: [Rename] Add option to rename subpackages
Status: REOPENED
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.4
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: Ralph Ruijs
URL: https://sourceforge.net/projects/zdfm...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-08 15:37 UTC by luigiusai
Modified: 2015-07-29 23:58 UTC (History)
2 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
IDE log (51.56 KB, text/plain)
2013-12-08 15:37 UTC, luigiusai
Details
Screenshots of the bug (633.27 KB, application/zip)
2013-12-11 15:45 UTC, luigiusai
Details

Note You need to log in before you can comment on or make changes to this bug.
Description luigiusai 2013-12-08 15:37:03 UTC
Product Version = NetBeans IDE 7.4 (Build 201310111528)
Operating System = Linux version 3.2.0-38-generic running on amd64
Java; VM; Vendor = 1.7.0_45
Runtime = Java HotSpot(TM) 64-Bit Server VM 24.45-b08

Hi, I am Luigi Usai, from Verona University, Italy.
Procedure for recreating the bug:

1) I have a project, let's suppose Mediathek View
https://sourceforge.net/projects/zdfmediathk/?source=navbar

2) I want to refactor the projct calling it MultimediaOnline instead of Mediathek

3) While refactoring the project, Netbeans 7.4 create a new directory and moves the .java files inside, 
but not the other subdirectories.

4) this way, the project stops compiling, signalling there are missing res files (from the /res/ directory, which still is on the previous place)

Copying 1 file to /home/studente/src/MultimediaOnline/build/classes
compile:
run:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at javax.swing.ImageIcon.<init>(ImageIcon.java:205)
	at mediathekview.MediathekGui.initComponents(MediathekGui.java:1231)
	at mediathekview.MediathekGui.<init>(MediathekGui.java:211)
	at mediathekview.Main$1.run(Main.java:94)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
	at java.awt.EventQueue.access$200(EventQueue.java:103)
	at java.awt.EventQueue$3.run(EventQueue.java:694)
	at java.awt.EventQueue$3.run(EventQueue.java:692)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
BUILD SUCCESSFUL (total time: 2 seconds)
Comment 1 luigiusai 2013-12-08 15:37:08 UTC
Created attachment 142946 [details]
IDE log
Comment 2 Jiri Prox 2013-12-11 12:31:08 UTC
Sorry but I cannot reproduce the wrong behavior with the sources downloaded from source forge. 

Can you provide your project?
Comment 3 luigiusai 2013-12-11 15:43:57 UTC
Hi.
Yes, I can provide 2 things:

1) my sources:

at this page:
https://sourceforge.net/projects/learngermanwithmovies/files/latest/download

the version 0.0.0.3.zip.

2) the screenshot of the bug:

http://sourceforge.net/projects/learngermanwithmovies/files/screenshotOfTheBug.zip/download

Let me know if you need more specifications about it.

Best regards
Luigi
Comment 4 luigiusai 2013-12-11 15:45:51 UTC
Created attachment 143070 [details]
Screenshots of the bug

I add you the screenshots of how to replicate the bug.
Comment 5 Jiri Prox 2013-12-11 16:13:19 UTC
Thanks, I can see the problem now


Summary:
When renaming package "mediathek" all references to resources in package "mediathek.res" generated by from editor are also changed although the subpackage was not renamed 

e.g.: getClass().getResource("/mediathek/res/film_rec_16.png") is changed to
getClass().getResource("/mediathekRenamed/res/film_rec_16.png")
Comment 6 Tomas Pavek 2013-12-11 18:13:43 UTC
Maybe I do not understand it, but it seems to me the reporter actually wants to rename the whole tree, complaining that NB creates a new directory "and moves the .java files inside, but not the other subdirectories". In this sense the GUI builder renamed the resources well (as what was expected), the problem is that the rest of refactoring did not rename everything.

Can you advise how to do the whole dir rename?
Comment 7 luigiusai 2013-12-23 18:44:42 UTC
Tomas Pavek, you are right.
Let's suppose I have:

com.mathemathics.geometry.cirle;
com.mathemathics.geometry.square;

the node "geometry" is a directory containing java classes.
If NB renames only one package, software stops compiling.
This behaviour is an error.

IMHO, NB should rename each node "geometry".
Thank you.
Comment 8 Ralph Ruijs 2013-12-24 11:30:43 UTC
In java there is no notion of subpackages. Renaming a folder is done through the files view.
Comment 9 luigiusai 2013-12-24 11:52:51 UTC
I'm sorry if I must reopen this bug. I'm going to explain why.

Source of information is this book: Ken Arnold, James Gosling, David Holmes, The Java Programming Language, Fourth Edition, Addison-Wesley Professional, 2005, ISBN 0-321-34980-6; James ...

James Gosling invented Java, so I think you'll trust him. ;)

In the Italian third edition of this book, chapter 20.9, they teach the Java Subpackages.

Please I ask you to reconsider this bug for the sake of Netbeans.
Comment 10 luigiusai 2013-12-24 12:04:41 UTC
If this can be useful, you can look here for detailed info:

https://www.google.it/search?tbm=bks&hl=it&q=java+manuale+ufficiale+subpackage#hl=it&q=java+subpackage&tbm=bks

I searched over the internet for your sentence:

"in java there's no notion of subpackage"

I got about 473.000 results (0,59 seconds)

It's very sad, because it means that online there's lot of people talking without knowledge. Sometimes internet is not trustable, unless you do a deeper search.
Thank you all, programmers.
Comment 11 Ralph Ruijs 2013-12-26 12:21:54 UTC
(In reply to luigiusai from comment #9)
> I'm sorry if I must reopen this bug. I'm going to explain why.

You are right. We can add an option to rename subpackages when renaming a package.
Comment 12 luigiusai 2015-07-29 23:58:15 UTC
Tested on 
NetBeans IDE 8.0.2
Windows 8 version, 64 bit

the problem still exists in the last Netbeans version.

Let's make a simple example:

create a new project with the Netbeans from samples:
Samples --> JavaFX --> BrickBreaker

Now refactor the main program name

refactor BrickBreaker --> newProgramName;

this command should rename both the main program AND all the subpackages.

This first bug generate a second bug: if you try to restore the original name, Netbeans says "The package already exists" and user get stuck.

There are two bugs in one.

More info and screenshots here:
https://plus.google.com/+LuigiUsai/posts/CvsAoDg1fHh

Best regards and thank you all for your efforts to build a better tool.

Luigi, Verona
www.luigiusai.it