Search in sources :

Example 31 with MavenProject

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

the class AssignShortcutAction method getGoalActionId.

@Nullable
private static String getGoalActionId(DataContext context) {
    final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
    if (goals == null || goals.size() != 1) {
        return null;
    }
    MavenProject project = MavenActionUtil.getMavenProject(context);
    if (project == null)
        return null;
    String goal = goals.get(0);
    final MavenShortcutsManager shortcutsManager = getShortcutsManager(context);
    String actionId = shortcutsManager != null ? shortcutsManager.getActionId(project.getPath(), goal) : null;
    if (actionId != null) {
        AnAction action = ActionManager.getInstance().getAction(actionId);
        if (action == null) {
            MavenKeymapExtension.getOrRegisterAction(project, actionId, goal);
        }
    }
    return actionId;
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenShortcutsManager(org.jetbrains.idea.maven.tasks.MavenShortcutsManager) AnAction(com.intellij.openapi.actionSystem.AnAction) Nullable(org.jetbrains.annotations.Nullable)

Example 32 with MavenProject

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

the class AssignShortcutAction method isIgnoredProject.

private static boolean isIgnoredProject(DataContext context) {
    final MavenProject project = MavenActionUtil.getMavenProject(context);
    if (project == null)
        return false;
    final MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
    return projectsManager != null && projectsManager.isIgnored(project);
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager)

Example 33 with MavenProject

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

the class MavenBeforeRunTasksProvider method configureTask.

public boolean configureTask(RunConfiguration runConfiguration, MavenBeforeRunTask task) {
    MavenEditGoalDialog dialog = new MavenEditGoalDialog(myProject);
    dialog.setTitle(TasksBundle.message("maven.tasks.select.goal.title"));
    if (task.getGoal() == null) {
        // just created empty task.
        MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(myProject);
        List<MavenProject> rootProjects = projectsManager.getRootProjects();
        if (rootProjects.size() > 0) {
            dialog.setSelectedMavenProject(rootProjects.get(0));
        } else {
            dialog.setSelectedMavenProject(null);
        }
    } else {
        dialog.setGoals(task.getGoal());
        MavenProject mavenProject = getMavenProject(task);
        if (mavenProject != null) {
            dialog.setSelectedMavenProject(mavenProject);
        } else {
            dialog.setSelectedMavenProject(null);
        }
    }
    if (!dialog.showAndGet()) {
        return false;
    }
    task.setProjectPath(dialog.getWorkDirectory() + "/pom.xml");
    task.setGoal(dialog.getGoals());
    return true;
}
Also used : MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenEditGoalDialog(org.jetbrains.idea.maven.execution.MavenEditGoalDialog)

Example 34 with MavenProject

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

the class MavenShowEffectivePom method findPomXml.

@Nullable
private static VirtualFile findPomXml(@NotNull DataContext dataContext) {
    VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
    if (file == null)
        return null;
    if (file.isDirectory()) {
        file = file.findChild("pom.xml");
        if (file == null)
            return null;
    }
    MavenProjectsManager manager = MavenActionUtil.getProjectsManager(dataContext);
    if (manager == null)
        return null;
    MavenProject mavenProject = manager.findProject(file);
    if (mavenProject == null)
        return null;
    return file;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) Nullable(org.jetbrains.annotations.Nullable)

Example 35 with MavenProject

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

the class RunBuildAction method checkOrPerform.

private static boolean checkOrPerform(DataContext context, boolean perform) {
    final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
    if (goals == null || goals.isEmpty())
        return false;
    final Project project = MavenActionUtil.getProject(context);
    if (project == null)
        return false;
    final MavenProject mavenProject = MavenActionUtil.getMavenProject(context);
    if (mavenProject == null)
        return false;
    if (!perform)
        return true;
    final MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
    if (projectsManager == null)
        return false;
    MavenExplicitProfiles explicitProfiles = projectsManager.getExplicitProfiles();
    final MavenRunnerParameters params = new MavenRunnerParameters(true, mavenProject.getDirectory(), goals, explicitProfiles.getEnabledProfiles(), explicitProfiles.getDisabledProfiles());
    MavenRunConfigurationType.runConfiguration(project, params, null);
    return true;
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject) Project(com.intellij.openapi.project.Project) MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenExplicitProfiles(org.jetbrains.idea.maven.model.MavenExplicitProfiles) MavenRunnerParameters(org.jetbrains.idea.maven.execution.MavenRunnerParameters)

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