Java Code Examples for org.netbeans.api.templates.FileBuilder#build()

The following examples show how to use org.netbeans.api.templates.FileBuilder#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SnippetClassGenerator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "EXC_UnexpectedTemplateContents=Unexpected plain class template contents",
    "EXC_ShellTemplateMissing=Unexpected plain class template contents"
})
private FileObject createJavaFile() throws IOException {
    FileObject template = FileUtil.getConfigFile("Templates/Classes/ShellClass.java"); // NOI18N
    if (template == null) {
        throw new IOException(Bundle.EXC_ShellTemplateMissing());
    }
    FileBuilder builder = new FileBuilder(template, targetFolder);
    builder.name(className);
    builder.param("executables", executableContent.toString());
    builder.param("declaratives", declarativeConent.toString());
    
    Collection<FileObject> l = builder.build();
    if (l.size() != 1) {
        throw new IOException(Bundle.EXC_UnexpectedTemplateContents());
    }
    return l.iterator().next();
}
 
Example 2
Source File: InjectSpringBootGenerator.java    From nb-springboot with Apache License 2.0 6 votes vote down vote up
private void createNbActions(FileObject dir) throws IOException {
    if (dir == null) {
        return;
    }
    // retrieve default options from prefs
    final Preferences prefs = NbPreferences.forModule(PrefConstants.class);
    final boolean bForceColor = prefs.getBoolean(PrefConstants.PREF_FORCE_COLOR_OUTPUT, true);
    final boolean bManualRestart = prefs.getBoolean(PrefConstants.PREF_MANUAL_RESTART, false);
    final String strVmOpts = Utils.vmOptsFromPrefs();
    // use template file from Initializr Spring Boot wizard
    FileObject foTmpl = FileUtil.getConfigFile("/Templates/Project/Maven2/initializr-nbactions.xml");
    FileBuilder fb = new FileBuilder(foTmpl, dir)
            .name("nbactions")
            .param("forceColor", bForceColor)
            .param("manualRestart", bManualRestart)
            .param("isBoot2", BasicProjectWizardIterator.BOOTVERSION.startsWith("2"))
            .param("vmOpts", strVmOpts);
    fb.build();
}