Search in sources :

Example 6 with ChooseModulesDialog

use of com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog in project android by JetBrains.

the class AndroidArtifactUtil method chooseAndroidApplicationModule.

@Nullable
public static AndroidFacet chooseAndroidApplicationModule(@NotNull Project project, @NotNull List<AndroidFacet> facets) {
    final Map<Module, AndroidFacet> map = new HashMap<Module, AndroidFacet>();
    for (AndroidFacet facet : facets) {
        map.put(facet.getModule(), facet);
    }
    String message = "Selected Android application module will be included in the created artifact with all dependencies";
    final ChooseModulesDialog dialog = new ChooseModulesDialog(project, new ArrayList<Module>(map.keySet()), "Select Module", message);
    dialog.setSingleSelectionMode();
    dialog.show();
    final List<Module> selected = dialog.getChosenElements();
    if (selected.isEmpty()) {
        return null;
    }
    assert selected.size() == 1;
    final Module module = selected.get(0);
    final String moduleName = module.getName();
    final AndroidFacet facet = map.get(module);
    if (facet == null) {
        message = "Cannot find Android facet for module " + moduleName;
        Messages.showErrorDialog(project, message, CommonBundle.getErrorTitle());
        return null;
    }
    return facet;
}
Also used : ChooseModulesDialog(com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog) HashMap(com.intellij.util.containers.HashMap) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Module (com.intellij.openapi.module.Module)6 ChooseModulesDialog (com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog)6 Project (com.intellij.openapi.project.Project)2 ArrayList (java.util.ArrayList)2 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)2 Facet (com.intellij.facet.Facet)1 ProjectFacetsConfigurator (com.intellij.facet.impl.ProjectFacetsConfigurator)1 ModuleStructureConfigurable (com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable)1 HashMap (com.intellij.util.containers.HashMap)1 Nullable (org.jetbrains.annotations.Nullable)1