use of com.android.tools.idea.templates.Template in project android by JetBrains.
the class RenderTemplateModel method renderTemplate.
private boolean renderTemplate(boolean dryRun, @NotNull Project project, @NotNull AndroidProjectPaths paths, @Nullable List<File> filesToOpen, @Nullable List<File> filesToReformat) {
final Template template = myTemplateHandle.getTemplate();
File moduleRoot = paths.getModuleRoot();
if (moduleRoot == null) {
return false;
}
// @formatter:off
final RenderingContext context = RenderingContext.Builder.newContext(template, project).withCommandName(myCommandName).withDryRun(dryRun).withShowErrors(true).withModuleRoot(paths.getModuleRoot()).withParams(myTemplateValues).intoOpenFiles(filesToOpen).intoTargetFiles(filesToReformat).build();
// @formatter:on
return template.render(context);
}
use of com.android.tools.idea.templates.Template in project android by JetBrains.
the class NewModuleModel method renderModule.
private boolean renderModule(boolean dryRun, @NotNull Map<String, Object> templateState, @NotNull Project project) {
File projectRoot = new File(project.getBasePath());
File moduleRoot = new File(projectRoot, myModuleName.get());
Template template = Template.createFromPath(myTemplateFile.getValue());
// @formatter:off
RenderingContext context = RenderingContext.Builder.newContext(template, project).withCommandName("New Module").withDryRun(dryRun).withShowErrors(true).withOutputRoot(projectRoot).withModuleRoot(moduleRoot).withParams(templateState).build();
// @formatter:on
return template.render(context);
}
use of com.android.tools.idea.templates.Template in project android by JetBrains.
the class NewFormFactorModulePath method renderActivity.
private boolean renderActivity(boolean dryRun, Map<String, Object> templateState, File projectRoot, File moduleRoot) {
TemplateEntry templateEntry = myState.get(KEY_SELECTED_TEMPLATE);
if (templateEntry == null) {
return true;
}
Template activityTemplate = templateEntry.getTemplate();
for (Parameter parameter : templateEntry.getMetadata().getParameters()) {
templateState.put(parameter.id, myState.get(myParameterStep.getParameterKey(parameter)));
}
RenderingContext activityContext = RenderingContext.Builder.newContext(activityTemplate, myWizard.getProject()).withCommandName("New Module").withDryRun(dryRun).withShowErrors(true).withOutputRoot(projectRoot).withModuleRoot(moduleRoot).withParams(templateState).withGradleSync(myGradleSyncIfNecessary).intoTargetFiles(myState.get(TARGET_FILES_KEY)).intoOpenFiles(myState.get(FILES_TO_OPEN_KEY)).intoDependencies(myState.get(DEPENDENCIES_KEY)).build();
return activityTemplate.render(activityContext);
}
use of com.android.tools.idea.templates.Template in project android by JetBrains.
the class NewFormFactorModulePath method renderModule.
private boolean renderModule(boolean dryRun, Map<String, Object> templateState, File projectRoot, File moduleRoot) {
Template template = Template.createFromPath(myTemplateFile);
// @formatter:off
RenderingContext context = RenderingContext.Builder.newContext(template, myWizard.getProject()).withCommandName("New Module").withDryRun(dryRun).withShowErrors(true).withOutputRoot(projectRoot).withModuleRoot(moduleRoot).withParams(templateState).withGradleSync(myGradleSyncIfNecessary).intoTargetFiles(myState.get(TARGET_FILES_KEY)).intoOpenFiles(myState.get(FILES_TO_OPEN_KEY)).intoDependencies(myState.get(DEPENDENCIES_KEY)).build();
// @formatter:on
return template.render(context);
}
use of com.android.tools.idea.templates.Template in project android by JetBrains.
the class ConfigureAndroidProjectPath method performFinishingOperation.
private boolean performFinishingOperation(boolean dryRun) {
Project project = getProject();
assert project != null;
Template projectTemplate = Template.createFromName(Template.CATEGORY_PROJECTS, WizardConstants.PROJECT_TEMPLATE_NAME);
// @formatter:off
final RenderingContext context = RenderingContext.Builder.newContext(projectTemplate, project).withCommandName("New Project").withDryRun(dryRun).withShowErrors(true).withParams(myState.flatten()).intoTargetFiles(myState.get(WizardConstants.TARGET_FILES_KEY)).build();
// @formatter:on
return projectTemplate.render(context);
}
Aggregations