com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog Java Examples

The following examples show how to use com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProjectStructureValidator.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void showDialogAndAddLibraryToDependencies(final Library library, final Project project, boolean allowEmptySelection) {
  for (ProjectStructureValidator validator : EP_NAME.getExtensions()) {
    if (validator.addLibraryToDependencies(library, project, allowEmptySelection)) {
      return;
    }
  }

  final ModuleStructureConfigurable moduleStructureConfigurable = ModuleStructureConfigurable.getInstance(project);
  final List<Module> modules = LibraryEditingUtil.getSuitableModules(moduleStructureConfigurable, ((LibraryEx)library).getKind(), library);
  if (modules.isEmpty()) return;
  final ChooseModulesDialog
    dlg = new ChooseModulesDialog(moduleStructureConfigurable.getProject(), modules, ProjectBundle.message("choose.modules.dialog.title"),
                                  ProjectBundle
                                    .message("choose.modules.dialog.description", library.getName()));
  dlg.show();
  if (dlg.isOK()) {
    final List<Module> chosenModules = dlg.getChosenElements();
    for (Module module : chosenModules) {
      moduleStructureConfigurable.addLibraryOrderEntry(module, library);
    }
  }
}
 
Example #2
Source File: ModuleChooserDialogHelper.java    From ADB-Duang with MIT License 5 votes vote down vote up
public static AndroidFacet showDialogForFacets(Project project, List<AndroidFacet> facets) {
    List<Module> modules = Lists.newArrayList();
    String previousModuleName = getPreviousModuleName(project);
    List<Module> previousSelectedModule = null;
    for (AndroidFacet facet : facets) {
        Module module = facet.getModule();
        modules.add(module);
        if (module.getName().equals(previousModuleName)) {
            previousSelectedModule = Lists.newArrayList(module);
        }
    }

    ChooseModulesDialog dialog = new ChooseModulesDialog(project, modules, "Choose Module", "");
    dialog.setSingleSelectionMode();
    if (previousSelectedModule != null) {
        dialog.selectElements(previousSelectedModule);
    }
    dialog.show();

    List<Module> chosenElements = dialog.getChosenElements();
    if (chosenElements.isEmpty()) {
        return null;
    }

    Module chosenModule = chosenElements.get(0);
    saveModuleName(project, chosenModule.getName());
    int chosenModuleIndex = modules.indexOf(chosenModule);
    return facets.get(chosenModuleIndex);
}
 
Example #3
Source File: ModuleChooserDialogHelper.java    From ADBWIFI with Apache License 2.0 5 votes vote down vote up
public static AndroidFacet showDialogForFacets(Project project, List<AndroidFacet> facets) {
    List<Module> modules = Lists.newArrayList();
    String previousModuleName = getPreviousModuleName(project);
    List<Module> previousSelectedModule = null;
    for (AndroidFacet facet : facets) {
        Module module = facet.getModule();
        modules.add(module);
        if (module.getName().equals(previousModuleName)) {
            previousSelectedModule = Lists.newArrayList(module);
        }
    }

    ChooseModulesDialog dialog = new ChooseModulesDialog(project, modules, "Choose Module", "");
    dialog.setSingleSelectionMode();
    if (previousSelectedModule != null) {
        dialog.selectElements(previousSelectedModule);
    }
    dialog.show();

    List<Module> chosenElements = dialog.getChosenElements();
    if (chosenElements.isEmpty()) {
        return null;
    }

    Module chosenModule = chosenElements.get(0);
    saveModuleName(project, chosenModule.getName());
    int chosenModuleIndex = modules.indexOf(chosenModule);
    return facets.get(chosenModuleIndex);
}
 
Example #4
Source File: ArtifactEditorContextImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public List<Module> chooseModules(final List<Module> modules, final String title) {
  return new ChooseModulesDialog(getProject(), modules, title, null).showAndGetResult();
}