Search in sources :

Example 41 with MavenProjectsManager

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

the class MavenRunnerPanel method collectProperties.

private void collectProperties() {
    MavenProjectsManager s = MavenProjectsManager.getInstance(myProject);
    Map<String, String> result = new LinkedHashMap<>();
    for (MavenProject each : s.getProjects()) {
        Properties properties = each.getProperties();
        result.putAll((Map) properties);
    }
    myProperties = result;
}
Also used : MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) Properties(java.util.Properties) LinkedHashMap(java.util.LinkedHashMap)

Example 42 with MavenProjectsManager

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

the class MavenEditGoalDialog method setUpDialog.

private void setUpDialog() {
    JComponent goalComponent;
    if (myHistory == null) {
        goalsEditor = new EditorTextField("", myProject, PlainTextFileType.INSTANCE);
        goalComponent = goalsEditor;
        goalsLabel.setLabelFor(goalsEditor);
    } else {
        goalsComboBox = new ComboBox(ArrayUtilRt.toStringArray(myHistory));
        goalComponent = goalsComboBox;
        goalsLabel.setLabelFor(goalsComboBox);
        goalsComboBox.setLightWeightPopupEnabled(false);
        EditorComboBoxEditor editor = new StringComboboxEditor(myProject, PlainTextFileType.INSTANCE, goalsComboBox);
        goalsComboBox.setRenderer(new EditorComboBoxRenderer(editor));
        goalsComboBox.setEditable(true);
        goalsComboBox.setEditor(editor);
        goalsComboBox.setFocusable(true);
        goalsEditor = editor.getEditorComponent();
    }
    goalsPanel.add(goalComponent);
    new MavenArgumentsCompletionProvider(myProject).apply(goalsEditor);
    MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(myProject);
    showProjectTreeButton.setIcon(AllIcons.Actions.Module);
    MavenSelectProjectPopup.attachToWorkingDirectoryField(projectsManager, workDirectoryField.getTextField(), showProjectTreeButton, goalsComboBox != null ? goalsComboBox : goalsEditor);
    workDirectoryField.addBrowseFolderListener(RunnerBundle.message("maven.select.maven.project.file"), "", myProject, new FileChooserDescriptor(false, true, false, false, false, false) {

        @Override
        public boolean isFileSelectable(VirtualFile file) {
            if (!super.isFileSelectable(file))
                return false;
            for (VirtualFile child : file.getChildren()) {
                if (MavenUtil.isPomFileName(child.getName()))
                    return true;
            }
            return false;
        }
    });
}
Also used : EditorComboBoxEditor(com.intellij.ui.EditorComboBoxEditor) VirtualFile(com.intellij.openapi.vfs.VirtualFile) StringComboboxEditor(com.intellij.ui.StringComboboxEditor) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) EditorTextField(com.intellij.ui.EditorTextField) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) EditorComboBoxRenderer(com.intellij.ui.EditorComboBoxRenderer)

Example 43 with MavenProjectsManager

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

the class MavenPropertyResolver method resolve.

public static String resolve(String text, MavenDomProjectModel projectDom) {
    XmlElement element = projectDom.getXmlElement();
    if (element == null)
        return text;
    VirtualFile file = MavenDomUtil.getVirtualFile(element);
    if (file == null)
        return text;
    MavenProjectsManager manager = MavenProjectsManager.getInstance(projectDom.getManager().getProject());
    MavenProject mavenProject = manager.findProject(file);
    if (mavenProject == null)
        return text;
    StringBuilder res = new StringBuilder();
    try {
        doFilterText(PATTERN, manager, mavenProject, text, collectPropertiesFromDOM(mavenProject, projectDom), null, false, null, res);
    } catch (IOException e) {
        // never thrown
        throw new RuntimeException(e);
    }
    return res.toString();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) XmlElement(com.intellij.psi.xml.XmlElement) IOException(java.io.IOException)

Example 44 with MavenProjectsManager

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

the class MavenDomUtil method findProject.

@Nullable
public static MavenProject findProject(@NotNull MavenDomProjectModel projectDom) {
    XmlElement element = projectDom.getXmlElement();
    if (element == null)
        return null;
    VirtualFile file = getVirtualFile(element);
    if (file == null)
        return null;
    MavenProjectsManager manager = MavenProjectsManager.getInstance(element.getProject());
    return manager.findProject(file);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) XmlElement(com.intellij.psi.xml.XmlElement) Nullable(org.jetbrains.annotations.Nullable)

Example 45 with MavenProjectsManager

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

the class MavenDomUtil method isFilteredResourceFile.

public static boolean isFilteredResourceFile(PsiElement element) {
    PsiFile psiFile = element.getContainingFile();
    VirtualFile file = getVirtualFile(psiFile);
    if (file == null)
        return false;
    MavenProjectsManager manager = MavenProjectsManager.getInstance(psiFile.getProject());
    MavenProject mavenProject = manager.findContainingProject(file);
    if (mavenProject == null)
        return false;
    Set<VirtualFile> filteredRoots = getFilteredResourcesRoots(mavenProject);
    if (!filteredRoots.isEmpty()) {
        for (VirtualFile f = file.getParent(); f != null; f = f.getParent()) {
            if (filteredRoots.contains(f)) {
                return true;
            }
        }
    }
    return false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) MavenProject(org.jetbrains.idea.maven.project.MavenProject) PsiFile(com.intellij.psi.PsiFile)

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