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 216949 - Save as template ignores source roots for project from existing sources
Summary: Save as template ignores source roots for project from existing sources
Status: VERIFIED FIXED
Alias: None
Product: web
Classification: Unclassified
Component: HTML Project (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-16 07:42 UTC by Jiri Skrivanek
Modified: 2012-11-09 08:04 UTC (History)
1 user (show)

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 Jiri Skrivanek 2012-08-16 07:42:07 UTC
It is not possible to save project from existing sources as template. To reproduce:

- create HTML5 project
- add some html and JavaScript files
- open new project wizard
- select "HTML/JavaScript|HTML Application with Existing Sources" and click Next
- browse for site root from previously created project
- provide project name and empty folder as project directory
- finish wizard
- right-click project node and choose "Save as Template"
- only project root node is offered but not sources

Product Version: NetBeans IDE Dev (Build EaselCSS-504-on-20120815)
Java: 1.7.0_06; Java HotSpot(TM) 64-Bit Server VM 23.2-b09
System: Windows 7 version 6.1 running on amd64; Cp1250; en_US (nb)
Comment 1 Tomas Mysik 2012-10-19 08:59:25 UTC
Will have a look at it.
Comment 2 Tomas Mysik 2012-10-19 09:04:37 UTC
BTW likely related, issue #216642, comment #3:

> Other problem I can imagine is when Site Root is specified outside of Project
> Folder - Save as Template will likely fail to offer Site Root files.

The question is - what to do with the external Site Root? The proper fix would likely be to add it to the archive and after unpacking, move it to the original location.
Comment 3 David Konecny 2012-10-22 20:45:00 UTC
(In reply to comment #2)
> The question is - what to do with the external Site Root? The proper fix would
> likely be to add it to the archive and after unpacking, move it to the original
> location.

I would not worry about "original location". Let's keep it simple. Project template is just a template, that is list of initial files in a single project directory. If a template is created from external site root that's fine but resulting template will have these sources directly under its "public_html" folder.
Comment 4 Tomas Mysik 2012-10-23 08:01:22 UTC
OK, agreed, will look at it.
Comment 5 Tomas Mysik 2012-11-07 12:26:53 UTC
Davide, is there an easy way to do this? I tried it but no success yet, moreover the patch is _very_ ugly so far. Sorry for asking, I do not understand well all these Children, Keys, etc.

Thanks for any hint.
Comment 6 David Konecny 2012-11-07 22:32:48 UTC
Old APIs like Nodes are awful to use - I never know how to use them either. FilterNode.Children sounds like a class to filter children yet Javadoc says that class is not well suited for that??? Anyway, I fixed it the best way I could imagine. Have a look. It will need to be re-tested so thanks in advance Jirka. c8a89dbdae91
Comment 7 Tomas Mysik 2012-11-08 06:56:17 UTC
Thanks a lot Davide! I just tried it and there are still couple of things to do:
- proper relative path in ZIP [1]
- proper Site Root value in netbeans-project.properties file

I will fix that.

[1]
java.lang.NullPointerException
	at java.util.zip.ZipEntry.<init>(ZipEntry.java:56)
	at org.netbeans.modules.web.clientproject.ui.wizard.CreateSiteTemplate.writeChildren(CreateSiteTemplate.java:712)
Comment 8 Tomas Mysik 2012-11-08 07:26:13 UTC
Now it should be fixed. Not nice but works...

http://hg.netbeans.org/web-main/rev/a35ea9bfb500
Comment 9 David Konecny 2012-11-08 19:25:58 UTC
Gosh! I forgot to test creation of a template - sorry about that; that just could not work. :-) Thanks for finishing it.
Comment 10 Quality Engineering 2012-11-09 02:52:47 UTC
Integrated into 'main-golden', will be available in build *201211090001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/c8a89dbdae91
User: David Konecny <dkonecny@netbeans.org>
Log: #216949 - Save as template ignores source roots for project from existing sources
Comment 11 Tomas Mysik 2012-11-09 05:13:56 UTC
(In reply to comment #9)
> Gosh! I forgot to test creation of a template - sorry about that; that just
> could not work. :-) Thanks for finishing it.

No problem, it was easy (not nice, but easy ;).