本文整理汇总了Java中com.intellij.openapi.roots.libraries.LibraryUtil.findLibraryEntry方法的典型用法代码示例。如果您正苦于以下问题:Java LibraryUtil.findLibraryEntry方法的具体用法?Java LibraryUtil.findLibraryEntry怎么用?Java LibraryUtil.findLibraryEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.libraries.LibraryUtil
的用法示例。
在下文中一共展示了LibraryUtil.findLibraryEntry方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: navigate
import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
@Override
public void navigate(final boolean requestFocus) {
Module module = ModuleUtil.findModuleForPsiElement(getValue());
if (module != null) {
final VirtualFile file = getVirtualFile();
final Project project = getProject();
ProjectSettingsService service = ProjectSettingsService.getInstance(myProject);
if (ProjectRootsUtil.isModuleContentRoot(file, project)) {
service.openModuleSettings(module);
}
else if (ProjectRootsUtil.isLibraryRoot(file, project)) {
final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(file, module.getProject());
if (orderEntry != null) {
service.openLibraryOrSdkSettings(orderEntry);
}
}
else {
service.openContentEntriesSettings(module);
}
}
}
示例2: displayUrlRelativeToProject
import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
public static String displayUrlRelativeToProject(@NotNull VirtualFile file,
@NotNull String url,
@NotNull Project project,
boolean includeFilePath,
boolean keepModuleAlwaysOnTheLeft) {
final VirtualFile baseDir = project.getBaseDir();
if (baseDir != null && includeFilePath) {
//noinspection ConstantConditions
final String projectHomeUrl = baseDir.getPresentableUrl();
if (url.startsWith(projectHomeUrl)) {
url = "..." + url.substring(projectHomeUrl.length());
}
}
if (SystemInfo.isMac && file.getFileSystem() instanceof LocalFileProvider) {
final VirtualFile fileForJar = ((LocalFileProvider)file.getFileSystem()).getLocalVirtualFileFor(file);
if (fileForJar != null) {
final OrderEntry libraryEntry = LibraryUtil.findLibraryEntry(file, project);
if (libraryEntry != null) {
if (libraryEntry instanceof JdkOrderEntry) {
url = url + " - [" + ((JdkOrderEntry)libraryEntry).getJdkName() + "]";
}
else {
url = url + " - [" + libraryEntry.getPresentableName() + "]";
}
}
else {
url = url + " - [" + fileForJar.getName() + "]";
}
}
}
final Module module = ModuleUtilCore.findModuleForFile(file, project);
if (module == null) return url;
return !keepModuleAlwaysOnTheLeft && SystemInfo.isMac ?
url + " - [" + module.getName() + "]" :
"[" + module.getName() + "] - " + url;
}
示例3: isNavigatableLibraryRoot
import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
private boolean isNavigatableLibraryRoot() {
VirtualFile jarRoot = getJarRoot();
final Project project = getProject();
if (jarRoot != null && ProjectRootsUtil.isLibraryRoot(jarRoot, project)) {
final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(jarRoot, project);
return orderEntry != null && ProjectSettingsService.getInstance(project).canOpenLibraryOrSdkSettings(orderEntry);
}
return false;
}
示例4: navigate
import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
@Override
public void navigate(boolean requestFocus) {
final VirtualFile jarRoot = getJarRoot();
final Project project = getProject();
if (requestFocus && jarRoot != null && ProjectRootsUtil.isLibraryRoot(jarRoot, project)) {
final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(jarRoot, project);
if (orderEntry != null) {
ProjectSettingsService.getInstance(project).openLibraryOrSdkSettings(orderEntry);
return;
}
}
super.navigate(requestFocus);
}
示例5: findLibrary
import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
@Nullable
private Library findLibrary(Project project, PsiJavaFile clsFile) {
OrderEntry libraryEntry = LibraryUtil.findLibraryEntry(clsFile.getVirtualFile(), project);
if (!(libraryEntry instanceof LibraryOrderEntry)) {
return null;
}
return ((LibraryOrderEntry) libraryEntry).getLibrary();
}
示例6: displayUrlRelativeToProject
import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
public static String displayUrlRelativeToProject(@Nonnull VirtualFile file,
@Nonnull String url,
@Nonnull Project project,
boolean includeFilePath,
boolean keepModuleAlwaysOnTheLeft) {
final VirtualFile baseDir = project.getBaseDir();
if (baseDir != null && includeFilePath) {
//noinspection ConstantConditions
final String projectHomeUrl = baseDir.getPresentableUrl();
if (url.startsWith(projectHomeUrl)) {
url = "..." + url.substring(projectHomeUrl.length());
}
}
if (SystemInfo.isMac && file.getFileSystem() instanceof LocalFileProvider) {
final VirtualFile fileForJar = ((LocalFileProvider)file.getFileSystem()).getLocalVirtualFileFor(file);
if (fileForJar != null) {
final OrderEntry libraryEntry = LibraryUtil.findLibraryEntry(file, project);
if (libraryEntry != null) {
if (libraryEntry instanceof ModuleExtensionWithSdkOrderEntry) {
url = url + " - [" + ((ModuleExtensionWithSdkOrderEntry)libraryEntry).getSdkName() + "]";
}
else {
url = url + " - [" + libraryEntry.getPresentableName() + "]";
}
}
else {
url = url + " - [" + fileForJar.getName() + "]";
}
}
}
final Module module = ModuleUtilCore.findModuleForFile(file, project);
if (module == null) return url;
return !keepModuleAlwaysOnTheLeft && SystemInfo.isMac ?
url + " - [" + module.getName() + "]" :
"[" + module.getName() + "] - " + url;
}
示例7: isNavigatableLibraryRoot
import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
private boolean isNavigatableLibraryRoot() {
VirtualFile jarRoot = getArchiveRoot();
final Project project = getProject();
if (jarRoot != null && ProjectRootsUtil.isLibraryRoot(jarRoot, project)) {
final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(jarRoot, project);
return orderEntry != null ;
}
return false;
}
示例8: navigate
import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
@Override
public void navigate(boolean requestFocus) {
final VirtualFile jarRoot = getArchiveRoot();
final Project project = getProject();
if (requestFocus && jarRoot != null && ProjectRootsUtil.isLibraryRoot(jarRoot, project)) {
final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(jarRoot, project);
if (orderEntry != null) {
ProjectSettingsService.getInstance(project).openLibraryOrSdkSettings(orderEntry);
return;
}
}
super.navigate(requestFocus);
}
示例9: selectIn
import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
@Override
public void selectIn(final SelectInContext context, final boolean requestFocus) {
final Project project = context.getProject();
final VirtualFile file = context.getVirtualFile();
final Module module;
final Facet facet;
if (file instanceof WrappingVirtualFile) {
final Object o = ((WrappingVirtualFile)file).getWrappedObject(project);
facet = o instanceof Facet? (Facet)o : null;
module = facet == null? null : facet.getModule();
}
else {
Module moduleByIml = file.getFileType().equals(StdFileTypes.IDEA_MODULE) ? findModuleByModuleFile(project, file) : null;
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
module = moduleByIml != null ? moduleByIml : fileIndex.getModuleForFile(file);
facet = fileIndex.isInSourceContent(file) ? null : findFacet(project, file);
}
if (module != null || facet != null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (facet != null) {
ModulesConfigurator.showFacetSettingsDialog(facet, null);
}
else {
ProjectSettingsService.getInstance(project).openModuleSettings(module);
}
}
});
return;
}
final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(file, project);
if (orderEntry != null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
ProjectSettingsService.getInstance(project).openLibraryOrSdkSettings(orderEntry);
}
});
}
}
示例10: selectIn
import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
@Override
public void selectIn(final SelectInContext context, final boolean requestFocus) {
final Project project = context.getProject();
final VirtualFile file = context.getVirtualFile();
final Module module;
final Facet facet;
if (file instanceof WrappingVirtualFile) {
final Object o = ((WrappingVirtualFile)file).getWrappedObject(project);
facet = o instanceof Facet? (Facet)o : null;
module = facet == null? null : facet.getModule();
}
else {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
module = fileIndex.getModuleForFile(file);
facet = fileIndex.isInSourceContent(file) ? null : findFacet(project, file);
}
if (module != null || facet != null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (facet != null) {
ModulesConfigurator.showFacetSettingsDialog(facet, null);
}
else {
ProjectSettingsService.getInstance(project).openModuleSettings(module);
}
}
});
return;
}
final OrderEntry orderEntry = LibraryUtil.findLibraryEntry(file, project);
if (orderEntry != null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
ProjectSettingsService.getInstance(project).openLibraryOrSdkSettings(orderEntry);
}
});
}
}
示例11: calcRelativeToProjectPath
import com.intellij.openapi.roots.libraries.LibraryUtil; //导入方法依赖的package包/类
@Nonnull
public static String calcRelativeToProjectPath(@Nonnull final VirtualFile file,
@Nullable final Project project,
final boolean includeFilePath,
final boolean includeUniqueFilePath,
final boolean keepModuleAlwaysOnTheLeft) {
if (file instanceof VirtualFilePathWrapper) {
return includeFilePath ? ((VirtualFilePathWrapper)file).getPresentablePath() : file.getName();
}
String url;
if (includeFilePath) {
url = file.getPresentableUrl();
}
else if (includeUniqueFilePath) {
url = UniqueVFilePathBuilder.getInstance().getUniqueVirtualFilePath(project, file);
}
else {
url = file.getName();
}
if (project == null) {
return url;
}
else {
final VirtualFile baseDir = project.getBaseDir();
if (baseDir != null && includeFilePath) {
//noinspection ConstantConditions
final String projectHomeUrl = baseDir.getPresentableUrl();
if (url.startsWith(projectHomeUrl)) {
url = "..." + url.substring(projectHomeUrl.length());
}
}
if (SystemInfo.isMac && file.getFileSystem() instanceof ArchiveFileSystem) {
final VirtualFile fileForJar = ((ArchiveFileSystem)file.getFileSystem()).getLocalVirtualFileFor(file);
if (fileForJar != null) {
final OrderEntry libraryEntry = LibraryUtil.findLibraryEntry(file, project);
if (libraryEntry != null) {
if (libraryEntry instanceof ModuleExtensionWithSdkOrderEntry) {
url = url + " - [" + ((ModuleExtensionWithSdkOrderEntry)libraryEntry).getSdkName() + "]";
}
else {
url = url + " - [" + libraryEntry.getPresentableName() + "]";
}
}
else {
url = url + " - [" + fileForJar.getName() + "]";
}
}
}
final Module module = ModuleUtil.findModuleForFile(file, project);
if (module == null) return url;
return !keepModuleAlwaysOnTheLeft && SystemInfo.isMac ? url + " - [" + module.getName() + "]" : "[" + module.getName() + "] - " + url;
}
}