本文整理汇总了Java中com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable类的典型用法代码示例。如果您正苦于以下问题:Java ProjectLibraryTable类的具体用法?Java ProjectLibraryTable怎么用?Java ProjectLibraryTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectLibraryTable类属于com.intellij.openapi.roots.impl.libraries包,在下文中一共展示了ProjectLibraryTable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: removeOldProjectData
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
private static void removeOldProjectData(@NotNull final Project project) {
final ModifiableModuleModel moduleModel = ModuleManager.getInstance(project).getModifiableModel();
for (Module module : moduleModel.getModules()) {
moduleModel.disposeModule(module);
}
final LibraryTable.ModifiableModel libraryModel = ProjectLibraryTable.getInstance(project).getModifiableModel();
for (Library library : libraryModel.getLibraries()) {
libraryModel.removeLibrary(library);
}
ApplicationManager.getApplication().runWriteAction(() -> {
moduleModel.commit();
libraryModel.commit();
});
final GradleSupport gradleSupport = GradleSupport.getInstance();
if (gradleSupport != null) {
gradleSupport.clearLinkedProjectSettings(project);
}
final AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(project);
for (AntBuildFile antBuildFile : antConfiguration.getBuildFiles()) {
antConfiguration.removeBuildFile(antBuildFile);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:ProjectRefreshAction.java
示例2: removeLibrariesAndStoreAttachments
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
public static void removeLibrariesAndStoreAttachments(@NotNull Project project) {
LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
LibraryTable.ModifiableModel model = libraryTable.getModifiableModel();
try {
Map<OrderRootType, Multimap<String, String>> attachmentsByType = Maps.newHashMap();
for (Library library : model.getLibraries()) {
for (OrderRootType type : SUPPORTED_TYPES) {
Multimap<String, String> attachments = ArrayListMultimap.create();
String name = library.getName();
if (name != null) {
String[] urls = library.getUrls(type);
for (String url : urls) {
attachments.put(name, url);
}
}
attachmentsByType.put(type, attachments);
}
model.removeLibrary(library);
}
project.putUserData(LIBRARY_ATTACHMENTS, new LibraryAttachments(project, attachmentsByType));
}
finally {
model.commit();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:LibraryAttachments.java
示例3: findLibrary
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的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
示例4: testJavaModelSerialization
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
@Test @IdeGuiTest
public void testJavaModelSerialization() throws IOException {
IdeFrameFixture projectFrame = importProjectAndWaitForProjectSyncToFinish("MultipleModuleTypes");
final File projectPath = projectFrame.getProjectPath();
projectFrame.requestProjectSync()
.waitForGradleProjectSyncToFinish();
projectFrame.closeProject();
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
projectManager.loadAndOpenProject(projectPath.getPath());
}
});
projectFrame = findIdeFrame(projectPath);
LibraryTable libraryTable = ProjectLibraryTable.getInstance(projectFrame.getProject());
// When serialization of Java model fails, libraries are not set up.
// Here we confirm that serialization works, because the Java module has the dependency declared in its build.gradle file.
assertThat(libraryTable.getLibraries()).hasSize(1);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GradleSyncTest.java
示例5: appendProjectLibraries
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
public static void appendProjectLibraries(final Project project, @Nullable final File userLibrariesFile) throws IOException {
if (userLibrariesFile == null) return;
if (userLibrariesFile.exists() && !userLibrariesFile.isFile()) return;
final File parentFile = userLibrariesFile.getParentFile();
if (parentFile == null) return;
if (!parentFile.isDirectory()) {
if (!parentFile.mkdir()) return;
}
final Element userLibsElement = new Element("eclipse-userlibraries");
final List<Library> libraries = new ArrayList<Library>(Arrays.asList(ProjectLibraryTable.getInstance(project).getLibraries()));
ContainerUtil.addAll(libraries, LibraryTablesRegistrar.getInstance().getLibraryTable().getLibraries());
for (Library library : libraries) {
Element libElement = new Element("library");
libElement.setAttribute("name", library.getName());
writeUserLibrary(library, libElement);
userLibsElement.addContent(libElement);
}
JDOMUtil.writeDocument(new Document(userLibsElement), userLibrariesFile, "\n");
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:EclipseUserLibrariesHelper.java
示例6: updateProjectStructure
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
@Override
public void updateProjectStructure(
Project project,
BlazeContext context,
WorkspaceRoot workspaceRoot,
ProjectViewSet projectViewSet,
BlazeProjectData blazeProjectData,
@Nullable BlazeProjectData oldBlazeProjectData,
ModuleEditor moduleEditor,
Module workspaceModule,
ModifiableRootModel workspaceModifiableModel) {
if (!blazeProjectData.workspaceLanguageSettings.isLanguageActive(LanguageClass.TYPESCRIPT)) {
return;
}
Library tsConfigLibrary =
ProjectLibraryTable.getInstance(project).getLibraryByName(TSCONFIG_LIBRARY_NAME);
if (tsConfigLibrary != null) {
if (workspaceModifiableModel.findLibraryOrderEntry(tsConfigLibrary) == null) {
workspaceModifiableModel.addLibraryEntry(tsConfigLibrary);
}
}
}
开发者ID:bazelbuild,项目名称:intellij,代码行数:24,代码来源:BlazeTypescriptSyncPlugin.java
示例7: updateProjectStructure
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
@Override
public void updateProjectStructure(
Project project,
BlazeContext context,
WorkspaceRoot workspaceRoot,
ProjectViewSet projectViewSet,
BlazeProjectData blazeProjectData,
@Nullable BlazeProjectData oldBlazeProjectData,
ModuleEditor moduleEditor,
Module workspaceModule,
ModifiableRootModel workspaceModifiableModel) {
if (!blazeProjectData.workspaceLanguageSettings.isLanguageActive(LanguageClass.SCALA)) {
return;
}
for (Library library : ProjectLibraryTable.getInstance(project).getLibraries()) {
// Convert the type of the SDK library to prevent the scala plugin from
// showing the missing SDK notification.
// TODO: use a canonical class in the SDK (e.g., scala.App) instead of the name?
if (library.getName() != null && library.getName().startsWith("scala-library")) {
ExistingLibraryEditor editor = new ExistingLibraryEditor(library, null);
editor.setType(ScalaLibraryType.instance());
editor.commit();
return;
}
}
}
开发者ID:bazelbuild,项目名称:intellij,代码行数:27,代码来源:BlazeScalaSyncPlugin.java
示例8: testAppEngine_defaultManagedLibrariesSelected
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
public void testAppEngine_defaultManagedLibrariesSelected() {
AppEngineStandardLibraryPanel libraryPanel =
new AppEngineStandardLibraryPanel(true /*enabled*/);
LibraryEx library = mock(LibraryEx.class);
when(library.getTable()).thenReturn(ProjectLibraryTable.getInstance(myModule.getProject()));
when(library.getExcludedRoots()).thenReturn(new VirtualFile[0]);
when(library.getName()).thenReturn("javax.servlet:servlet-api:2.5");
setupAppEngine(libraryPanel, library);
addSupport();
assertNull(FacetManager.getInstance(myModule).getFacetByType(WebFacet.ID));
final String moduleName = myModule.getName();
ArtifactsTestUtil.assertLayout(
myProject,
moduleName,
"<root>\n"
+ " WEB-INF/\n"
+ " classes/\n"
+ " module:"
+ moduleName
+ "\n"
+ " lib/\n"
+ " lib:javax.servlet:servlet-api:2.5(project)\n");
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:27,代码来源:AppEngineStandardSupportProviderTest.java
示例9: tearDown
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
@Override
protected void tearDown() throws Exception {
final LibraryTable libraryTable = ProjectLibraryTable.getInstance(myFixture.getProject());
final Library libraryByName = libraryTable.getLibraryByName(PantsConstants.PANTS_LIBRARY_NAME);
if (libraryByName != null) {
ApplicationManager.getApplication().runWriteAction(
new Runnable() {
@Override
public void run() {
libraryTable.removeLibrary(libraryByName);
}
}
);
}
PantsConsoleManager.disposeAll();
super.tearDown();
}
开发者ID:pantsbuild,项目名称:intellij-pants-plugin,代码行数:18,代码来源:PantsCodeInsightFixtureTestCase.java
示例10: addProjectLibrary
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
private static void addProjectLibrary(final Module module,
final ModifiableRootModel model,
final String libName,
final VirtualFile... classesRoots) {
new WriteCommandAction.Simple(module.getProject()) {
@Override
protected void run() throws Throwable {
final LibraryTable libraryTable = ProjectLibraryTable.getInstance(module.getProject());
final Library library = libraryTable.createLibrary(libName);
final Library.ModifiableModel libraryModel = library.getModifiableModel();
for (VirtualFile root : classesRoots) {
libraryModel.addRoot(root, OrderRootType.CLASSES);
}
libraryModel.commit();
model.addLibraryEntry(library);
final OrderEntry[] orderEntries = model.getOrderEntries();
OrderEntry last = orderEntries[orderEntries.length - 1];
System.arraycopy(orderEntries, 0, orderEntries, 1, orderEntries.length - 1);
orderEntries[0] = last;
model.rearrangeOrderEntries(orderEntries);
}
}.execute().throwException();
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:PsiTestUtil.java
示例11: getProjectLibraries
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
/**
* Get the list of libraries specified on the project. Managed haxelib
* (of the form "haxelib|<lib_name>") libraries are included unless
* filterManagedLibs is true.
*
*
* @param project to get the classpath for.
* @return a (possibly empty) list of the classpaths for all of the libraries
* that are specified on the project (in the library pane).
*/
@NotNull
public static HaxeLibraryList getProjectLibraries(@NotNull Project project, boolean filterManagedLibs, boolean filterUnmanagedLibs) {
LibraryTable libraryTable = ProjectLibraryTable.getInstance(project);
if (null == libraryTable || (filterManagedLibs && filterUnmanagedLibs)) {
return new HaxeLibraryList(HaxelibSdkUtils.lookupSdk(project));
}
HaxeLibraryList libs = new HaxeLibraryList(HaxelibSdkUtils.lookupSdk(project));
Library[] libraries = libraryTable.getLibraries();
for (Library library : libraries) {
String name = library.getName();
boolean isManaged = HaxelibNameUtil.isManagedLibrary(name);
if (filterManagedLibs && isManaged) continue;
if (filterUnmanagedLibs && !isManaged) continue;
libs.add(HaxeLibraryReference.create(project, name));
}
return libs;
}
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:30,代码来源:HaxelibUtil.java
示例12: addProjectLibrary
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
private static void addProjectLibrary(final Module module,
final ModifiableRootModel model,
final String libName,
final VirtualFile... classesRoots) {
new WriteCommandAction.Simple(module.getProject()) {
@Override
protected void run() throws Throwable {
final LibraryTable libraryTable = ProjectLibraryTable.getInstance(module.getProject());
final Library library = libraryTable.createLibrary(libName);
final Library.ModifiableModel libraryModel = library.getModifiableModel();
for (VirtualFile root : classesRoots) {
libraryModel.addRoot(root, BinariesOrderRootType.getInstance());
}
libraryModel.commit();
model.addLibraryEntry(library);
final OrderEntry[] orderEntries = model.getOrderEntries();
OrderEntry last = orderEntries[orderEntries.length - 1];
System.arraycopy(orderEntries, 0, orderEntries, 1, orderEntries.length - 1);
orderEntries[0] = last;
model.rearrangeOrderEntries(orderEntries);
}
}.execute().throwException();
}
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:PsiTestUtil.java
示例13: setUp
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
myRoot = LocalFileSystem.getInstance().findFileByPath(PathManagerEx.getTestDataPath() + "/psi/cls/repo");
assertNotNull(myRoot);
myLib = WriteCommandAction.runWriteCommandAction(null, new Computable<Library>() {
@Override
public Library compute() {
return ProjectLibraryTable.getInstance(myProject).createLibrary("LIB");
}
});
ModuleRootModificationUtil.addDependency(myModule, myLib);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ProjectLibrariesTest.java
示例14: loadDirectoryProject
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
private static void loadDirectoryProject(MockProject project, VirtualFile projectDir) throws IOException, JDOMException,
InvalidDataException {
VirtualFile dotIdea = projectDir.findChild(Project.DIRECTORY_STORE_FOLDER);
if (dotIdea == null)
throw new FileNotFoundException("Missing '" + Project.DIRECTORY_STORE_FOLDER + "' in " + projectDir.getPath());
VirtualFile modulesXml = dotIdea.findChild("modules.xml");
if (modulesXml == null)
throw new FileNotFoundException("Missing 'modules.xml' in " + dotIdea.getPath());
TreeMap<String, Element> storageData = loadStorageFile(project, modulesXml);
final Element moduleManagerState = storageData.get("ProjectModuleManager");
if (moduleManagerState == null) {
throw new JDOMException("cannot find ProjectModuleManager state in modules.xml");
}
final CoreModuleManager moduleManager = (CoreModuleManager)ModuleManager.getInstance(project);
moduleManager.loadState(moduleManagerState);
VirtualFile miscXml = dotIdea.findChild("misc.xml");
if (miscXml == null)
throw new FileNotFoundException("Missing 'misc.xml' in " + dotIdea.getPath());
storageData = loadStorageFile(project, miscXml);
final Element projectRootManagerState = storageData.get("ProjectRootManager");
if (projectRootManagerState == null) {
throw new JDOMException("cannot find ProjectRootManager state in misc.xml");
}
((ProjectRootManagerImpl) ProjectRootManager.getInstance(project)).loadState(projectRootManagerState);
VirtualFile libraries = dotIdea.findChild("libraries");
if (libraries != null) {
Map<String, Element> data = DirectoryStorageUtil.loadFrom(libraries, PathMacroManager.getInstance(project).createTrackingSubstitutor());
Element libraryTable = DefaultStateSerializer.deserializeState(DirectoryStorageUtil.getCompositeState(data, new ProjectLibraryTable.LibraryStateSplitter()), Element.class, null);
((LibraryTableBase) ProjectLibraryTable.getInstance(project)).loadState(libraryTable);
}
moduleManager.loadModules();
project.projectOpened();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:CoreProjectLoader.java
示例15: assertProjectLibraries
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
public void assertProjectLibraries(String... expectedNames) {
List<String> actualNames = new ArrayList<String>();
for (Library each : ProjectLibraryTable.getInstance(myProject).getLibraries()) {
String name = each.getName();
actualNames.add(name == null ? "<unnamed>" : name);
}
assertUnorderedElementsAreEqual(actualNames, expectedNames);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ExternalSystemImportingTestCase.java
示例16: attachSourcesToLibraries
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
private void attachSourcesToLibraries() {
LibraryTable libraryTable = ProjectLibraryTable.getInstance(myProject);
LibraryAttachments storedLibraryAttachments = getStoredLibraryAttachments(myProject);
for (Library library : libraryTable.getLibraries()) {
Set<String> sourcePaths = Sets.newHashSet();
for (VirtualFile file : library.getFiles(SOURCES)) {
sourcePaths.add(file.getUrl());
}
Library.ModifiableModel libraryModel = library.getModifiableModel();
// Find the source attachment based on the location of the library jar file.
for (VirtualFile classFile : library.getFiles(CLASSES)) {
VirtualFile sourceJar = findSourceJarForJar(classFile);
if (sourceJar != null) {
String url = pathToUrl(sourceJar.getPath());
if (!sourcePaths.contains(url)) {
libraryModel.addRoot(url, SOURCES);
sourcePaths.add(url);
}
}
}
if (storedLibraryAttachments != null) {
storedLibraryAttachments.addUrlsTo(libraryModel);
}
libraryModel.commit();
}
if (storedLibraryAttachments != null) {
storedLibraryAttachments.removeFromProject();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:PostProjectSetupTasksExecutor.java
示例17: testUserDefinedLibrarySources
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的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
示例18: getLibrary
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的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
示例19: createProjectLibrary
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
private Library createProjectLibrary(final String libraryName) {
AccessToken accessToken = WriteAction.start();
try {
return ProjectLibraryTable.getInstance(myProject).createLibrary(libraryName);
}
finally {
accessToken.finish();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:DependenciesImportingTest.java
示例20: clearLibraryRoots
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable; //导入依赖的package包/类
private void clearLibraryRoots(final String libraryName, final OrderRootType... types) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
Library lib = ProjectLibraryTable.getInstance(myProject).getLibraryByName(libraryName);
Library.ModifiableModel model = lib.getModifiableModel();
for (OrderRootType eachType : types) {
for (String each : model.getUrls(eachType)) {
model.removeRoot(each, eachType);
}
}
model.commit();
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:DependenciesImportingTest.java
注:本文中的com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论