Search in sources :

Example 86 with MavenProject

use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.

the class RemoveManagedFilesAction method notifyUserIfNeeded.

private static void notifyUserIfNeeded(DataContext context, MavenProjectsManager projectsManager, List<VirtualFile> selectedFiles, VirtualFile pomXml) {
    MavenProject mavenProject = projectsManager.findProject(pomXml);
    assert mavenProject != null;
    MavenProject aggregator = projectsManager.findAggregator(mavenProject);
    while (aggregator != null && !projectsManager.isManagedFile(aggregator.getFile())) {
        aggregator = projectsManager.findAggregator(aggregator);
    }
    if (aggregator != null && !selectedFiles.contains(aggregator.getFile())) {
        notifyUser(context, mavenProject, aggregator);
    }
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 87 with MavenProject

use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.

the class ToggleIgnoredProjectsAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    final DataContext context = e.getDataContext();
    MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
    if (projectsManager == null)
        return;
    List<MavenProject> projects = MavenActionUtil.getMavenProjects(context);
    final Project project = MavenActionUtil.getProject(context);
    if (project == null)
        return;
    if (isIgnoredInSettings(projectsManager, projects)) {
        ShowSettingsUtil.getInstance().editConfigurable(project, new MavenIgnoredFilesConfigurable(project));
    } else {
        projectsManager.setIgnoredState(projects, !isIgnored(projectsManager, projects));
    }
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenIgnoredFilesConfigurable(org.jetbrains.idea.maven.project.MavenIgnoredFilesConfigurable)

Example 88 with MavenProject

use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.

the class ToggleIgnoredProjectsAction method update.

@Override
public void update(AnActionEvent e) {
    super.update(e);
    if (!isAvailable(e))
        return;
    final DataContext context = e.getDataContext();
    MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
    if (projectsManager == null)
        return;
    List<MavenProject> projects = MavenActionUtil.getMavenProjects(context);
    if (isIgnoredInSettings(projectsManager, projects)) {
        e.getPresentation().setText(ProjectBundle.message("maven.ignore.edit"));
    } else if (isIgnored(projectsManager, projects)) {
        e.getPresentation().setText(ProjectBundle.message("maven.unignore"));
    } else {
        e.getPresentation().setText(ProjectBundle.message("maven.ignore"));
    }
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 89 with MavenProject

use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.

the class MavenKeymapExtension method createActions.

private static void createActions(Project project, List<MavenProject> mavenProjects) {
    ActionManager actionManager = ActionManager.getInstance();
    MavenShortcutsManager shortcutsManager = MavenShortcutsManager.getInstance(project);
    for (MavenProject eachProject : mavenProjects) {
        //noinspection TestOnlyProblems
        String actionIdPrefix = getActionPrefix(project, eachProject);
        for (MavenGoalAction eachAction : collectActions(eachProject)) {
            String id = actionIdPrefix + eachAction.getGoal();
            actionManager.unregisterAction(id);
            if (shortcutsManager.hasShortcuts(eachProject, eachAction.getGoal())) {
                actionManager.registerAction(id, eachAction);
            }
        }
    }
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 90 with MavenProject

use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.

the class MavenProjectNamer method generateNameMap.

//private static Logger LOG = Logger.getInstance(MavenProjectNamer.class);
public static Map<MavenProject, String> generateNameMap(Collection<MavenProject> mavenProjects) {
    MultiMap<String, MavenProject> artifactIdMap = new MultiMap<>();
    for (MavenProject project : mavenProjects) {
        artifactIdMap.putValue(project.getMavenId().getArtifactId(), project);
    }
    Map<MavenProject, String> res = new THashMap<>();
    for (Map.Entry<String, Collection<MavenProject>> entry : artifactIdMap.entrySet()) {
        List<MavenProject> projectList = (List<MavenProject>) entry.getValue();
        String artifactId = entry.getKey();
        if (projectList.size() == 1) {
            res.put(projectList.get(0), artifactId);
        } else if (allGroupsAreDifferent(projectList)) {
            for (MavenProject mavenProject : projectList) {
                res.put(mavenProject, mavenProject.getMavenId().getGroupId() + ':' + mavenProject.getMavenId().getArtifactId());
            }
        } else if (allGroupsEqual(mavenProjects)) {
            for (MavenProject mavenProject : projectList) {
                res.put(mavenProject, mavenProject.getMavenId().getArtifactId() + ':' + mavenProject.getMavenId().getVersion());
            }
        } else {
            for (MavenProject mavenProject : projectList) {
                MavenId mavenId = mavenProject.getMavenId();
                res.put(mavenProject, mavenId.getGroupId() + ':' + mavenId.getArtifactId() + ':' + mavenId.getVersion());
            }
        }
    }
    return res;
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) MavenId(org.jetbrains.idea.maven.model.MavenId) MavenProject(org.jetbrains.idea.maven.project.MavenProject) THashMap(gnu.trove.THashMap) THashMap(gnu.trove.THashMap) MultiMap(com.intellij.util.containers.MultiMap)

Aggregations

MavenProject (org.jetbrains.idea.maven.project.MavenProject)132 VirtualFile (com.intellij.openapi.vfs.VirtualFile)40 MavenProjectsManager (org.jetbrains.idea.maven.project.MavenProjectsManager)20 MavenId (org.jetbrains.idea.maven.model.MavenId)16 Project (com.intellij.openapi.project.Project)10 Nullable (org.jetbrains.annotations.Nullable)9 Bombed (com.intellij.idea.Bombed)8 Module (com.intellij.openapi.module.Module)6 DataContext (com.intellij.openapi.actionSystem.DataContext)5 File (java.io.File)5 ArrayList (java.util.ArrayList)5 Result (com.intellij.openapi.application.Result)4 MavenArtifact (org.jetbrains.idea.maven.model.MavenArtifact)4 MavenEmbeddersManager (org.jetbrains.idea.maven.project.MavenEmbeddersManager)4 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)3 TextRange (com.intellij.openapi.util.TextRange)3 NotNull (org.jetbrains.annotations.NotNull)3 MavenRunnerParameters (org.jetbrains.idea.maven.execution.MavenRunnerParameters)3 MavenExplicitProfiles (org.jetbrains.idea.maven.model.MavenExplicitProfiles)3 MavenProjectsTree (org.jetbrains.idea.maven.project.MavenProjectsTree)3