JavaScript Libraries in NetBeans
Introduction
For background, see
3rd bullet "Components" in AJAX Features
In response to the requirements for handling JavaScript Libraries as described in the above document, we need to provide mainly:
- the ability to register and manage JavaScript Libraries so that they can be accessible globally inside the IDE
- the ability to consume these libraries in different projects
- the packaging of some external libraries
Project Plan
Registering & Managing Libraries
To be consistent with how NetBeans has been managing libraries, the most desirable approach would be to leverage the Libraries Manager infrastructure for registering and managing javascript libraries. This would require defining a new "javascript" library type and its volumes. Here are the current volume types:
- classpath (to be removed after J1)
- scriptpath
- (more will be defined after J1)
For more info on the Library Manager framework, see http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-project-libraries/org/netbeans/api/project/libraries/package-summary.html.
Libraries can be pre-packaged. If they get installed, they will be registered automatically in the IDE and can be found under 'JavaScript Libraries' node in the Library Manager window:
Alternatively, a library can also be registered in the IDE at any time using the New Library... option in the Library Manager:
Consuming the libraries in projects
(To be completed after the JavaOne deliverable below)
Packaging the 3rd-party JavaScript Libraries
Each of the JavaScript Libraries can be individually wrapped in a NB plugin module. The structure is similar to web.libraries.jsf1102 as an example. Each contains a library definition so that it can registered in the IDE.
JavaOne deliverable
Since the ability to add 3rd party JavaScript libraries into NB projects is needed to be demoed at J1 and it should run on NB 6.1 without any modification to this release, a new 'Add JavaScript Libraries to Project' dialog is implemented to add the libraries to the projects to avoid making any modifications to the NB project system:
To bring up the above dialog, select Tools -> Add JavaScript Libraries to Project:
The functionality of the Dialog behaves as what is described in this document with the exception that the libraries can be registered in the IDE using NB Library Manager. The libraries' "scriptpath" volumes will be extracted into a subfolder relative to the selected project location:
- For web project, the default copy-to location is "/web/resources"
- For ruby project, the default copy-to location is "/public/resource"
- For php project, the default copy-to location is "/web/resources"
- For all other projects, it is "/javascript/resources"
If there is no project open, the following will be presented:
If the destination folder is not empty, the libraries will not be extracted unless the user specifically selects the Overwrite option.
Sources
- Module names:
- javascript.libraries: This contains all the JavaScript Library support including creation of the JavaScript library type and its volumes, api, UI/Wizard support the creation of the libraries themselves.
- javascript.toolkit.woodstock: pre-packaged Woodstock widget library and its library definition
- Repository: The new modules will be checked into http://hg.netbeans.org/main/contrib repository initially and will be moved to http://hg.netbeans.org/main repository later (after J1).
- Migration to NB 6.5:
- As the user project with these JavaScript artifacts gets migrated into a newer version of NB, the extracted javascript libraries will continue to be in the projects as files in the project directory. If needed to uninstall, the user will remove the files manually.