use of org.jetbrains.idea.maven.project.MavenProjectsManager in project intellij-community by JetBrains.
the class RemoveManagedFilesAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final DataContext context = e.getDataContext();
MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
if (projectsManager == null)
return;
List<VirtualFile> selectedFiles = MavenActionUtil.getMavenProjectsFiles(context);
List<VirtualFile> removableFiles = new ArrayList<>();
for (VirtualFile pomXml : selectedFiles) {
if (projectsManager.isManagedFile(pomXml)) {
removableFiles.add(pomXml);
} else {
notifyUserIfNeeded(context, projectsManager, selectedFiles, pomXml);
}
}
projectsManager.removeManagedFiles(removableFiles);
}
use of org.jetbrains.idea.maven.project.MavenProjectsManager 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;
}
use of org.jetbrains.idea.maven.project.MavenProjectsManager in project intellij-community by JetBrains.
the class ToggleIgnoredProjectsAction method isAvailable.
@Override
protected boolean isAvailable(AnActionEvent e) {
if (!super.isAvailable(e))
return false;
final DataContext context = e.getDataContext();
MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
if (projectsManager == null)
return false;
List<MavenProject> projects = MavenActionUtil.getMavenProjects(context);
if (projects == null || projects.isEmpty())
return false;
int ignoredStatesCount = 0;
int ignoredCount = 0;
for (MavenProject each : projects) {
if (projectsManager.getIgnoredState(each)) {
ignoredStatesCount++;
}
if (projectsManager.isIgnored(each)) {
ignoredCount++;
}
}
return (ignoredCount == 0 || ignoredCount == projects.size()) && (ignoredStatesCount == 0 || ignoredStatesCount == projects.size());
}
use of org.jetbrains.idea.maven.project.MavenProjectsManager in project intellij-community by JetBrains.
the class MavenPropertyCompletionContributor method fillCompletionVariants.
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
PsiFile psiFile = parameters.getOriginalFile();
Project project = psiFile.getProject();
MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
if (!manager.isMavenizedProject())
return;
MavenProject projectFile = MavenDomUtil.findContainingProject(psiFile);
if (projectFile == null)
return;
if (!MavenDomUtil.isMavenFile(psiFile) && !MavenDomUtil.isFilteredResourceFile(psiFile))
return;
String text = psiFile.getText();
int offset = parameters.getOffset();
int braceOffset = findOpenBrace(text, offset);
if (braceOffset == -1)
return;
TextRange range = TextRange.create(braceOffset, offset);
String prefix = range.substring(text);
MavenFilteredPropertyPsiReference ref = new MavenFilteredPropertyPsiReference(projectFile, psiFile, prefix, range);
addVariants(Arrays.asList(ref.getVariants()), result.withPrefixMatcher(prefix));
}
use of org.jetbrains.idea.maven.project.MavenProjectsManager in project intellij-community by JetBrains.
the class MavenPropertyPsiReferenceProvider method findMavenProject.
@Nullable
private static MavenProject findMavenProject(PsiElement element) {
VirtualFile virtualFile = MavenDomUtil.getVirtualFile(element);
if (virtualFile == null)
return null;
MavenProjectsManager manager = MavenProjectsManager.getInstance(element.getProject());
return manager.findProject(virtualFile);
}
Aggregations