本文整理汇总了Java中com.intellij.openapi.roots.libraries.LibraryTable类的典型用法代码示例。如果您正苦于以下问题:Java LibraryTable类的具体用法?Java LibraryTable怎么用?Java LibraryTable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LibraryTable类属于com.intellij.openapi.roots.libraries包,在下文中一共展示了LibraryTable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createGlobalLibrary
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
public void createGlobalLibrary(
@NotNull final IdeModifiableModelsProvider modifiableModelsProvider,
@NotNull final File libraryDirRoot,
@NotNull final String libraryName
) {
final LibraryTable.ModifiableModel libraryTableModifiableModel = modifiableModelsProvider
.getModifiableProjectLibrariesModel();
Library library = libraryTableModifiableModel.getLibraryByName(libraryName);
if (null == library) {
library = libraryTableModifiableModel.createLibrary(libraryName);
}
if (libraryTableModifiableModel instanceof LibrariesModifiableModel) {
final ExistingLibraryEditor existingLibraryEditor = ((LibrariesModifiableModel) libraryTableModifiableModel)
.getLibraryEditor(library);
existingLibraryEditor.addJarDirectory(
VfsUtil.getUrlForLibraryRoot(libraryDirRoot), true, OrderRootType.CLASSES
);
} else {
final Library.ModifiableModel libraryModifiableModel = modifiableModelsProvider
.getModifiableLibraryModel(library);
libraryModifiableModel.addJarDirectory(VfsUtil.getUrlForLibraryRoot(libraryDirRoot), true);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:26,代码来源:OotbHybrisModuleDescriptor.java
示例2: addLibsToModule
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
private void addLibsToModule(
@NotNull final ModifiableRootModel modifiableRootModel,
@NotNull IdeModifiableModelsProvider modifiableModelsProvider,
@NotNull final String libraryName,
final boolean export
) {
Validate.notNull(modifiableRootModel);
final LibraryTable.ModifiableModel libraryTableModifiableModel = modifiableModelsProvider
.getModifiableProjectLibrariesModel();
Library library = libraryTableModifiableModel.getLibraryByName(libraryName);
if (null == library) {
library = libraryTableModifiableModel.createLibrary(libraryName);
}
modifiableRootModel.addLibraryEntry(library);
if (export) {
setLibraryEntryExported(modifiableRootModel, library);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:23,代码来源:DefaultLibRootsConfigurator.java
示例3: removeOldProjectData
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的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
示例4: testRemoveLibrary
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
public void testRemoveLibrary() throws IOException {
CamelService service = ServiceManager.getService(myProject, CamelService.class);
assertEquals(0, service.getLibraries().size());
VirtualFile camelCoreVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTestArchive("camel-core-2.19.0.jar"));
VirtualFile camelSpringVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(createTestArchive("camel-spring-2.19.0.jar"));
final LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject);
Library springLibrary = addLibraryToModule(camelSpringVirtualFile, projectLibraryTable, "Maven: org.apache.camel:camel-spring:2.19.0-snapshot");
Library coreLibrary = addLibraryToModule(camelCoreVirtualFile, projectLibraryTable, "Maven: org.apache.camel:camel-core:2.19.0-snapshot");
UIUtil.dispatchAllInvocationEvents();
assertEquals(2, service.getLibraries().size());
assertEquals(true, service.isCamelPresent());
ApplicationManager.getApplication().runWriteAction(() -> projectLibraryTable.removeLibrary(springLibrary));
UIUtil.dispatchAllInvocationEvents();
assertEquals(1, service.getLibraries().size());
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:22,代码来源:CamelProjectComponentTestIT.java
示例5: testAddModule
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
public void testAddModule() throws IOException {
CamelService service = ServiceManager.getService(myProject, CamelService.class);
assertEquals(0, service.getLibraries().size());
File camelJar = createTestArchive("camel-core-2.19.0.jar");
VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(camelJar);
final LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject);
ApplicationManager.getApplication().runWriteAction(() -> {
final Module moduleA = createModule("myNewModel.iml");
Library library = projectLibraryTable.createLibrary("Maven: org.apache.camel:camel-core:2.19.0-snapshot");
final Library.ModifiableModel libraryModifiableModel = library.getModifiableModel();
libraryModifiableModel.addRoot(virtualFile, OrderRootType.CLASSES);
libraryModifiableModel.commit();
ModuleRootModificationUtil.addDependency(moduleA, library);
});
UIUtil.dispatchAllInvocationEvents();
assertEquals(1, service.getLibraries().size());
}
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:21,代码来源:CamelProjectComponentTestIT.java
示例6: testDoNotFailOnAbsentAppLibrary
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
public void testDoNotFailOnAbsentAppLibrary() throws Exception {
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>");
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
LibraryTable appTable = LibraryTablesRegistrar.getInstance().getLibraryTable();
Library lib = appTable.createLibrary("foo");
ModuleRootModificationUtil.addDependency(getModule("project"), lib);
appTable.removeLibrary(lib);
}
});
importProject(); // should not fail;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:DependenciesImportingTest.java
示例7: commitLibraryModel
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
protected static void commitLibraryModel(ModifiableRootModel model, String testDataPath, @NotNull String... libraryPath) {
LibraryTable libraryTable = model.getModuleLibraryTable();
Library library = libraryTable.createLibrary("test");
Library.ModifiableModel libraryModel = library.getModifiableModel();
for (String annotationsDir : libraryPath) {
String path = testDataPath + "/libs/" + annotationsDir;
VirtualFile libJarLocal = LocalFileSystem.getInstance().findFileByPath(path);
assertNotNull(libJarLocal);
VirtualFile jarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(libJarLocal);
assertNotNull(jarRoot);
libraryModel.addRoot(jarRoot, jarRoot.getName().contains("-sources") ? OrderRootType.SOURCES
: OrderRootType.CLASSES);
}
libraryModel.commit();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ClsGenericsHighlightingTest.java
示例8: testModification
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
public void testModification() throws Exception {
final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable();
final Library library = libraryTable.createLibrary("NewLibrary");
final boolean[] listenerNotifiedOnChange = new boolean[1];
library.getRootProvider().addRootSetChangedListener(wrapper -> listenerNotifiedOnChange[0] = true);
final Library.ModifiableModel model1 = library.getModifiableModel();
model1.addRoot("file://x.jar", OrderRootType.CLASSES);
model1.addRoot("file://x-src.jar", OrderRootType.SOURCES);
commit(model1);
assertTrue(listenerNotifiedOnChange[0]);
listenerNotifiedOnChange[0] = false;
final Library.ModifiableModel model2 = library.getModifiableModel();
model2.setName("library");
commit(model2);
assertFalse(listenerNotifiedOnChange[0]);
ApplicationManager.getApplication().runWriteAction(() -> {
libraryTable.removeLibrary(library);
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:LibraryTest.java
示例9: addProjectLibrary
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
private static Library addProjectLibrary(final Module module, final String name, final List<String> jarDirectories, final VirtualFile[] sources) {
return new WriteAction<Library>() {
protected void run(@NotNull final Result<Library> result) {
final LibraryTable libraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(module.getProject());
Library library = libraryTable.getLibraryByName(name);
if (library == null) {
library = libraryTable.createLibrary(name);
final Library.ModifiableModel model = library.getModifiableModel();
for (String path : jarDirectories) {
String url = VfsUtilCore.pathToUrl(path);
VirtualFileManager.getInstance().refreshAndFindFileByUrl(url);
model.addJarDirectory(url, false);
}
for (VirtualFile sourceRoot : sources) {
model.addRoot(sourceRoot, OrderRootType.SOURCES);
}
model.commit();
}
result.setResult(library);
}
}.execute().getResultObject();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AppEngineSupportProvider.java
示例10: removeData
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
@Override
public void removeData(@NotNull final Computable<Collection<Library>> toRemoveComputable,
@NotNull Collection<DataNode<LibraryData>> toIgnore,
@NotNull ProjectData projectData,
@NotNull final Project project,
@NotNull final IdeModifiableModelsProvider modelsProvider) {
final Collection<Library> toRemove = toRemoveComputable.compute();
if (toRemove.isEmpty()) {
return;
}
final LibraryTable.ModifiableModel librariesModel = modelsProvider.getModifiableProjectLibrariesModel();
for (Library library : toRemove) {
String libraryName = library.getName();
if (libraryName != null) {
Library libraryToRemove = librariesModel.getLibraryByName(libraryName);
if (libraryToRemove != null) {
librariesModel.removeLibrary(libraryToRemove);
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:LibraryDataService.java
示例11: removeLibrariesAndStoreAttachments
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的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
示例12: renameLibrary
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
private static void renameLibrary(final Sdk sdk, final String previousName) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
public void run() {
final LibraryTable.ModifiableModel libraryTableModel =
ModifiableModelsProvider.SERVICE.getInstance().getLibraryTableModifiableModel();
final Library library = libraryTableModel.getLibraryByName(PythonFacet.getFacetLibraryName(previousName));
if (library != null) {
final Library.ModifiableModel model = library.getModifiableModel();
model.setName(PythonFacet.getFacetLibraryName(sdk.getName()));
model.commit();
}
libraryTableModel.commit();
}
});
}
}, ModalityState.NON_MODAL);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PythonSdkTableListener.java
示例13: createLibrary
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
@Override
public Library createLibrary(@NotNull NewLibraryEditor libraryEditor,
@NotNull LibraryLevel level) {
LibraryTableModifiableModelProvider provider = getProvider(level);
if (provider == null) {
LOG.error("cannot create module library in this context");
}
LibraryTable.ModifiableModel model = provider.getModifiableModel();
final LibraryType<?> type = libraryEditor.getType();
Library library = model.createLibrary(getUniqueLibraryName(libraryEditor.getName(), model), type == null ? null : type.getKind());
ExistingLibraryEditor createdLibraryEditor = ((LibrariesModifiableModel)model).getLibraryEditor(library);
createdLibraryEditor.setProperties(libraryEditor.getProperties());
libraryEditor.applyTo(createdLibraryEditor);
return library;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:LibrariesContainerFactory.java
示例14: createNewLibrary
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
private LibraryEx createNewLibrary(@NotNull final Module module, final LibraryTable.ModifiableModel modifiableModel) {
RepositoryLibraryProperties libraryProperties = new RepositoryLibraryProperties(
libraryDescription.getGroupId(),
libraryDescription.getArtifactId(),
model.getVersion());
final LibraryEx library = (LibraryEx)modifiableModel.createLibrary(
LibraryEditingUtil.suggestNewLibraryName(modifiableModel, RepositoryLibraryType.getInstance().getDescription(libraryProperties)),
RepositoryLibraryType.REPOSITORY_LIBRARY_KIND);
RepositoryLibraryProperties realLibraryProperties = (RepositoryLibraryProperties)library.getProperties();
realLibraryProperties.setMavenId(libraryProperties.getMavenId());
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
modifiableModel.commit();
}
});
RepositoryUtils.loadDependencies(
module.getProject(),
library,
model.isDownloadSources(),
model.isDownloadJavaDocs(),
null);
return library;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:RepositoryLibrarySupport.java
示例15: createDialog
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
public static EditExistingLibraryDialog createDialog(Component parent,
LibraryTableModifiableModelProvider modelProvider,
Library library,
@Nullable Project project,
LibraryTablePresentation presentation,
StructureConfigurableContext context) {
LibraryTable.ModifiableModel modifiableModel = modelProvider.getModifiableModel();
boolean commitChanges = false;
ExistingLibraryEditor libraryEditor;
if (modifiableModel instanceof LibrariesModifiableModel) {
libraryEditor = ((LibrariesModifiableModel)modifiableModel).getLibraryEditor(library);
}
else {
libraryEditor = new ExistingLibraryEditor(library, context);
commitChanges = true;
}
return new EditExistingLibraryDialog(parent, modifiableModel, project, libraryEditor, commitChanges, presentation, context);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:EditExistingLibraryDialog.java
示例16: CreateNewLibraryDialog
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
public CreateNewLibraryDialog(@NotNull JComponent parent, @NotNull StructureConfigurableContext context, @NotNull NewLibraryEditor libraryEditor,
@NotNull List<LibraryTable> libraryTables, int selectedTable) {
super(parent, new LibraryRootsComponent(context.getProject(), libraryEditor));
myContext = context;
myLibraryEditor = libraryEditor;
final DefaultComboBoxModel model = new DefaultComboBoxModel();
for (LibraryTable table : libraryTables) {
model.addElement(table);
}
myLibraryLevelCombobox = new ComboBox(model);
myLibraryLevelCombobox.setSelectedIndex(selectedTable);
myLibraryLevelCombobox.setRenderer(new ListCellRendererWrapper() {
@Override
public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
if (value instanceof LibraryTable) {
setText(((LibraryTable)value).getPresentation().getDisplayName(false));
}
}
});
init();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CreateNewLibraryDialog.java
示例17: 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
示例18: selectLibrary
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
@Override
public void selectLibrary(@NotNull Library library) {
final LibraryTable table = library.getTable();
if (table != null) {
ProjectStructureConfigurable.getInstance(getProject()).selectProjectOrGlobalLibrary(library, true);
}
else {
final Module module = ((LibraryImpl)library).getModule();
if (module != null) {
final ModuleRootModel rootModel = myParent.getModulesProvider().getRootModel(module);
final String libraryName = library.getName();
for (OrderEntry entry : rootModel.getOrderEntries()) {
if (entry instanceof ModuleLibraryOrderEntryImpl) {
final ModuleLibraryOrderEntryImpl libraryEntry = (ModuleLibraryOrderEntryImpl)entry;
if (libraryName != null && libraryName.equals(libraryEntry.getLibraryName())
|| libraryName == null && library.equals(libraryEntry.getLibrary())) {
ProjectStructureConfigurable.getInstance(getProject()).selectOrderEntry(module, libraryEntry);
return;
}
}
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ArtifactEditorContextImpl.java
示例19: doEdit
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
private void doEdit() {
final OrderEntry entry = getSelectedEntry();
if (!(entry instanceof LibraryOrderEntry)) return;
final Library library = ((LibraryOrderEntry)entry).getLibrary();
if (library == null) {
return;
}
final LibraryTable table = library.getTable();
final String tableLevel = table != null ? table.getTableLevel() : LibraryTableImplUtil.MODULE_LEVEL;
final LibraryTablePresentation presentation = LibraryEditingUtil.getLibraryTablePresentation(getProject(), tableLevel);
final LibraryTableModifiableModelProvider provider = getModifiableModelProvider(tableLevel);
EditExistingLibraryDialog dialog = EditExistingLibraryDialog.createDialog(this, provider, library, myState.getProject(),
presentation, getStructureConfigurableContext());
dialog.setContextModule(getRootModel().getModule());
dialog.show();
myEntryTable.repaint();
ModuleStructureConfigurable.getInstance(myState.getProject()).getTree().repaint();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ClasspathPanelImpl.java
示例20: getModifiableModelProvider
import com.intellij.openapi.roots.libraries.LibraryTable; //导入依赖的package包/类
@Override
@NotNull
public LibraryTableModifiableModelProvider getModifiableModelProvider(@NotNull String tableLevel) {
if (LibraryTableImplUtil.MODULE_LEVEL.equals(tableLevel)) {
final LibraryTable moduleLibraryTable = getRootModel().getModuleLibraryTable();
return new LibraryTableModifiableModelProvider() {
@Override
public LibraryTable.ModifiableModel getModifiableModel() {
return moduleLibraryTable.getModifiableModel();
}
};
}
else {
return getStructureConfigurableContext().createModifiableModelProvider(tableLevel);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ClasspathPanelImpl.java
注:本文中的com.intellij.openapi.roots.libraries.LibraryTable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论