use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class SelectMavenProjectDialog method createCenterPanel.
protected JComponent createCenterPanel() {
ComboBoxUtil.setModel(myMavenProjectsComboBox, new DefaultComboBoxModel(), myMavenDomProjectModels, model -> {
String projectName = model.getName().getStringValue();
MavenProject mavenProject = MavenDomUtil.findProject(model);
if (mavenProject != null) {
projectName = mavenProject.getDisplayName();
}
if (StringUtil.isEmptyOrSpaces(projectName)) {
projectName = "pom.xml";
}
return Pair.create(projectName, model);
});
myReplaceAllListener = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateControls();
}
};
myMavenProjectsComboBox.addItemListener(myReplaceAllListener);
myMavenProjectsComboBox.setSelectedItem(0);
myReplaceAllCheckBox.setVisible(myHasUsagesInProjects);
myExtractExclusions.setVisible(myHasExclusions);
updateControls();
return myMainPanel;
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class IntroducePropertyDialog method createCenterPanel.
protected JComponent createCenterPanel() {
myFieldNamePanel.setLayout(new BorderLayout());
myNameField = new NameSuggestionsField(myProject);
myNameChangedListener = new NameSuggestionsField.DataChanged() {
public void dataChanged() {
updateOkStatus();
}
};
myNameField.addDataChangedListener(myNameChangedListener);
myNameField.setSuggestions(getSuggestions());
myFieldNamePanel.add(myNameField, BorderLayout.CENTER);
List<MavenDomProjectModel> projects = getProjects();
ComboBoxUtil.setModel(myMavenProjectsComboBox, new DefaultComboBoxModel(), projects, model -> {
String projectName = model.getName().getStringValue();
MavenProject mavenProject = MavenDomUtil.findProject(model);
if (mavenProject != null) {
projectName = mavenProject.getDisplayName();
}
if (StringUtil.isEmptyOrSpaces(projectName)) {
projectName = "pom.xml";
}
return Pair.create(projectName, model);
});
myMavenProjectsComboBox.setSelectedItem(myMavenDomProjectModel);
return myMainPanel;
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class MavenFilteredPropertyPsiReferenceProvider method getReferencesByElement.
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
if (!shouldAddReference(element)) {
// Add reference to element with one child or leaf element only to avoid performance problem.
return PsiReference.EMPTY_ARRAY;
}
if (!MavenDomUtil.isFilteredResourceFile(element))
return PsiReference.EMPTY_ARRAY;
String text = element.getText();
if (StringUtil.isEmptyOrSpaces(text))
return PsiReference.EMPTY_ARRAY;
MavenProject mavenProject = MavenDomUtil.findContainingProject(element);
if (mavenProject == null)
return PsiReference.EMPTY_ARRAY;
List<PsiReference> res = null;
Pattern pattern = getDelimitersPattern(mavenProject);
Matcher matcher = pattern.matcher(text);
int groupCount = matcher.groupCount();
while (matcher.find()) {
String propertyName = null;
int from = 0;
for (int i = 0; i < groupCount; i++) {
propertyName = matcher.group(i + 1);
if (propertyName != null) {
from = matcher.start(i + 1);
break;
}
}
assert propertyName != null;
if (res == null) {
res = new ArrayList<>();
}
TextRange range = TextRange.from(from, propertyName.length());
res.add(new MavenFilteredPropertyPsiReference(mavenProject, element, propertyName, range));
}
return res == null ? PsiReference.EMPTY_ARRAY : res.toArray(new PsiReference[res.size()]);
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class MavenDomUtil method updateMavenParent.
public static MavenDomParent updateMavenParent(MavenDomProjectModel mavenModel, MavenProject parentProject) {
MavenDomParent result = mavenModel.getMavenParent();
VirtualFile pomFile = DomUtil.getFile(mavenModel).getVirtualFile();
Project project = mavenModel.getXmlElement().getProject();
MavenId parentId = parentProject.getMavenId();
result.getGroupId().setStringValue(parentId.getGroupId());
result.getArtifactId().setStringValue(parentId.getArtifactId());
result.getVersion().setStringValue(parentId.getVersion());
if (!Comparing.equal(pomFile.getParent().getParent(), parentProject.getDirectoryFile())) {
result.getRelativePath().setValue(PsiManager.getInstance(project).findFile(parentProject.getFile()));
}
return result;
}
use of org.jetbrains.idea.maven.project.MavenProject in project intellij-community by JetBrains.
the class MavenPropertyResolver method doFilterText.
public static void doFilterText(Module module, String text, Properties additionalProperties, @Nullable String propertyEscapeString, Appendable out) throws IOException {
MavenProjectsManager manager = MavenProjectsManager.getInstance(module.getProject());
MavenProject mavenProject = manager.findProject(module);
if (mavenProject == null) {
out.append(text);
return;
}
Element pluginConfiguration = mavenProject.getPluginConfiguration("org.apache.maven.plugins", "maven-resources-plugin");
String escapeWindowsPathsStr = MavenJDOMUtil.findChildValueByPath(pluginConfiguration, "escapeWindowsPaths");
boolean escapeWindowsPath = escapeWindowsPathsStr == null || Boolean.parseBoolean(escapeWindowsPathsStr);
doFilterText(MavenFilteredPropertyPsiReferenceProvider.getDelimitersPattern(mavenProject), manager, mavenProject, text, additionalProperties, propertyEscapeString, escapeWindowsPath, null, out);
}
Aggregations