<commit_before>/*
 * Copyright 2000-2012 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.execution.ui;

import com.intellij.application.options.ModuleDescriptionsComboBox;
import com.intellij.application.options.ModuleListCellRenderer;
import com.intellij.application.options.ModulesCombo;
import com.intellij.application.options.ModulesComboBox;
import com.intellij.core.JavaPsiBundle;
import com.intellij.execution.configurations.JavaRunConfigurationModule;
import com.intellij.execution.configurations.ModuleBasedConfiguration;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.ModuleTypeManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ui.configuration.ModulesAlphaComparator;
import com.intellij.openapi.util.NlsContexts;
import com.intellij.psi.PsiClass;
import com.intellij.ui.ComboboxSpeedSearch;
import com.intellij.ui.SortedComboBoxModel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class ConfigurationModuleSelector {
  @NotNull
  private final Project myProject;
  /** this field is {@code null} if and only if {@link #myModulesList} is not null */
  private final ModulesCombo myModulesDescriptionsComboBox;
  /** this field is {@code null} if and only if {@link #myModulesDescriptionsComboBox} is not null */
  private final JComboBox<? extends Module> myModulesList;

  /**
   * @deprecated use {@link #ConfigurationModuleSelector(Project, ModulesComboBox)} instead
   */
  @Deprecated
  public ConfigurationModuleSelector(@NotNull Project project, final JComboBox<? extends Module> modulesList) {
    this(project, modulesList, JavaPsiBundle.message("list.item.no.module"));
  }

  public ConfigurationModuleSelector(@NotNull Project project, ModulesComboBox modulesComboBox) {
    this(project, modulesComboBox, JavaPsiBundle.message("list.item.no.module"));
  }

  public ConfigurationModuleSelector(@NotNull Project project, ModuleDescriptionsComboBox modulesDescriptionsComboBox) {
    this(project, modulesDescriptionsComboBox, JavaPsiBundle.message("list.item.no.module"));
  }

  public ConfigurationModuleSelector(@NotNull Project project, ModulesCombo modulesDescriptionsComboBox) {
    this(project, modulesDescriptionsComboBox, JavaPsiBundle.message("list.item.no.module"));
  }

  private ConfigurationModuleSelector(@NotNull Project project, ModulesCombo modulesDescriptionsComboBox, @NlsContexts.ListItem @NotNull String emptySelectionText) {
    myProject = project;
    myModulesDescriptionsComboBox = modulesDescriptionsComboBox;
    myModulesList = null;
    modulesDescriptionsComboBox.allowEmptySelection(emptySelectionText);
  }

  public ConfigurationModuleSelector(@NotNull Project project, ModulesComboBox modulesComboBox, @NlsContexts.ListItem String noModule) {
    myProject = project;
    myModulesList = modulesComboBox;
    myModulesDescriptionsComboBox = null;
    modulesComboBox.allowEmptySelection(noModule);
  }

  /**
   * @deprecated use {@link #ConfigurationModuleSelector(Project, ModulesComboBox, String)} instead
   */
  @Deprecated
  public ConfigurationModuleSelector(@NotNull Project project, final JComboBox<? extends Module> modulesList, final @NlsContexts.ListItem String noModule) {
    myProject = project;
    myModulesList = modulesList;<commit_msg>IDEA-258146 JUnit configuration editor: <no module> is present in the popup but not selectable<commit_after>/*
 * Copyright 2000-2012 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.execution.ui;

import com.intellij.application.options.ModuleDescriptionsComboBox;
import com.intellij.application.options.ModuleListCellRenderer;
import com.intellij.application.options.ModulesCombo;
import com.intellij.application.options.ModulesComboBox;
import com.intellij.core.JavaPsiBundle;
import com.intellij.execution.configurations.JavaRunConfigurationModule;
import com.intellij.execution.configurations.ModuleBasedConfiguration;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.ModuleTypeManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ui.configuration.ModulesAlphaComparator;
import com.intellij.openapi.util.NlsContexts;
import com.intellij.psi.PsiClass;
import com.intellij.ui.ComboboxSpeedSearch;
import com.intellij.ui.SortedComboBoxModel;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class ConfigurationModuleSelector {
  @NotNull
  private final Project myProject;
  /** this field is {@code null} if and only if {@link #myModulesList} is not null */
  private final ModulesCombo myModulesDescriptionsComboBox;
  /** this field is {@code null} if and only if {@link #myModulesDescriptionsComboBox} is not null */
  private final JComboBox<? extends Module> myModulesList;

  /**
   * @deprecated use {@link #ConfigurationModuleSelector(Project, ModulesComboBox)} instead
   */
  @Deprecated
  public ConfigurationModuleSelector(@NotNull Project project, final JComboBox<? extends Module> modulesList) {
    this(project, modulesList, JavaPsiBundle.message("list.item.no.module"));
  }

  public ConfigurationModuleSelector(@NotNull Project project, ModulesComboBox modulesComboBox) {
    this(project, modulesComboBox, JavaPsiBundle.message("list.item.no.module"));
  }

  public ConfigurationModuleSelector(@NotNull Project project, ModuleDescriptionsComboBox modulesDescriptionsComboBox) {
    this(project, modulesDescriptionsComboBox, JavaPsiBundle.message("list.item.no.module"));
  }

  public ConfigurationModuleSelector(@NotNull Project project, ModulesCombo modulesDescriptionsComboBox) {
    this(project, modulesDescriptionsComboBox, null);
  }

  private ConfigurationModuleSelector(@NotNull Project project, ModulesCombo modulesDescriptionsComboBox, @NlsContexts.ListItem @Nullable String emptySelectionText) {
    myProject = project;
    myModulesDescriptionsComboBox = modulesDescriptionsComboBox;
    myModulesList = null;
    if (emptySelectionText != null) {
      modulesDescriptionsComboBox.allowEmptySelection(emptySelectionText);
    }
  }

  public ConfigurationModuleSelector(@NotNull Project project, ModulesComboBox modulesComboBox, @NlsContexts.ListItem String noModule) {
    myProject = project;
    myModulesList = modulesComboBox;
    myModulesDescriptionsComboBox = null;
    modulesComboBox.allowEmptySelection(noModule);
  }

  /**
   * @deprecated use {@link #ConfigurationModuleSelector(Project, ModulesComboBox, String)} instead
   */
  @Deprecated
  public ConfigurationModuleSelector(@NotNull Project project, final JComboBox<? extends Module> modulesList, final @NlsContexts.ListItem String noModule) {
    myProject = project;
    myModulesList = modulesList;
{'fraction_non_alphanumeric': 0.08559650824442289, 'fraction_numerical': 0.0036372453928225023, 'mean_word_length': 5.789300411522634, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2374271', 'n_tokens_mistral': 2230, 'n_tokens_neox': 2213, 'n_words': 577}