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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations