@Nullable private FrameworkSupportNode createNode( final FrameworkSupportInModuleProvider provider, final Map<String, FrameworkSupportNode> nodes, final Map<FrameworkGroup<?>, FrameworkGroupNode> groupNodes, List<FrameworkSupportNodeBase> roots, List<FrameworkSupportInModuleProvider> providers, Set<String> associated, Map<String, FrameworkSupportNodeBase> associatedNodes) { String id = provider.getFrameworkType().getId(); FrameworkSupportNode node = nodes.get(id); if (node != null || associatedNodes.containsKey(id)) { return node; } String underlyingTypeId = provider.getFrameworkType().getUnderlyingFrameworkTypeId(); FrameworkSupportNodeBase parentNode = null; final FrameworkGroup<?> group = provider.getFrameworkType().getParentGroup(); if (underlyingTypeId != null) { FrameworkSupportInModuleProvider parentProvider = FrameworkSupportUtil.findProvider(underlyingTypeId, providers); if (parentProvider == null) { LOG.info("Cannot find id = " + underlyingTypeId); return null; } parentNode = createNode( parentProvider, nodes, groupNodes, roots, providers, associated, associatedNodes); } else if (group != null) { parentNode = groupNodes.get(group); if (parentNode == null) { FrameworkGroupNode groupNode = new FrameworkGroupNode(group, null); if (associated.contains(groupNode.getId())) { associatedNodes.put(groupNode.getId(), groupNode); } else { groupNodes.put(group, groupNode); parentNode = groupNode; roots.add(groupNode); } } } node = new FrameworkSupportNode(provider, parentNode, myModel, this); if (associated.contains(id)) { associatedNodes.put(id, node); } else { nodes.put(id, node); if (parentNode == null) { roots.add(node); } } return node; }
private static boolean matchFramework( ProjectCategory projectCategory, FrameworkSupportInModuleProvider framework) { FrameworkRole[] roles = framework.getRoles(); if (roles.length == 0) return true; List<FrameworkRole> acceptable = Arrays.asList(projectCategory.getAcceptableFrameworkRoles()); return ContainerUtil.intersects(Arrays.asList(roles), acceptable); }
public static AddSupportForSingleFrameworkDialogFixed createDialog( @NotNull Module module, @NotNull FrameworkSupportInModuleProvider provider) { VirtualFile[] roots = ModuleRootManager.getInstance(module).getContentRoots(); if (roots.length == 0) return null; List<FrameworkSupportInModuleProvider> providers = FrameworkSupportUtil.getProviders(module, DefaultFacetsProvider.INSTANCE); if (providers.isEmpty()) return null; final LibrariesContainer container = LibrariesContainerFactory.createContainer(module.getProject()); final IdeaModifiableModelsProvider modifiableModelsProvider = new IdeaModifiableModelsProvider(); return new AddSupportForSingleFrameworkDialogFixed( module, roots[0].getPath(), provider.getFrameworkType(), provider, container, modifiableModelsProvider); }
public AddSupportForSingleFrameworkDialogFixed( @NotNull Module module, final @NotNull String contentRootPath, FrameworkTypeEx frameworkType, @NotNull FrameworkSupportInModuleProvider provider, @NotNull LibrariesContainer librariesContainer, ModifiableModelsProvider modifiableModelsProvider) { super(module.getProject(), true); myFrameworkType = frameworkType; myModifiableModelsProvider = modifiableModelsProvider; setTitle( ProjectBundle.message( "dialog.title.add.framework.0.support", frameworkType.getPresentableName())); myModule = module; myModel = new FrameworkSupportModelImpl(module.getProject(), contentRootPath, librariesContainer); myConfigurable = provider.createConfigurable(myModel); myComponent = new FrameworkSupportOptionsComponent( myModel, myModel.getLibrariesContainer(), myDisposable, myConfigurable, null); Disposer.register(myDisposable, myConfigurable); init(); }
@Override public String convert(FrameworkSupportInModuleProvider o) { return o.getId(); }
// new TemplatesGroup selected public void projectTypeChanged() { TemplatesGroup group = getSelectedGroup(); if (group == null || group == myLastSelectedGroup) return; myLastSelectedGroup = group; PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_GROUP, group.getId()); ModuleBuilder groupModuleBuilder = group.getModuleBuilder(); mySettingsStep = null; myHeaderPanel.removeAll(); if (groupModuleBuilder != null && groupModuleBuilder.getModuleType() != null) { mySettingsStep = groupModuleBuilder.modifyProjectTypeStep(this); } if (groupModuleBuilder == null || groupModuleBuilder.isTemplateBased()) { showTemplates(group); } else if (!showCustomOptions(groupModuleBuilder)) { List<FrameworkSupportInModuleProvider> providers = FrameworkSupportUtil.getProviders(groupModuleBuilder); final ProjectCategory category = group.getProjectCategory(); if (category != null) { List<FrameworkSupportInModuleProvider> filtered = ContainerUtil.filter( providers, new Condition<FrameworkSupportInModuleProvider>() { @Override public boolean value(FrameworkSupportInModuleProvider provider) { return matchFramework(category, provider); } }); // add associated Map<String, FrameworkSupportInModuleProvider> map = ContainerUtil.newMapFromValues(providers.iterator(), PROVIDER_STRING_CONVERTOR); Set<FrameworkSupportInModuleProvider> set = new HashSet<FrameworkSupportInModuleProvider>(filtered); for (FrameworkSupportInModuleProvider provider : filtered) { for (FrameworkSupportInModuleProvider.FrameworkDependency depId : provider.getDependenciesFrameworkIds()) { FrameworkSupportInModuleProvider dependency = map.get(depId.getFrameworkId()); set.add(dependency); } } myFrameworksPanel.setProviders( new ArrayList<FrameworkSupportInModuleProvider>(set), new HashSet<String>(Arrays.asList(category.getAssociatedFrameworkIds())), new HashSet<String>(Arrays.asList(category.getPreselectedFrameworkIds()))); } else { myFrameworksPanel.setProviders(providers); } getSelectedBuilder().addModuleConfigurationUpdater(myConfigurationUpdater); showCard(FRAMEWORKS_CARD); } myHeaderPanel.setVisible(myHeaderPanel.getComponentCount() > 0); // align header labels List<JLabel> labels = UIUtil.findComponentsOfType(myHeaderPanel, 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)); } myHeaderPanel.revalidate(); myHeaderPanel.repaint(); updateSelection(); }