public void setProviders(List<FrameworkSupportInModuleProvider> providers) {
   setProviders(providers, Collections.<String>emptySet(), Collections.<String>emptySet());
 }
  public AddSupportForFrameworksPanel(
      final List<FrameworkSupportInModuleProvider> providers,
      final FrameworkSupportModelBase model,
      boolean vertical,
      @Nullable JPanel associatedFrameworksPanel) {
    myModel = model;
    myAssociatedFrameworksPanel = associatedFrameworksPanel;
    myLibrariesContainer = model.getLibrariesContainer();

    myLabel.setVisible(!vertical);
    Splitter splitter =
        vertical ? new Splitter(true, 0.6f, 0.2f, 0.8f) : new Splitter(false, 0.3f, 0.3f, 0.7f);
    splitter.setHonorComponentsMinimumSize(false);
    myFrameworksTree =
        new FrameworksTree(model) {
          @Override
          protected void onNodeStateChanged(CheckedTreeNode node) {
            if (!(node instanceof FrameworkSupportNode)) return;

            final FrameworkSupportNode frameworkSupportNode = (FrameworkSupportNode) node;
            if (frameworkSupportNode == getSelectedNode()) {
              updateOptionsPanel();
            }
            final FrameworkSupportInModuleConfigurable configurable =
                frameworkSupportNode.getConfigurable();
            configurable.onFrameworkSelectionChanged(node.isChecked());
            myModel.onFrameworkSelectionChanged(frameworkSupportNode);
            onFrameworkStateChanged();
          }
        };
    model.addFrameworkVersionListener(
        new FrameworkVersionListener() {
          @Override
          public void versionChanged(FrameworkVersion version) {
            ((DefaultTreeModel) myFrameworksTree.getModel()).nodeChanged(getSelectedNode());
          }
        },
        this);

    myFrameworksTree.addTreeSelectionListener(
        new TreeSelectionListener() {
          public void valueChanged(TreeSelectionEvent e) {
            onSelectionChanged();
          }
        });

    JPanel treePanel = new JPanel(new BorderLayout());
    treePanel.add(ScrollPaneFactory.createScrollPane(myFrameworksTree), BorderLayout.CENTER);
    treePanel.setMinimumSize(new Dimension(200, 300));

    splitter.setFirstComponent(treePanel);
    myOptionsPanel = new JPanel(new CardLayout());
    JPanel emptyCard = new JPanel();
    emptyCard.setPreferredSize(new Dimension(400, 100));
    myOptionsPanel.add(EMPTY_CARD, emptyCard);

    splitter.setSecondComponent(myOptionsPanel);
    myFrameworksPanel.add(splitter, BorderLayout.CENTER);

    setProviders(providers);
  }
Exemple #3
0
  // 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();
  }