本文整理汇总了Java中org.jetbrains.idea.maven.project.MavenProjectsManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java MavenProjectsManager.getInstance方法的具体用法?Java MavenProjectsManager.getInstance怎么用?Java MavenProjectsManager.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jetbrains.idea.maven.project.MavenProjectsManager
的用法示例。
在下文中一共展示了MavenProjectsManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findContainingMavenizedModule
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
@Nullable
public static Module findContainingMavenizedModule(@NotNull PsiFile psiFile) {
VirtualFile file = psiFile.getVirtualFile();
if (file == null) return null;
Project project = psiFile.getProject();
MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
if (!manager.isMavenizedProject()) return null;
ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
Module module = index.getModuleForFile(file);
if (module == null || !manager.isMavenizedModule(module)) return null;
return module;
}
示例2: fillCompletionVariants
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
@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));
}
示例3: isFilteredResourceFile
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
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;
}
示例4: resolve
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
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) {
throw new RuntimeException(e); // never thrown
}
return res.toString();
}
示例5: getMuleApp
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
@NotNull
public File getMuleApp(@NotNull Module module) throws ExecutionException {
final MavenProjectsManager instance = MavenProjectsManager.getInstance(module.getProject());
if (instance.hasProjects()) {
return new MuleAppMavenHandler().getMuleApp(module);
}
throw new ExecutionException("Unable to find application builder");
}
示例6: getMavenProject
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
private MavenProject getMavenProject(Module module) { //RunConfiguration runConfiguration, Project project)
final MavenProjectsManager instance = MavenProjectsManager.getInstance(module.getProject());
return instance.findProject(module);
//
// if (runConfiguration instanceof MuleConfiguration)
// {
// MuleConfiguration muleConfiguration = (MuleConfiguration) runConfiguration;
// return instance.findProject(muleConfiguration.getModule());
// }
// return null;
}
示例7: configureTask
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
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;
}
示例8: getEditorTabTitle
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
public String getEditorTabTitle(Project project, VirtualFile file) {
MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(project);
if (!projectsManager.isMavenizedProject()) return null;
MavenProject mavenProject = projectsManager.findProject(file);
if (mavenProject == null) return null;
return mavenProject.getMavenId().getArtifactId();
}
示例9: MavenPsiReference
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
public MavenPsiReference(@NotNull PsiElement element, @NotNull String text, @NotNull TextRange range) {
myProject = element.getProject();
myProjectsManager = MavenProjectsManager.getInstance(myProject);
myPsiFile = element.getContainingFile().getOriginalFile();
myVirtualFile = myPsiFile.getVirtualFile();
myElement = element;
myText = text;
myRange = range;
}
示例10: importData
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
@Override
public boolean importData(final TransferSupport support) {
if (canImport(support)) {
List<VirtualFile> pomFiles = new ArrayList<VirtualFile>();
final List<File> fileList = FileCopyPasteUtil.getFileList(support.getTransferable());
if (fileList == null) return false;
MavenProjectsManager manager = MavenProjectsManager.getInstance(myProject);
for (File file : fileList) {
VirtualFile virtualFile = VfsUtil.findFileByIoFile(file, true);
if (file.isFile()
&& virtualFile != null
&& MavenActionUtil.isMavenProjectFile(virtualFile)
&& !manager.isManagedFile(virtualFile)) {
pomFiles.add(virtualFile);
}
}
if (pomFiles.isEmpty()) {
return false;
}
manager.addManagedFilesOrUnignore(pomFiles);
return true;
}
return false;
}
示例11: resolve
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
@Override
public PsiFile resolve(MavenId id, ConvertContext context) {
PsiFile res = super.resolve(id, context);
if (res != null) return res;
// Try to resolve to imported plugin
MavenProject mavenProject = findMavenProject(context);
if (mavenProject != null) {
for (MavenPlugin plugin : mavenProject.getPlugins()) {
if (MavenArtifactUtil.isPluginIdEquals(id.getGroupId(), id.getArtifactId(), plugin.getGroupId(), plugin.getArtifactId())) {
return super.resolve(plugin.getMavenId(), context);
}
}
}
// Try to resolve to plugin with latest version
PsiManager psiManager = context.getPsiManager();
MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(psiManager.getProject());
File artifactFile = MavenArtifactUtil
.getArtifactFile(projectsManager.getLocalRepository(), id.getGroupId(), id.getArtifactId(), id.getVersion(), "pom");
VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(artifactFile);
if (virtualFile != null) {
return psiManager.findFile(virtualFile);
}
return null;
}
示例12: updateProjectFolders
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
public static void updateProjectFolders(final Project project, final boolean updateTargetFoldersOnly) {
final MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
final MavenImportingSettings settings = manager.getImportingSettings();
AccessToken accessToken = WriteAction.start();
try {
List<ModifiableRootModel> rootModels = new ArrayList<ModifiableRootModel>();
for (Module each : ModuleManager.getInstance(project).getModules()) {
MavenProject mavenProject = manager.findProject(each);
if (mavenProject == null) continue;
MavenRootModelAdapter a = new MavenRootModelAdapter(mavenProject, each, new IdeModifiableModelsProviderImpl(project));
new MavenFoldersImporter(mavenProject, settings, a).config(updateTargetFoldersOnly);
ModifiableRootModel model = a.getRootModel();
if (model.isChanged()) {
rootModels.add(model);
}
else {
model.dispose();
}
}
if (!rootModels.isEmpty()) {
ModifiableRootModel[] modelsArray = rootModels.toArray(new ModifiableRootModel[rootModels.size()]);
if (modelsArray.length > 0) {
ModifiableModelCommitter.multiCommit(modelsArray, ModuleManager.getInstance(modelsArray[0].getProject()).getModifiableModel());
}
}
}
finally {
accessToken.finish();
}
}
示例13: findContainingProject
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
@Nullable
public static MavenProject findContainingProject(@NotNull PsiElement element) {
VirtualFile file = getVirtualFile(element);
if (file == null) return null;
MavenProjectsManager manager = MavenProjectsManager.getInstance(element.getProject());
return manager.findContainingProject(file);
}
示例14: isElementInsideManagedFile
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
private static boolean isElementInsideManagedFile(GenericDomValue value) {
VirtualFile virtualFile = DomUtil.getFile(value).getVirtualFile();
if (virtualFile == null) {
return false;
}
MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(value.getManager().getProject());
return projectsManager.findProject(virtualFile) != null;
}
示例15: findMavenProject
import org.jetbrains.idea.maven.project.MavenProjectsManager; //导入方法依赖的package包/类
@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);
}