use of com.android.tools.idea.templates.TemplateManager in project android by JetBrains.
the class ChooseTemplateStep method getTemplateList.
/**
* Search the given folder for a list of templates and populate the display list.
*/
protected static List<MetadataListItem> getTemplateList(TemplateWizardState state, String templateFolder, @Nullable Set<String> excluded) {
TemplateManager manager = TemplateManager.getInstance();
List<File> templates = manager.getTemplates(templateFolder);
return getTemplateList(state, templates, excluded);
}
use of com.android.tools.idea.templates.TemplateManager in project android by JetBrains.
the class NewFormFactorModulePath method getAvailableFormFactorModulePaths.
public static List<NewFormFactorModulePath> getAvailableFormFactorModulePaths(@NotNull Disposable disposable) {
TemplateManager manager = TemplateManager.getInstance();
List<File> applicationTemplates = manager.getTemplatesInCategory(Template.CATEGORY_APPLICATION);
List<NewFormFactorModulePath> toReturn = Lists.newArrayList();
for (File templateFile : applicationTemplates) {
TemplateMetadata metadata = manager.getTemplateMetadata(templateFile);
if (metadata == null || metadata.getFormFactor() == null) {
continue;
}
FormFactor formFactor = FormFactor.get(metadata.getFormFactor());
if (formFactor == FormFactor.GLASS && !AndroidSdkUtils.isGlassInstalled()) {
// Only show Glass if you've already installed the SDK
continue;
}
NewFormFactorModulePath path = new NewFormFactorModulePath(formFactor, templateFile, disposable);
toReturn.add(path);
}
Collections.sort(toReturn, (p1, p2) -> p1.myFormFactor.compareTo(p2.myFormFactor));
return toReturn;
}
use of com.android.tools.idea.templates.TemplateManager in project android by JetBrains.
the class ImportSourceModulePath method createImportTemplateWithCustomName.
@NotNull
protected static MetadataListItem createImportTemplateWithCustomName(@NotNull final String importTemplateName, @Nullable final String description) {
// Now, we're going to add in two pointers to the same template
File moduleTemplate = new File(TemplateManager.getTemplateRootFolder(), FileUtil.join(Template.CATEGORY_PROJECTS, "ImportExistingProject"));
TemplateManager manager = TemplateManager.getInstance();
TemplateMetadata metadata = manager.getTemplateMetadata(moduleTemplate);
assert metadata != null;
return new MetadataListItem(moduleTemplate, metadata) {
@Override
public String toString() {
return importTemplateName;
}
@Nullable
@Override
public String getDescription() {
return description == null ? super.getDescription() : description;
}
};
}
use of com.android.tools.idea.templates.TemplateManager in project android by JetBrains.
the class NewAndroidModuleDescriptionProvider method getDescriptions.
@Override
public Collection<ModuleTemplateGalleryEntry> getDescriptions() {
ArrayList<ModuleTemplateGalleryEntry> res = new ArrayList<>();
TemplateManager manager = TemplateManager.getInstance();
List<File> applicationTemplates = manager.getTemplatesInCategory(Template.CATEGORY_APPLICATION);
for (File templateFile : applicationTemplates) {
TemplateMetadata metadata = manager.getTemplateMetadata(templateFile);
if (metadata == null || metadata.getFormFactor() == null) {
continue;
}
int minSdk = metadata.getMinSdk();
FormFactor formFactor = FormFactor.get(metadata.getFormFactor());
if (formFactor == FormFactor.CAR) {
// Auto is not a standalone module (but rather a modification to a mobile module)
} else if (formFactor == FormFactor.GLASS && !AndroidSdkUtils.isGlassInstalled()) {
// Hidden if not installed
} else if (formFactor.equals(FormFactor.MOBILE)) {
res.add(new AndroidModuleTemplateGalleryEntry(templateFile, formFactor, minSdk, false, AndroidIcons.ModuleTemplates.Mobile, message("android.wizard.module.new.mobile"), metadata.getTitle()));
res.add(new AndroidModuleTemplateGalleryEntry(templateFile, formFactor, minSdk, true, AndroidIcons.ModuleTemplates.Android, message("android.wizard.module.new.library"), metadata.getDescription()));
} else {
res.add(new AndroidModuleTemplateGalleryEntry(templateFile, formFactor, minSdk, false, getModuleTypeIcon(formFactor), metadata.getTitle(), metadata.getDescription()));
}
}
return res;
}
use of com.android.tools.idea.templates.TemplateManager in project android by JetBrains.
the class TemplateListProvider method getTemplateList.
/**
* Search the given folder for a list of templates and populate the display list.
*/
private static TemplateEntry[] getTemplateList(@NotNull FormFactor formFactor, @NotNull String category, @Nullable Set<String> excluded) {
TemplateManager manager = TemplateManager.getInstance();
List<File> templates = manager.getTemplatesInCategory(category);
List<TemplateEntry> metadataList = new ArrayList<>(templates.size());
for (File template : templates) {
TemplateMetadata metadata = manager.getTemplateMetadata(template);
if (metadata == null || !metadata.isSupported()) {
continue;
}
// Don't include this template if it's been excluded
if (excluded != null && excluded.contains(metadata.getTitle())) {
continue;
}
// If a form factor has been specified, ensure that requirement is met.
if (!formFactor.id.equalsIgnoreCase(metadata.getFormFactor())) {
continue;
}
metadataList.add(new TemplateEntry(template, metadata));
}
return ArrayUtil.toObjectArray(metadataList, TemplateEntry.class);
}
Aggregations