当前位置: 首页>>代码示例>>Java>>正文


Java LibraryTable.getLibraryByName方法代码示例

本文整理汇总了Java中com.intellij.openapi.roots.libraries.LibraryTable.getLibraryByName方法的典型用法代码示例。如果您正苦于以下问题:Java LibraryTable.getLibraryByName方法的具体用法?Java LibraryTable.getLibraryByName怎么用?Java LibraryTable.getLibraryByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.roots.libraries.LibraryTable的用法示例。


在下文中一共展示了LibraryTable.getLibraryByName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createElements

import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
public static List<SimpleClasspathElement> createElements(@Nullable Project project, @NotNull Element element) {
  final String name = element.getAttributeValue(GlobalLibraryReferenceElement.NAME_ATTRIBUTE);
  final String level = element.getAttributeValue(GlobalLibraryReferenceElement.LEVEL_ATTRIBUTE);
  final String url = element.getChildText(SingleRootClasspathElement.URL_ELEMENT);
  if (!StringUtil.isEmpty(url)) {
    return Collections.<SimpleClasspathElement>singletonList(new SingleRootClasspathElement(url));
  }
  if (name == null || level == null) {
    return Collections.emptyList();
  }
  if (LibraryTablesRegistrar.APPLICATION_LEVEL.equals(level)) {
    return Collections.<SimpleClasspathElement>singletonList(new GlobalLibraryReferenceElement(name));
  }
  //this is needed only for backward compatibility with version before 8
  if (project != null) {
    final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTableByLevel(level, project);
    if (libraryTable != null) {
      final Library library = libraryTable.getLibraryByName(name);
      if (library != null) {
        return createElements(library);
      }
    }
  }
  return Collections.emptyList();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:SimpleClasspathElementFactory.java

示例2: findLibrary

import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
@Nullable
private static Library findLibrary(@NotNull AnActionEvent e) {
  if (isAndroidStudio()) {
    Project project = e.getProject();
    if (project != null) {
      NamedLibraryElementNode node = findLibraryNode(e.getDataContext());
      if (node != null) {
        String libraryName = node.getName();
        if (isNotEmpty(libraryName)) {
          LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
          return libraryTable.getLibraryByName(libraryName);
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:LibraryPropertiesAction.java

示例3: findLibraryByName

import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
public static Library findLibraryByName(Project project, String name) {
  final LibraryTablesRegistrar tablesRegistrar = LibraryTablesRegistrar.getInstance();
  Library lib = tablesRegistrar.getLibraryTable().getLibraryByName(name);
  if (lib == null) {
    lib = tablesRegistrar.getLibraryTable(project).getLibraryByName(name);
  }
  if (lib == null) {
    for (LibraryTable table : tablesRegistrar.getCustomLibraryTables()) {
      lib = table.getLibraryByName(name);
      if (lib != null) {
        break;
      }
    }
  }
  return lib;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:EclipseClasspathReader.java

示例4: searchForLibrary

import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
private void searchForLibrary(@NotNull String name, @NotNull String level) {
  if (myLibrary != null) return;
  final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTableByLevel(level, getRootModel().getModule().getProject());
  final Library library = libraryTable != null ? libraryTable.getLibraryByName(name) : null;
  if (library == null) {
    myLibraryName = name;
    myLibraryLevel = level;
    myLibrary = null;
  }
  else {
    myLibraryName = null;
    myLibraryLevel = null;
    myLibrary = library;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:LibraryOrderEntryImpl.java

示例5: findLibrary

import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
public Library findLibrary(@NotNull String level, @NotNull String libraryName) {
  if (level.equals(LibraryTablesRegistrar.PROJECT_LEVEL)) {
    return getLibraryByName(libraryName);
  }
  final LibraryTable table = LibraryTablesRegistrar.getInstance().getLibraryTableByLevel(level, myProject);
  return table != null ? table.getLibraryByName(libraryName) : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:AbstractIdeModifiableModelsProvider.java

示例6: testUserDefinedLibrarySources

import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
@Test @IdeGuiTest
public void testUserDefinedLibrarySources() throws IOException {
  IdeFrameFixture projectFrame = importSimpleApplication();
  Project project = projectFrame.getProject();

  String libraryName = "guava-18.0";

  LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
  Library library = libraryTable.getLibraryByName(libraryName);
  assertNotNull(library);

  String url = "jar://$USER_HOME$/fake-dir/fake-sources.jar!/";

  // add an extra source path.
  final Library.ModifiableModel libraryModel = library.getModifiableModel();
  libraryModel.addRoot(url, OrderRootType.SOURCES);

  execute(new GuiTask() {
    @Override
    protected void executeInEDT() throws Throwable {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          libraryModel.commit();
        }
      });
    }
  });

  projectFrame.requestProjectSync().waitForBackgroundTasksToFinish();

  libraryTable = ProjectLibraryTable.getInstance(project);
  library = libraryTable.getLibraryByName(libraryName);
  assertNotNull(library);

  String[] urls = library.getUrls(OrderRootType.SOURCES);
  assertThat(urls).contains(url);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:GradleSyncTest.java

示例7: getLibrary

import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
@NotNull
public LibraryFixture getLibrary() {
  LibraryTable libraryTable = ProjectLibraryTable.getInstance(myProject);
  Library library = libraryTable.getLibraryByName(myLibraryName);

  assertNotNull("Failed to find library " + quote(myLibraryName), library);
  return new LibraryFixture(library);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:LibraryPropertiesDialogFixture.java

示例8: configSurefirePlugin

import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
private void configSurefirePlugin() {
  // Remove "maven-surefire-plugin urls" library created by previous version of IDEA.
  // todo remove this code after 01.06.2013
  LibraryTable moduleLibraryTable = myRootModelAdapter.getRootModel().getModuleLibraryTable();

  Library library = moduleLibraryTable.getLibraryByName(SUREFIRE_PLUGIN_LIBRARY_NAME);
  if (library != null) {
    moduleLibraryTable.removeLibrary(library);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:MavenModuleImporter.java

示例9: updateLibraryDependency

import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
private static void updateLibraryDependency(ModifiableRootModel model, LibraryKey libraryKey) {
  LibraryTable libraryTable = ProjectLibraryTable.getInstance(model.getProject());
  Library library = libraryTable.getLibraryByName(libraryKey.getIntelliJLibraryName());
  if (library == null) {
    logger.error(
        "Library missing: "
            + libraryKey.getIntelliJLibraryName()
            + ". Please resync project to resolve.");
    return;
  }
  model.addLibraryEntry(library);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:13,代码来源:LibraryEditor.java

示例10: findLibraryForAction

import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
@Nullable
public static Library findLibraryForAction(@NotNull AnActionEvent e) {
  Project project = e.getProject();
  if (project != null) {
    NamedLibraryElementNode node = findLibraryNode(e.getDataContext());
    if (node != null) {
      String libraryName = node.getName();
      if (StringUtil.isNotEmpty(libraryName)) {
        LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
        return libraryTable.getLibraryByName(libraryName);
      }
    }
  }
  return null;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:16,代码来源:LibraryActionHelper.java

示例11: findLibrary

import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
@Nullable
public static Library findLibrary(Project project, String level, String libraryName) {
  LibraryTable table = LibraryTablesRegistrar.getInstance().getLibraryTableByLevel(level, project);
  return table != null ? table.getLibraryByName(libraryName) : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:DefaultPackagingElementResolvingContext.java

示例12: getLibrary

import com.intellij.openapi.roots.libraries.LibraryTable; //导入方法依赖的package包/类
@Override
public Library getLibrary() {
  final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable();
  return libraryTable.getLibraryByName(myLibraryName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:GlobalLibraryReferenceElement.java


注:本文中的com.intellij.openapi.roots.libraries.LibraryTable.getLibraryByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。