use of com.intellij.platform.ProjectTemplate in project azure-tools-for-java by Microsoft.
the class HDInsightProjectTemplatesFactory method createTemplates.
@NotNull
@Override
public ProjectTemplate[] createTemplates(@Nullable String var1, WizardContext var2) {
ArrayList<HDInsightTemplateItem> templateItems = HDInsightTemplates.getTemplates();
int templateCount = templateItems.size();
List<CustomHDInsightTemplateItem> customHDInsightTemplateItems = TemplatesUtil.getCustomTemplate();
ProjectTemplate[] projectTemplates = new ProjectTemplate[templateCount + customHDInsightTemplateItems.size()];
for (int i = 0; i < templateCount; i++) {
projectTemplates[i] = new HDInsightProjectTemplate(templateItems.get(i));
}
for (int i = templateCount; i < templateCount + customHDInsightTemplateItems.size(); ++i) {
projectTemplates[i] = new CustomProjectTemplate(customHDInsightTemplateItems.get(i - templateCount));
}
return projectTemplates;
}
use of com.intellij.platform.ProjectTemplate in project intellij-community by JetBrains.
the class ProjectTemplateList method restoreSelection.
void restoreSelection() {
final String templateName = PropertiesComponent.getInstance().getValue(PROJECT_WIZARD_TEMPLATE);
if (templateName != null && myList.getModel() instanceof CollectionListModel) {
@SuppressWarnings("unchecked") List<ProjectTemplate> list = ((CollectionListModel<ProjectTemplate>) myList.getModel()).toList();
ProjectTemplate template = ContainerUtil.find(list, template1 -> templateName.equals(template1.getName()));
if (template != null) {
myList.setSelectedValue(template, true);
}
}
myList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
ProjectTemplate template = getSelectedTemplate();
if (template != null) {
PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_TEMPLATE, template.getName());
}
}
});
}
use of com.intellij.platform.ProjectTemplate in project intellij-community by JetBrains.
the class ProjectTypeStep method updateSelection.
private void updateSelection() {
ProjectTemplate template = getSelectedTemplate();
if (template != null) {
myContext.setProjectTemplate(template);
}
ModuleBuilder builder = getSelectedBuilder();
myContext.setProjectBuilder(builder);
if (builder != null) {
myWizard.getSequence().setType(builder.getBuilderId());
}
myWizard.setDelegate(builder instanceof WizardDelegate ? (WizardDelegate) builder : null);
myWizard.updateWizardButtons();
}
use of com.intellij.platform.ProjectTemplate in project intellij-community by JetBrains.
the class ProjectTypeStep method fillTemplatesMap.
private List<TemplatesGroup> fillTemplatesMap(WizardContext context) {
List<ModuleBuilder> builders = ModuleBuilder.getAllBuilders();
if (context.isCreatingNewProject()) {
builders.add(new EmptyModuleBuilder());
}
Map<String, TemplatesGroup> groupMap = new HashMap<>();
for (ModuleBuilder builder : builders) {
BuilderBasedTemplate template = new BuilderBasedTemplate(builder);
if (builder.isTemplate()) {
TemplatesGroup group = groupMap.get(builder.getGroupName());
if (group == null) {
group = new TemplatesGroup(builder);
}
myTemplatesMap.putValue(group, template);
} else {
TemplatesGroup group = new TemplatesGroup(builder);
groupMap.put(group.getName(), group);
myTemplatesMap.put(group, new ArrayList<>());
}
}
MultiMap<TemplatesGroup, ProjectTemplate> map = getTemplatesMap(context);
myTemplatesMap.putAllValues(map);
for (ProjectCategory category : ProjectCategory.EXTENSION_POINT_NAME.getExtensions()) {
TemplatesGroup group = new TemplatesGroup(category);
myTemplatesMap.remove(group);
myTemplatesMap.put(group, new ArrayList<>());
}
if (context.isCreatingNewProject()) {
MultiMap<String, ProjectTemplate> localTemplates = loadLocalTemplates();
for (TemplatesGroup group : myTemplatesMap.keySet()) {
myTemplatesMap.putValues(group, localTemplates.get(group.getId()));
}
}
List<TemplatesGroup> groups = new ArrayList<>(myTemplatesMap.keySet());
// sorting by module type popularity
final MultiMap<ModuleType, TemplatesGroup> moduleTypes = new MultiMap<>();
for (TemplatesGroup group : groups) {
ModuleType type = getModuleType(group);
moduleTypes.putValue(type, group);
}
Collections.sort(groups, (o1, o2) -> {
int i = o2.getWeight() - o1.getWeight();
if (i != 0)
return i;
int i1 = moduleTypes.get(getModuleType(o2)).size() - moduleTypes.get(getModuleType(o1)).size();
if (i1 != 0)
return i1;
return o1.compareTo(o2);
});
Set<String> groupNames = ContainerUtil.map2Set(groups, TemplatesGroup::getParentGroup);
// move subgroups
MultiMap<String, TemplatesGroup> subGroups = new MultiMap<>();
for (ListIterator<TemplatesGroup> iterator = groups.listIterator(); iterator.hasNext(); ) {
TemplatesGroup group = iterator.next();
String parentGroup = group.getParentGroup();
if (parentGroup != null && groupNames.contains(parentGroup) && !group.getName().equals(parentGroup) && groupMap.containsKey(parentGroup)) {
subGroups.putValue(parentGroup, group);
iterator.remove();
}
}
for (ListIterator<TemplatesGroup> iterator = groups.listIterator(); iterator.hasNext(); ) {
TemplatesGroup group = iterator.next();
for (TemplatesGroup subGroup : subGroups.get(group.getName())) {
iterator.add(subGroup);
}
}
// remove Static Web group in IDEA Community if no specific templates found (IDEA-120593)
if (PlatformUtils.isIdeaCommunity()) {
for (ListIterator<TemplatesGroup> iterator = groups.listIterator(); iterator.hasNext(); ) {
TemplatesGroup group = iterator.next();
if (WebModuleTypeBase.WEB_MODULE.equals(group.getId()) && myTemplatesMap.get(group).isEmpty()) {
iterator.remove();
break;
}
}
}
return groups;
}
Aggregations