use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class ToggleBeforeRunTaskAction method setSelected.
@Override
public void setSelected(final AnActionEvent e, boolean state) {
final DataContext context = e.getDataContext();
final Pair<MavenProject, String> desc = getTaskDesc(context);
if (desc != null) {
new MavenExecuteBeforeRunDialog(MavenActionUtil.getProject(context), desc.first, desc.second).show();
}
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class ToggleBeforeRunTaskAction method getTaskDesc.
@Nullable
protected static Pair<MavenProject, String> getTaskDesc(DataContext context) {
List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
if (goals == null || goals.size() != 1)
return null;
MavenProject mavenProject = MavenActionUtil.getMavenProject(context);
if (mavenProject == null)
return null;
return Pair.create(mavenProject, goals.get(0));
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class ToggleCompilerTasksAction method getTasks.
protected static List<MavenCompilerTask> getTasks(DataContext context) {
final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
if (goals == null || goals.isEmpty())
return Collections.emptyList();
MavenProject project = MavenActionUtil.getMavenProject(context);
if (project == null)
return Collections.emptyList();
List<MavenCompilerTask> result = new ArrayList<>();
for (String each : goals) {
result.add(new MavenCompilerTask(project.getPath(), each));
}
return result;
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class MavenAttachSourcesProvider method getMavenProjects.
private static Collection<MavenProject> getMavenProjects(PsiFile psiFile) {
Project project = psiFile.getProject();
Collection<MavenProject> result = new ArrayList<>();
for (OrderEntry each : ProjectRootManager.getInstance(project).getFileIndex().getOrderEntriesForFile(psiFile.getVirtualFile())) {
MavenProject mavenProject = MavenProjectsManager.getInstance(project).findProject(each.getOwnerModule());
if (mavenProject != null)
result.add(mavenProject);
}
return result;
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class MavenShowEffectivePom method actionPerformed.
public static void actionPerformed(@NotNull final Project project, @NotNull final VirtualFile file) {
final MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
final MavenProject mavenProject = manager.findProject(file);
assert mavenProject != null;
manager.evaluateEffectivePom(mavenProject, s -> ApplicationManager.getApplication().invokeLater(() -> {
if (project.isDisposed())
return;
if (s == null) {
new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP, "Error", "Failed to evaluate effective pom.", NotificationType.ERROR).notify(project);
return;
}
String fileName = mavenProject.getMavenId().getArtifactId() + "-effective-pom.xml";
PsiFile file1 = PsiFileFactory.getInstance(project).createFileFromText(fileName, XMLLanguage.INSTANCE, s);
try {
file1.getVirtualFile().setWritable(false);
} catch (IOException e) {
LOG.error(e);
}
file1.navigate(true);
}));
}
Aggregations