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 249179 - Browse... button when using @TemplateRegistration(requireProject = false) doesn't work
Summary: Browse... button when using @TemplateRegistration(requireProject = false) doe...
Status: NEW
Alias: None
Product: apisupport
Classification: Unclassified
Component: Templates (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Martin Kozeny
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-07 18:10 UTC by agoubard
Modified: 2015-06-03 16:24 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Example showing the absence of the dropdown (28.01 KB, image/png)
2014-12-11 23:05 UTC, agoubard
Details

Note You need to log in before you can comment on or make changes to this bug.
Description agoubard 2014-12-07 18:10:09 UTC
If you create a NetBeans RCP application with files registered as @TemplateRegistration(..., requireProject = false), the "New File..." offers the file but on the "Name and location" part of the wizard, the Browse... button to choose the directory doesn't work.

When you click on it nothing happens.

I think the problem is that it normally displays a popup to choose a directory based on the root directory of your project. Since in this case the application doesn't have a project, it fails (with no error).

I think the solution would be to show the JFileChooser (like in Open File... menu item) and filter to only show/select directories.

I have the problem in my project Joeffice (https://bitbucket.org/agoubard/joeffice/). I haven't pushed my changes yet.
I've noticed the same project in ANTLRWorks2 (https://github.com/tunnelvisionlabs/antlrworks2)
Comment 1 agoubard 2014-12-11 23:02:46 UTC
I've moved the bug to projects as it seems to be a bug in Project UI.

Here are more details.
The bug is (I think) in SimpleTargetChooserPanelGUI.java#505
In case of the project == null of the action listener for the button, it gets the value of the combobox and stop if the value is null.

Note that there is no combobox visible so the value is always null, so it never goes to the FileChooserBuilder. (See screenshot)

Old code:
                if (group == null) { // #161478
                    return;
                }
                FileObject oldFo = previousTargetFolder != null ? group.getRootFolder().getFileObject(previousTargetFolder) : group.getRootFolder();
                if (oldFo == null && previousTargetFolder != null) {
                    oldFo = FileUtil.toFileObject(FileUtil.normalizeFile(new File(previousTargetFolder)));
                }

New code should be 
                FileObject oldFo = null;
                if (group != null) { // #249179
                    oldFo = previousTargetFolder != null ? group.getRootFolder().getFileObject(previousTargetFolder) : group.getRootFolder();
                }
                if (oldFo == null && previousTargetFolder != null) {
                    oldFo = FileUtil.toFileObject(FileUtil.normalizeFile(new File(previousTargetFolder)));
                }
Comment 2 agoubard 2014-12-11 23:05:22 UTC
Created attachment 151056 [details]
Example showing the absence of the dropdown