Search in sources :

Example 1 with ChooseModulesDialog

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

the class TargetOptionsComponent method addModules.

private void addModules() {
    final TargetLevelTableModel model = (TargetLevelTableModel) myTable.getModel();
    final List<Module> items = new ArrayList<>(Arrays.asList(ModuleManager.getInstance(myProject).getModules()));
    Set<Module> alreadyAdded = new HashSet<>();
    for (TargetLevelTableModel.Item item : model.getItems()) {
        alreadyAdded.add(item.module);
    }
    for (Iterator<Module> it = items.iterator(); it.hasNext(); ) {
        Module module = it.next();
        if (alreadyAdded.contains(module)) {
            it.remove();
        }
    }
    Collections.sort(items, (o1, o2) -> o1.getName().compareTo(o2.getName()));
    final ChooseModulesDialog chooser = new ChooseModulesDialog(this, items, "Choose module");
    chooser.show();
    final List<Module> elements = chooser.getChosenElements();
    if (!elements.isEmpty()) {
        model.addItems(elements);
        int i = model.getModuleRow(elements.get(0));
        if (i != -1) {
            TableUtil.selectRows(myTable, new int[] { i });
            TableUtil.scrollSelectionToVisible(myTable);
        }
    }
}
Also used : ChooseModulesDialog(com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog) Module(com.intellij.openapi.module.Module)

Example 2 with ChooseModulesDialog

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

the class ProjectStructureValidator method showDialogAndAddLibraryToDependencies.

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()));
    if (dlg.showAndGet()) {
        final List<Module> chosenModules = dlg.getChosenElements();
        for (Module module : chosenModules) {
            moduleStructureConfigurable.addLibraryOrderEntry(module, library);
        }
    }
}
Also used : ModuleStructureConfigurable(com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureConfigurable) ChooseModulesDialog(com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog) Module(com.intellij.openapi.module.Module)

Example 3 with ChooseModulesDialog

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

the class AddFacetOfTypeAction method addFacetToModule.

private void addFacetToModule(@NotNull FacetType type) {
    final ProjectFacetsConfigurator facetsConfigurator = myContext.getModulesConfigurator().getFacetsConfigurator();
    List<Module> suitableModules = new ArrayList<>(Arrays.asList(myContext.getModules()));
    final Iterator<Module> iterator = suitableModules.iterator();
    while (iterator.hasNext()) {
        Module module = iterator.next();
        if (!type.isSuitableModuleType(ModuleType.get(module)) || (type.isOnlyOneFacetAllowed() && facetsConfigurator.hasFacetOfType(module, null, type.getId()))) {
            iterator.remove();
        }
    }
    final Project project = myContext.getProject();
    if (suitableModules.isEmpty()) {
        Messages.showErrorDialog(project, "No suitable modules for " + type.getPresentableName() + " facet found.", "Cannot Create Facet");
        return;
    }
    final ChooseModulesDialog dialog = new ChooseModulesDialog(project, suitableModules, "Choose Module", type.getPresentableName() + " facet will be added to selected module");
    dialog.setSingleSelectionMode();
    dialog.show();
    final List<Module> elements = dialog.getChosenElements();
    if (!dialog.isOK() || elements.size() != 1)
        return;
    final Module module = elements.get(0);
    final Facet facet = ModuleStructureConfigurable.getInstance(project).getFacetEditorFacade().createAndAddFacet(type, module, null);
    ProjectStructureConfigurable.getInstance(project).select(facet, true);
}
Also used : Project(com.intellij.openapi.project.Project) ChooseModulesDialog(com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog) ArrayList(java.util.ArrayList) ProjectFacetsConfigurator(com.intellij.facet.impl.ProjectFacetsConfigurator) Module(com.intellij.openapi.module.Module) Facet(com.intellij.facet.Facet)

Example 4 with ChooseModulesDialog

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

the class PrepareAllToDeployAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null)
        return;
    List<Module> pluginModules = new ArrayList<>();
    for (Module aModule : ModuleManager.getInstance(project).getModules()) {
        if (PluginModuleType.isOfType(aModule)) {
            pluginModules.add(aModule);
        }
    }
    ChooseModulesDialog dialog = new ChooseModulesDialog(project, pluginModules, DevKitBundle.message("select.plugin.modules.title"), DevKitBundle.message("select.plugin.modules.description"));
    if (dialog.showAndGet()) {
        doPrepare(dialog.getChosenElements(), project);
    }
}
Also used : Project(com.intellij.openapi.project.Project) ChooseModulesDialog(com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog) ArrayList(java.util.ArrayList) Module(com.intellij.openapi.module.Module)

Example 5 with ChooseModulesDialog

use of com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog in project adb-idea by pbreault.

the class ModuleChooserDialogHelper method showDialogForFacets.

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);
}
Also used : ChooseModulesDialog(com.intellij.openapi.roots.ui.configuration.ChooseModulesDialog) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

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