本文整理汇总了Java中com.intellij.platform.ProjectTemplate类的典型用法代码示例。如果您正苦于以下问题:Java ProjectTemplate类的具体用法?Java ProjectTemplate怎么用?Java ProjectTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectTemplate类属于com.intellij.platform包,在下文中一共展示了ProjectTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTemplates
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
@NotNull
@Override
public ProjectTemplate[] createTemplates(@Nullable String group, WizardContext context) {
// myGroups contains only not-null keys
if (group == null) {
return ProjectTemplate.EMPTY_ARRAY;
}
List<ProjectTemplate> templates = null;
for (Pair<URL, ClassLoader> url : myGroups.getValue().get(group)) {
try {
for (String child : UrlUtil.getChildrenRelativePaths(url.first)) {
if (child.endsWith(ZIP)) {
if (templates == null) {
templates = new SmartList<ProjectTemplate>();
}
templates.add(new LocalArchivedTemplate(new URL(url.first.toExternalForm() + '/' + child), url.second));
}
}
}
catch (IOException e) {
LOG.error(e);
}
}
return ContainerUtil.isEmpty(templates) ? ProjectTemplate.EMPTY_ARRAY : templates.toArray(new ProjectTemplate[templates.size()]);
}
示例2: validate
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
@Override
public boolean validate() throws ConfigurationException {
ProjectTemplate template = getSelectedTemplate();
if (template == null) {
throw new ConfigurationException(StringUtil.capitalize(ProjectBundle.message("project.new.wizard.from.template.error", myWizardContext.getPresentationName())), "Error");
}
if (myWizardContext.isCreatingNewProject()) {
if (!myNamePathComponent.validateNameAndPath(myWizardContext, myFormatPanel.isDefault())) return false;
}
if (!myModuleNameLocationComponent.validateModulePaths()) return false;
if (!myWizardContext.isCreatingNewProject()) {
myModuleNameLocationComponent.validateExistingModuleName(myWizardContext.getProject());
}
ValidationInfo info = template.validateSettings();
if (info != null) {
throw new ConfigurationException(info.message, "Error");
}
if (mySettingsStep != null) {
return mySettingsStep.validate();
}
return true;
}
示例3: getTemplatesMap
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
public static MultiMap<TemplatesGroup, ProjectTemplate> getTemplatesMap(WizardContext context) {
ProjectTemplatesFactory[] factories = ProjectTemplatesFactory.EP_NAME.getExtensions();
final MultiMap<TemplatesGroup, ProjectTemplate> groups = new MultiMap<TemplatesGroup, ProjectTemplate>();
for (ProjectTemplatesFactory factory : factories) {
for (String group : factory.getGroups()) {
ProjectTemplate[] templates = factory.createTemplates(group, context);
List<ProjectTemplate> values = Arrays.asList(templates);
if (!values.isEmpty()) {
Icon icon = factory.getGroupIcon(group);
String parentGroup = factory.getParentGroup(group);
TemplatesGroup templatesGroup = new TemplatesGroup(group, null, icon, factory.getGroupWeight(group), parentGroup, group, null);
groups.putValues(templatesGroup, values);
}
}
}
return groups;
}
示例4: getAvailableTemplates
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
public Collection<ProjectTemplate> getAvailableTemplates() {
if (myCurrentCard != FRAMEWORKS_CARD) {
return Collections.emptyList();
}
else {
Collection<ProjectTemplate> templates = myTemplatesMap.get(getSelectedGroup());
List<FrameworkSupportNode> nodes = myFrameworksPanel.getSelectedNodes();
if (nodes.isEmpty()) return templates;
final List<String> selectedFrameworks = ContainerUtil.map(nodes, NODE_STRING_FUNCTION);
return ContainerUtil.filter(templates, new Condition<ProjectTemplate>() {
@Override
public boolean value(ProjectTemplate template) {
if (!(template instanceof ArchivedProjectTemplate)) return true;
List<String> frameworks = ((ArchivedProjectTemplate)template).getFrameworks();
return frameworks.containsAll(selectedFrameworks);
}
});
}
}
示例5: setTemplates
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
public void setTemplates(List<ProjectTemplate> list, boolean preserveSelection) {
Collections.sort(list, new Comparator<ProjectTemplate>() {
@Override
public int compare(ProjectTemplate o1, ProjectTemplate o2) {
return Comparing.compare(o1 instanceof ArchivedProjectTemplate, o2 instanceof ArchivedProjectTemplate);
}
});
int index = preserveSelection ? myList.getSelectedIndex() : -1;
//noinspection unchecked
myList.setModel(new CollectionListModel(list));
if (myList.isEnabled()) {
myList.setSelectedIndex(index == -1 ? 0 : index);
}
updateSelection();
}
示例6: createTemplates
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
@NotNull
@Override
public ProjectTemplate[] createTemplates(@Nullable String group, WizardContext context) {
Project project = context.getProject();
if (project != null && !Projects.isGradleProject(project)) {
return EMPTY_PROJECT_TEMPLATES;
}
TemplateManager manager = TemplateManager.getInstance();
List<File> templates = manager.getTemplates(Template.CATEGORY_PROJECTS);
List<ProjectTemplate> tt = new ArrayList<ProjectTemplate>();
for (File template : templates) {
final String templateName = template.getName();
if (NewProjectWizardState.PROJECT_TEMPLATE_NAME.equals(templateName) ||
NewProjectWizardState.IMPORT_EXISTING_PROJECT_TEMPLATE_NAME.equals(templateName) ||
project == null && !NewProjectWizardState.MODULE_TEMPLATE_NAME.equals(templateName)) {
continue;
}
TemplateMetadata metadata = manager.getTemplate(template);
if (metadata == null || !metadata.isSupported()) {
continue;
}
tt.add(new AndroidProjectTemplate(template, metadata, project, context.getDisposable()));
}
return tt.toArray(new ProjectTemplate[tt.size()]);
}
示例7: createTemplates
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
@NotNull
@Override
public ProjectTemplate[] createTemplates(@Nullable final String group, final WizardContext wizardContext) {
if(!wizardContext.isCreatingNewProject()) {
// ignore new module wizard
return EMPTY_TEMPLATES;
}
final List<ProjectTemplate> templates = new ArrayList<ProjectTemplate>();
templates.add(new DefracProjectTemplate("Generic", "Creates a new Multi-Platform project with a main entry point", new DefracModuleBuilder.Generic()));
if(DefracPlatform.IOS.isAvailableOnHostOS()) {
templates.add(new DefracProjectTemplate("iOS", "Creates a new iOS project based on native UIKit components", new DefracModuleBuilder.IOS()));
}
templates.add(new DefracProjectTemplate("Empty", "Creates an empty Multi-Platform project", new DefracModuleBuilder.Empty()));
return templates.toArray(new ProjectTemplate[templates.size()]);
}
示例8: runWizard
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
protected void runWizard(String group, String name, Project project, @Nullable Consumer<ModuleWizardStep> adjuster) throws IOException {
createWizard(project);
SelectTemplateStep step = (SelectTemplateStep)myWizard.getCurrentStepObject();
boolean condition = step.setSelectedTemplate(group, name);
if (!condition) {
throw new IllegalArgumentException(group + "/" + name + " template not found");
}
ProjectTemplate template = step.getSelectedTemplate();
assertNotNull(template);
if (adjuster != null) {
adjuster.consume(step);
}
runWizard(adjuster);
}
示例9: createTemplates
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
@NotNull
@Override
public ProjectTemplate[] createTemplates(String group, WizardContext context) {
Collection<Pair<URL, ClassLoader>> urls = myGroups.getValue().get(group);
List<ProjectTemplate> templates = new ArrayList<ProjectTemplate>();
for (Pair<URL, ClassLoader> url : urls) {
try {
List<String> children = UrlUtil.getChildrenRelativePaths(url.first);
for (String child : children) {
if (child.endsWith(ZIP)) {
URL templateUrl = new URL(url.first.toExternalForm() + "/" + child);
String name = child.substring(0, child.length() - ZIP.length()).replace('_', ' ');
templates.add(new LocalArchivedTemplate(name, templateUrl, url.second));
}
}
}
catch (IOException e) {
LOG.error(e);
}
}
return templates.toArray(new ProjectTemplate[templates.size()]);
}
示例10: validate
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
@Override
public boolean validate() throws ConfigurationException {
ProjectTemplate template = getSelectedTemplate();
if (template == null) {
throw new ConfigurationException(StringUtil.capitalize(ProjectBundle.message("project.new.wizard.from.template.error", myWizardContext.getPresentationName())), "Error");
}
if (myWizardContext.isCreatingNewProject()) {
if (!myNamePathComponent.validateNameAndPath(myWizardContext, myFormatPanel.isDefault())) return false;
}
if (!validateModulePaths()) return false;
if (!myWizardContext.isCreatingNewProject()) {
validateExistingModuleName();
}
ValidationInfo info = template.validateSettings();
if (info != null) {
throw new ConfigurationException(info.message, "Error");
}
if (mySettingsStep != null) {
return mySettingsStep.validate();
}
return true;
}
示例11: createTemplates
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
@NotNull
@Override
public ProjectTemplate[] createTemplates(@Nullable String group, WizardContext context) {
return new ProjectTemplate[]{
new TYPO3CMSClassicLayoutDirectoryProjectGenerator(),
new TYPO3CMSComposerLayoutDirectoryProjectGenerator()
};
}
示例12: createTemplates
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
@NotNull
@Override
public ProjectTemplate[] createTemplates(@Nullable String group, WizardContext context) {
final ArrayList<EduIntelliJProjectTemplate> templates = new ArrayList<>();
final List<Course> courses = EduCourseUpdater.getInstance().getRemoteCourses();
for (Course course : courses) {
templates.add(new EduRemoteCourseTemplate(course));
}
Collections.addAll(templates, ApplicationManager.getApplication().getExtensions(EduIntelliJProjectTemplate.EP_NAME));
return templates.toArray(new ProjectTemplate[templates.size()]);
}
示例13: createTemplates
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
@NotNull
@Override
public ProjectTemplate[] createTemplates(@Nullable String group, WizardContext context) {
return new ProjectTemplate[] {
new CatberryProjectGenerator()
};
}
示例14: getHelpId
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
@Override
public String getHelpId() {
String helpId = myWizardContext.isCreatingNewProject() ? "New_Project_Main_Settings" : "Add_Module_Main_Settings";
ProjectTemplate projectTemplate = getSelectedTemplate();
if (projectTemplate instanceof WebProjectTemplate) {
WebProjectTemplate webProjectTemplate = (WebProjectTemplate) projectTemplate;
String subHelpId = webProjectTemplate.getHelpId();
if (subHelpId != null) {
helpId = helpId + ":" + subHelpId;
}
}
return helpId;
}
示例15: setupPanels
import com.intellij.platform.ProjectTemplate; //导入依赖的package包/类
private void setupPanels(@Nullable ProjectTemplate template) {
restorePanel(myNamePathComponent, 4);
restorePanel(getModulePanel(), myWizardContext.isCreatingNewProject() ? 8 : 6);
restorePanel(myExpertPanel, myWizardContext.isCreatingNewProject() ? 1 : 0);
if (mySettingsStep != null) mySettingsStep.disposeUIResources();
mySettingsStep = myModuleBuilder == null ? null : myModuleBuilder.modifySettingsStep(this);
String description = null;
if (template != null) {
description = template.getDescription();
if (StringUtil.isNotEmpty(description)) {
StringBuilder sb = new StringBuilder("<html><body><font ");
sb.append(SystemInfo.isMac ? "" : "face=\"Verdana\" size=\"-1\"").append('>');
sb.append(description).append("</font></body></html>");
description = sb.toString();
myDescriptionPane.setText(description);
}
}
myExpertPlaceholder.setVisible(!(myModuleBuilder instanceof TemplateModuleBuilder) && myExpertPanel.getComponentCount() > 0);
for (int i = 0; i < 6; i++) {
getModulePanel().getComponent(i).setVisible(!(myModuleBuilder instanceof EmptyModuleBuilder));
}
myDescriptionPanel.setVisible(StringUtil.isNotEmpty(description));
mySettingsPanel.revalidate();
mySettingsPanel.repaint();
}