Search in sources :

Example 1 with TemplatesGroup

use of com.intellij.ide.util.newProjectWizard.TemplatesGroup in project liferay-ide by liferay.

the class LiferayProjectTypeStep method _fillTemplatesMap.

private List<TemplatesGroup> _fillTemplatesMap() {
    _templatesMap.put(new TemplatesGroup(new LiferayModuleBuilder()), new ArrayList<>());
    _templatesMap.put(new TemplatesGroup(new LiferayModuleFragmentBuilder()), new ArrayList<>());
    List<TemplatesGroup> groups = new ArrayList<>(_templatesMap.keySet());
    MultiMap<ModuleType, TemplatesGroup> moduleTypes = new MultiMap<>();
    for (TemplatesGroup group : groups) {
        ModuleType type = _getModuleType(group);
        moduleTypes.putValue(type, group);
    }
    return groups;
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) ConcurrentMultiMap(com.intellij.util.containers.ConcurrentMultiMap) ModuleType(com.intellij.openapi.module.ModuleType) ArrayList(java.util.ArrayList) TemplatesGroup(com.intellij.ide.util.newProjectWizard.TemplatesGroup)

Example 2 with TemplatesGroup

use of com.intellij.ide.util.newProjectWizard.TemplatesGroup in project liferay-ide by liferay.

the class LiferayProjectTypeStep method getTemplatesMap.

public static MultiMap<TemplatesGroup, ProjectTemplate> getTemplatesMap(WizardContext context) {
    MultiMap<TemplatesGroup, ProjectTemplate> groups = new MultiMap<>();
    for (ProjectTemplatesFactory factory : ProjectTemplatesFactory.EP_NAME.getExtensions()) {
        Stream<String> stream = Stream.of(factory.getGroups());
        stream.map(group -> new AbstractMap.SimpleEntry<>(group, factory.createTemplates(group, context))).filter(pair -> !CoreUtil.isNullOrEmpty(pair.getValue())).forEach(pair -> {
            String group = pair.getKey();
            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, Arrays.asList(pair.getValue()));
        });
    }
    return groups;
}
Also used : AbstractMap(java.util.AbstractMap) UIUtil(com.intellij.util.ui.UIUtil) CommitStepException(com.intellij.ide.wizard.CommitStepException) Arrays(java.util.Arrays) THashMap(gnu.trove.THashMap) JBLabel(com.intellij.ui.components.JBLabel) WizardDelegate(com.intellij.ide.util.newProjectWizard.WizardDelegate) AddSupportForFrameworksPanel(com.intellij.ide.util.newProjectWizard.AddSupportForFrameworksPanel) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) Map(java.util.Map) Disposer(com.intellij.openapi.util.Disposer) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) ListSelectionEvent(javax.swing.event.ListSelectionEvent) MultiMap(com.intellij.util.containers.MultiMap) TemplatesGroup(com.intellij.ide.util.newProjectWizard.TemplatesGroup) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) LibrariesContainerFactory(com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory) Collection(java.util.Collection) BuilderBasedTemplate(com.intellij.platform.templates.BuilderBasedTemplate) FactoryMap(com.intellij.util.containers.FactoryMap) Set(java.util.Set) Icon(javax.swing.Icon) Collectors(java.util.stream.Collectors) WizardContext(com.intellij.ide.util.projectWizard.WizardContext) Nullable(org.jetbrains.annotations.Nullable) Dimension(java.awt.Dimension) List(java.util.List) Stream(java.util.stream.Stream) CoreUtil(com.liferay.ide.idea.util.CoreUtil) Function(com.intellij.util.Function) ModulesProvider(com.intellij.openapi.roots.ui.configuration.ModulesProvider) SettingsStep(com.intellij.ide.util.projectWizard.SettingsStep) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) JPanel(javax.swing.JPanel) ListSelectionModel(javax.swing.ListSelectionModel) CardLayout(java.awt.CardLayout) ProjectCategoryUsagesCollector(com.intellij.ide.projectWizard.ProjectCategoryUsagesCollector) JTextField(javax.swing.JTextField) ModuleBuilder(com.intellij.ide.util.projectWizard.ModuleBuilder) ContainerUtil(com.intellij.util.containers.ContainerUtil) ProjectTemplate(com.intellij.platform.ProjectTemplate) FrameworkSupportModelBase(com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) FrameworkSupportNode(com.intellij.ide.util.newProjectWizard.FrameworkSupportNode) LibrariesContainer(com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer) TemplateModuleBuilder(com.intellij.platform.templates.TemplateModuleBuilder) ProjectCategory(com.intellij.ide.projectWizard.ProjectCategory) FrameworkSupportUtil(com.intellij.ide.util.frameworkSupport.FrameworkSupportUtil) Project(com.intellij.openapi.project.Project) ModuleType(com.intellij.openapi.module.ModuleType) StepSequence(com.intellij.ide.util.newProjectWizard.StepSequence) FrameworkRole(com.intellij.ide.util.frameworkSupport.FrameworkRole) JComponent(javax.swing.JComponent) JBList(com.intellij.ui.components.JBList) StringUtil(com.intellij.openapi.util.text.StringUtil) ListItemDescriptorAdapter(com.intellij.openapi.ui.popup.ListItemDescriptorAdapter) Convertor(com.intellij.util.containers.Convertor) FrameworkSupportNodeBase(com.intellij.ide.util.newProjectWizard.FrameworkSupportNodeBase) CollectionListModel(com.intellij.ui.CollectionListModel) ProjectTemplatesFactory(com.intellij.platform.ProjectTemplatesFactory) Disposable(com.intellij.openapi.Disposable) SingleSelectionModel(com.intellij.ui.SingleSelectionModel) FrameworkSupportInModuleProvider(com.intellij.framework.addSupport.FrameworkSupportInModuleProvider) AbstractMap(java.util.AbstractMap) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) JLabel(javax.swing.JLabel) GroupedItemsListRenderer(com.intellij.ui.popup.list.GroupedItemsListRenderer) ConcurrentMultiMap(com.intellij.util.containers.ConcurrentMultiMap) ListSelectionListener(javax.swing.event.ListSelectionListener) Collections(java.util.Collections) ListSpeedSearch(com.intellij.ui.ListSpeedSearch) MultiMap(com.intellij.util.containers.MultiMap) ConcurrentMultiMap(com.intellij.util.containers.ConcurrentMultiMap) ProjectTemplatesFactory(com.intellij.platform.ProjectTemplatesFactory) TemplatesGroup(com.intellij.ide.util.newProjectWizard.TemplatesGroup) Icon(javax.swing.Icon) ProjectTemplate(com.intellij.platform.ProjectTemplate)

Example 3 with TemplatesGroup

use of com.intellij.ide.util.newProjectWizard.TemplatesGroup in project liferay-ide by liferay.

the class LiferayProjectTypeStep method projectTypeChanged.

public void projectTypeChanged() {
    TemplatesGroup group = _getSelectedGroup();
    if ((group == null) || (group == _lastSelectedGroup)) {
        return;
    }
    _lastSelectedGroup = group;
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    propertiesComponent.setValue(_PROJECT_WIZARD_GROUP, group.getId());
    ModuleBuilder groupModuleBuilder = group.getModuleBuilder();
    _settingsStep = null;
    _headerPanel.removeAll();
    if ((groupModuleBuilder != null) && (groupModuleBuilder.getModuleType() != null)) {
        _settingsStep = groupModuleBuilder.modifyProjectTypeStep(this);
    }
    if ((groupModuleBuilder == null) || groupModuleBuilder.isTemplateBased()) {
        _showTemplates(group);
    } else if (!_showCustomOptions(groupModuleBuilder)) {
        List<FrameworkSupportInModuleProvider> providers = FrameworkSupportUtil.getProviders(groupModuleBuilder);
        ProjectCategory category = group.getProjectCategory();
        if (category != null) {
            List<FrameworkSupportInModuleProvider> filtered = ContainerUtil.filter(providers, provider -> _matchFramework(category, provider));
            Map<String, FrameworkSupportInModuleProvider> map = ContainerUtil.newMapFromValues(providers.iterator(), PROVIDER_STRING_CONVERTOR);
            Stream<FrameworkSupportInModuleProvider> stream = filtered.stream();
            Set<FrameworkSupportInModuleProvider> set = stream.flatMap(provider -> provider.getDependenciesFrameworkIds().stream()).map(depId -> map.get(depId.getFrameworkId())).filter(dependency -> dependency != null).collect(Collectors.toSet());
            _frameworksPanel.setProviders(new ArrayList<>(set), new HashSet<>(Arrays.asList(category.getAssociatedFrameworkIds())), new HashSet<>(Arrays.asList(category.getPreselectedFrameworkIds())));
        } else {
            _frameworksPanel.setProviders(providers);
        }
        _getSelectedBuilder().addModuleConfigurationUpdater(_configurationUpdater);
        _showCard(_FRAMEWORKS_CARD);
    }
    _headerPanel.setVisible(_headerPanel.getComponentCount() > 0);
    List<JLabel> labels = UIUtil.findComponentsOfType(_headerPanel, JLabel.class);
    int width = 0;
    for (JLabel label : labels) {
        int width1 = label.getPreferredSize().width;
        width = Math.max(width, width1);
    }
    for (JLabel label : labels) {
        label.setPreferredSize(new Dimension(width, label.getPreferredSize().height));
    }
    _headerPanel.revalidate();
    _headerPanel.repaint();
    _updateSelection();
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) CommitStepException(com.intellij.ide.wizard.CommitStepException) Arrays(java.util.Arrays) THashMap(gnu.trove.THashMap) JBLabel(com.intellij.ui.components.JBLabel) WizardDelegate(com.intellij.ide.util.newProjectWizard.WizardDelegate) AddSupportForFrameworksPanel(com.intellij.ide.util.newProjectWizard.AddSupportForFrameworksPanel) ModuleWizardStep(com.intellij.ide.util.projectWizard.ModuleWizardStep) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) Map(java.util.Map) Disposer(com.intellij.openapi.util.Disposer) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) ListSelectionEvent(javax.swing.event.ListSelectionEvent) MultiMap(com.intellij.util.containers.MultiMap) TemplatesGroup(com.intellij.ide.util.newProjectWizard.TemplatesGroup) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) LibrariesContainerFactory(com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory) Collection(java.util.Collection) BuilderBasedTemplate(com.intellij.platform.templates.BuilderBasedTemplate) FactoryMap(com.intellij.util.containers.FactoryMap) Set(java.util.Set) Icon(javax.swing.Icon) Collectors(java.util.stream.Collectors) WizardContext(com.intellij.ide.util.projectWizard.WizardContext) Nullable(org.jetbrains.annotations.Nullable) Dimension(java.awt.Dimension) List(java.util.List) Stream(java.util.stream.Stream) CoreUtil(com.liferay.ide.idea.util.CoreUtil) Function(com.intellij.util.Function) ModulesProvider(com.intellij.openapi.roots.ui.configuration.ModulesProvider) SettingsStep(com.intellij.ide.util.projectWizard.SettingsStep) ConfigurationException(com.intellij.openapi.options.ConfigurationException) NotNull(org.jetbrains.annotations.NotNull) JPanel(javax.swing.JPanel) ListSelectionModel(javax.swing.ListSelectionModel) CardLayout(java.awt.CardLayout) ProjectCategoryUsagesCollector(com.intellij.ide.projectWizard.ProjectCategoryUsagesCollector) JTextField(javax.swing.JTextField) ModuleBuilder(com.intellij.ide.util.projectWizard.ModuleBuilder) ContainerUtil(com.intellij.util.containers.ContainerUtil) ProjectTemplate(com.intellij.platform.ProjectTemplate) FrameworkSupportModelBase(com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) FrameworkSupportNode(com.intellij.ide.util.newProjectWizard.FrameworkSupportNode) LibrariesContainer(com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer) TemplateModuleBuilder(com.intellij.platform.templates.TemplateModuleBuilder) ProjectCategory(com.intellij.ide.projectWizard.ProjectCategory) FrameworkSupportUtil(com.intellij.ide.util.frameworkSupport.FrameworkSupportUtil) Project(com.intellij.openapi.project.Project) ModuleType(com.intellij.openapi.module.ModuleType) StepSequence(com.intellij.ide.util.newProjectWizard.StepSequence) FrameworkRole(com.intellij.ide.util.frameworkSupport.FrameworkRole) JComponent(javax.swing.JComponent) JBList(com.intellij.ui.components.JBList) StringUtil(com.intellij.openapi.util.text.StringUtil) ListItemDescriptorAdapter(com.intellij.openapi.ui.popup.ListItemDescriptorAdapter) Convertor(com.intellij.util.containers.Convertor) FrameworkSupportNodeBase(com.intellij.ide.util.newProjectWizard.FrameworkSupportNodeBase) CollectionListModel(com.intellij.ui.CollectionListModel) ProjectTemplatesFactory(com.intellij.platform.ProjectTemplatesFactory) Disposable(com.intellij.openapi.Disposable) SingleSelectionModel(com.intellij.ui.SingleSelectionModel) FrameworkSupportInModuleProvider(com.intellij.framework.addSupport.FrameworkSupportInModuleProvider) AbstractMap(java.util.AbstractMap) IdeBorderFactory(com.intellij.ui.IdeBorderFactory) JLabel(javax.swing.JLabel) GroupedItemsListRenderer(com.intellij.ui.popup.list.GroupedItemsListRenderer) ConcurrentMultiMap(com.intellij.util.containers.ConcurrentMultiMap) ListSelectionListener(javax.swing.event.ListSelectionListener) Collections(java.util.Collections) ListSpeedSearch(com.intellij.ui.ListSpeedSearch) Set(java.util.Set) HashSet(java.util.HashSet) ProjectCategory(com.intellij.ide.projectWizard.ProjectCategory) ModuleBuilder(com.intellij.ide.util.projectWizard.ModuleBuilder) TemplateModuleBuilder(com.intellij.platform.templates.TemplateModuleBuilder) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) TemplatesGroup(com.intellij.ide.util.newProjectWizard.TemplatesGroup) Dimension(java.awt.Dimension) List(java.util.List) ArrayList(java.util.ArrayList) JBList(com.intellij.ui.components.JBList) Stream(java.util.stream.Stream) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) THashMap(gnu.trove.THashMap) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap) FactoryMap(com.intellij.util.containers.FactoryMap) AbstractMap(java.util.AbstractMap) ConcurrentMultiMap(com.intellij.util.containers.ConcurrentMultiMap) HashSet(java.util.HashSet)

Aggregations

TemplatesGroup (com.intellij.ide.util.newProjectWizard.TemplatesGroup)3 ModuleType (com.intellij.openapi.module.ModuleType)3 ConcurrentMultiMap (com.intellij.util.containers.ConcurrentMultiMap)3 MultiMap (com.intellij.util.containers.MultiMap)3 ArrayList (java.util.ArrayList)3 FrameworkSupportInModuleProvider (com.intellij.framework.addSupport.FrameworkSupportInModuleProvider)2 ProjectCategory (com.intellij.ide.projectWizard.ProjectCategory)2 ProjectCategoryUsagesCollector (com.intellij.ide.projectWizard.ProjectCategoryUsagesCollector)2 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)2 FrameworkRole (com.intellij.ide.util.frameworkSupport.FrameworkRole)2 FrameworkSupportUtil (com.intellij.ide.util.frameworkSupport.FrameworkSupportUtil)2 AddSupportForFrameworksPanel (com.intellij.ide.util.newProjectWizard.AddSupportForFrameworksPanel)2 FrameworkSupportNode (com.intellij.ide.util.newProjectWizard.FrameworkSupportNode)2 FrameworkSupportNodeBase (com.intellij.ide.util.newProjectWizard.FrameworkSupportNodeBase)2 StepSequence (com.intellij.ide.util.newProjectWizard.StepSequence)2 WizardDelegate (com.intellij.ide.util.newProjectWizard.WizardDelegate)2 FrameworkSupportModelBase (com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelBase)2 ModuleBuilder (com.intellij.ide.util.projectWizard.ModuleBuilder)2 ModuleWizardStep (com.intellij.ide.util.projectWizard.ModuleWizardStep)2 SettingsStep (com.intellij.ide.util.projectWizard.SettingsStep)2