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.
The import manager is really nice. A very useful feature would be to have it import manage an entire project rather than just a file at a time.
Set target milestone to TBD
Changed version to "current" (previously it was 3.3.2).
Ideally we would like the 'Fix imports' action to be available for a package, a sources node and the entire project.
Probably something that would fit comfortably into the Jackpot UI, too.
A related requirement is to remove unused imports on the same scope (project, package, etc).
Note that there are students who are thinking about working on this project: http://netbeans.dzone.com/news/netbeans-platform-student-proj
*** Issue 150633 has been marked as a duplicate of this issue. ***
Created attachment 73022 [details] module containing the solution
I attached a module providing the requested feature. Please look over it and tell me what else I have to do to commit this to the NetBeans sources correctly.
CC-ing Tonda, Jaroslav, and David. Guys, one of the students has fixed this issue and has attached the patch above. Great, isn't it? Can the code be reviewed and more suggestions made to him?
Adding myself and Tonda to the cc.
Great! Ideas for improvements: -the reformat action block AWT (repainting) during reformatting the sources. This is not correct - the reformatting should run on background, and ideally there should be a progress dialog with Cancel. I might be a good idea to first gather all FileObjects that should be processed and then process them. -the current impl. of the action seem to allow reformatting only of one folder - might be better if it directly allowed reformatting of (one or more) Projects, SourceGroups, packages/folders and files, and maybe combinations of thereof. You may get some inspiration in contrib/javahints module, in BatchApply and BatchApplyAction classes: http://hg.netbeans.org/main/contrib/file/tip/javahints/src/org/netbeans/modules/javahints/batch/BatchApplyAction.java http://hg.netbeans.org/main/contrib/file/tip/javahints/src/org/netbeans/modules/javahints/batch/BatchApply.java -replace EditorCookie.saveDocument() with SaveCookie.save() (note that the SaveCookie is not be in the lookup if the file is not modified). -e.prinStackTrace()->org.openide.util.Exceptions.printStackTrace(e) -it would be good to clarify what should do the "fix all imports on package" action. Currently, if there will be several files with unresolved imports, it may cause several "Fix All Imports" dialogs (one for each file), which is probably not very good. Maybe the semantics should be "remove all unused imports"? -in JavaFixImportsAction you should keep the opened document in a local variable, otherwise it might get GCed prematurely. -might be good to implement the discovery process (finding files that should be modified) only once for both actions. -I personally do not like the Source submenu of the folders very much. I guess that the placement of the action should be discussed with HIE (adding jrojcek on CC). Also, if the "main UI elements" are going to be modified, there needs to be a UI review (before merging to trunk): http://wiki.netbeans.org/UIReviewProcess -it should be checked whether a new class(es) are loaded on startup - the performance team probably wouldn't like that.
I'm nearly finished with most of your points but I can't manage to add my menu to all file's (including projects etc.) contextual menues (yes, we can discuss this, but right now it seems to me the most natural way) - can you give me a hint on this?
I think there is a folder called "any", which applies to all folders and files, but I could be wrong. Have you solved the problem in the meantime?
For Projects use <folder name="Projects"> <folder name="Actions"> <file name="your-action.instance"> <attr name="position" intvalue="yourPosition"/> </file> </folder> </folder> for packages / folders use <folder name="Loaders"> <folder name="folder"> <folder name="any"> <folder name="Actions"> <file name="your-Action.instance"> <attr name="position" intvalue="yourPosition"/> </file> </folder> </folder> </folder> </folder>
Can this be integrated by jlahoda (or someone) even though the contributor hasn't completed it 100%? I.e., can't we do the few things that are left to do and integrate this code so that a really nice feature can be added (and a P2 solved and a student project integrated into the NetBeans sources)?
I still have a newer version than what is uploaded (just never managed to do the "correct" implementation into the menus & contacting the gui team et cetera.) - I will dig it up from my backups and post it here in the next days so that my sucessor will have less work. hope this helps & sorry for not finishing it myself, just can't find the time :/
Created attachment 89894 [details] most recent version
hi again, sorry it took so long. this should be my most recent version.
Although this can't be integrated now, will you have time Honzo to take a look at this after 6.8 is branched? Thanks!
Is it possible to add this feature for 6.10?
There are two new features in 7.1: organize imports (for one file, bug #183703) and Inspect and Refactor that allows to run Java editor hints on projects/folders. So I added a Configuration to this dialog that performs Organize Imports on selected scope: http://hg.netbeans.org/jet-main/rev/baa4ded890cb
Just curious: what happened to allowing code-format on multiple files (as implied by the title)?
Thanks for noticing that, I have created enhancement #201564 for reformatting whole project.
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/baa4ded890cb User: Jan Lahoda <jlahoda@netbeans.org> Log: #25377: adding Organize Imports configuration.