Search in sources :

Example 6 with MavenProjectsManager

use of org.jetbrains.idea.maven.project.MavenProjectsManager 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 7 with MavenProjectsManager

use of org.jetbrains.idea.maven.project.MavenProjectsManager 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 8 with MavenProjectsManager

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

the class AddManagedFilesAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    final MavenProjectsManager manager = MavenActionUtil.getProjectsManager(e.getDataContext());
    if (manager == null)
        return;
    FileChooserDescriptor singlePomSelection = new FileChooserDescriptor(true, false, false, false, false, true) {

        @Override
        public boolean isFileSelectable(VirtualFile file) {
            return super.isFileSelectable(file) && !manager.isManagedFile(file);
        }

        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            if (!file.isDirectory() && !MavenActionUtil.isMavenProjectFile(file))
                return false;
            return super.isFileVisible(file, showHiddenFiles);
        }
    };
    Project project = MavenActionUtil.getProject(e.getDataContext());
    VirtualFile fileToSelect = e.getData(CommonDataKeys.VIRTUAL_FILE);
    VirtualFile[] files = FileChooser.chooseFiles(singlePomSelection, project, fileToSelect);
    if (files.length == 0)
        return;
    manager.addManagedFilesOrUnignore(Arrays.asList(files));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor)

Example 9 with MavenProjectsManager

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

the class MavenProjectsAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    final DataContext context = e.getDataContext();
    final MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
    if (projectsManager == null)
        return;
    perform(projectsManager, MavenActionUtil.getMavenProjects(context), e);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager)

Example 10 with MavenProjectsManager

use of org.jetbrains.idea.maven.project.MavenProjectsManager 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)

Aggregations

MavenProjectsManager (org.jetbrains.idea.maven.project.MavenProjectsManager)52 MavenProject (org.jetbrains.idea.maven.project.MavenProject)29 VirtualFile (com.intellij.openapi.vfs.VirtualFile)24 Project (com.intellij.openapi.project.Project)13 Module (com.intellij.openapi.module.Module)8 File (java.io.File)8 Nullable (org.jetbrains.annotations.Nullable)8 DataContext (com.intellij.openapi.actionSystem.DataContext)6 PsiFile (com.intellij.psi.PsiFile)6 Notification (com.intellij.notification.Notification)4 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)4 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 MavenRunnerParameters (org.jetbrains.idea.maven.execution.MavenRunnerParameters)4 MavenExplicitProfiles (org.jetbrains.idea.maven.model.MavenExplicitProfiles)4 NotificationListener (com.intellij.notification.NotificationListener)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)2 XmlElement (com.intellij.psi.xml.XmlElement)2 List (java.util.List)2