filtering frameworks by template

This commit is contained in:
Dmitry Avdeev
2014-01-24 15:29:52 +04:00
parent 1d47fa02c0
commit 5485ead59d
5 changed files with 33 additions and 2 deletions
@@ -64,6 +64,9 @@ public abstract class ProjectCategory {
return new FrameworkRole[] {createModuleBuilder().getDefaultAcceptableRole()};
}
/**
* Describes "main" frameworks to be shown on top of the tree
*/
@NotNull
public String[] getAssociatedFrameworkIds() {
return ArrayUtil.EMPTY_STRING_ARRAY;
@@ -382,8 +382,10 @@ public class ProjectTypeStep extends ModuleWizardStep implements Disposable, Act
}
private void updateSelection() {
ModuleBuilder builder = getSelectedBuilder();
if (builder != null) {
ProjectTemplate template = getSelectedTemplate();
if (template != null) {
myContext.setProjectTemplate(template);
ModuleBuilder builder = myBuilders.get(template);
myContext.setProjectBuilder(builder);
myWizard.getSequence().setType(builder.getBuilderId());
}
@@ -18,6 +18,8 @@ package com.intellij.ide.util.newProjectWizard;
import com.intellij.CommonBundle;
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider;
import com.intellij.ide.projectWizard.ProjectCategory;
import com.intellij.ide.projectWizard.ProjectCategoryTemplate;
import com.intellij.ide.util.frameworkSupport.FrameworkSupportUtil;
import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase;
import com.intellij.ide.util.projectWizard.ModuleBuilder;
@@ -32,10 +34,13 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContaine
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.platform.ProjectTemplate;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Iterator;
import java.util.List;
/**
@@ -54,6 +59,7 @@ public class SupportForFrameworksStep extends ModuleWizardStep {
myContext = context;
myBuilder = builder;
List<FrameworkSupportInModuleProvider> providers = FrameworkSupportUtil.getProviders(builder);
filterByCategory(providers, context.getProjectTemplate());
myFrameworkSupportModel = new FrameworkSupportModelInWizard(librariesContainer, builder);
mySupportForFrameworksPanel = new AddSupportForFrameworksPanel(providers, myFrameworkSupportModel, false);
myConfigurationUpdater = new ModuleBuilder.ModuleConfigurationUpdater() {
@@ -69,6 +75,15 @@ public class SupportForFrameworksStep extends ModuleWizardStep {
return path != null ? FileUtil.toSystemIndependentName(path) : "";
}
private static void filterByCategory(List<FrameworkSupportInModuleProvider> providers, @Nullable ProjectTemplate template) {
if (!(template instanceof ProjectCategoryTemplate)) return;
ProjectCategory category = ((ProjectCategoryTemplate)template).getCategory();
for (Iterator<FrameworkSupportInModuleProvider> iterator = providers.iterator(); iterator.hasNext(); ) {
FrameworkSupportInModuleProvider provider = iterator.next();
}
}
public Icon getIcon() {
return ICON;
}
@@ -24,6 +24,7 @@ import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.UserDataHolderBase;
import com.intellij.platform.ProjectTemplate;
import com.intellij.util.SystemProperties;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
@@ -46,6 +47,7 @@ public class WizardContext extends UserDataHolderBase {
private String myCompilerOutputDirectory;
private Sdk myProjectJdk;
private ProjectBuilder myProjectBuilder;
private ProjectTemplate myProjectTemplate;
private final List<Listener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
private StorageScheme myProjectStorageFormat = StorageScheme.DIRECTORY_BASED;
private boolean myNewWizard;
@@ -163,6 +165,15 @@ public class WizardContext extends UserDataHolderBase {
myProjectBuilder = projectBuilder;
}
@Nullable
public ProjectTemplate getProjectTemplate() {
return myProjectTemplate;
}
public void setProjectTemplate(ProjectTemplate projectTemplate) {
myProjectTemplate = projectTemplate;
}
public String getPresentationName() {
return myProject == null ? IdeBundle.message("project.new.wizard.project.identification") : IdeBundle.message("project.new.wizard.module.identification");
}