use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-community by JetBrains.
the class RepositoryLibraryDependencyScopeSuggester method getDefaultDependencyScope.
@Nullable
@Override
public DependencyScope getDefaultDependencyScope(@NotNull Library library) {
if (!(library instanceof LibraryEx)) {
return null;
}
LibraryEx libraryEx = (LibraryEx) library;
LibraryProperties libraryProperties = libraryEx.getProperties();
if (libraryProperties == null || !(libraryProperties instanceof RepositoryLibraryProperties)) {
return null;
}
RepositoryLibraryProperties repositoryLibraryProperties = (RepositoryLibraryProperties) libraryProperties;
RepositoryLibraryDescription libraryDescription = RepositoryLibraryDescription.findDescription(repositoryLibraryProperties);
return libraryDescription.getSuggestedScope();
}
use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-community by JetBrains.
the class RepositoryLibrarySupport method createNewLibrary.
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(() -> modifiableModel.commit());
RepositoryUtils.loadDependencies(module.getProject(), library, model.isDownloadSources(), model.isDownloadJavaDocs(), null);
return library;
}
use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-community by JetBrains.
the class RepositoryLibrarySynchronizer method runActivity.
@Override
public void runActivity(@NotNull final Project project) {
StartupManager.getInstance(project).registerPostStartupActivity(new DumbAwareRunnable() {
@Override
public void run() {
ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
@Override
public void run() {
final Collection<Library> libraries = collectLibraries(project, new Predicate<Library>() {
@Override
public boolean apply(Library library) {
if (!(library instanceof LibraryEx)) {
return false;
}
LibraryEx libraryEx = (LibraryEx) library;
return libraryEx.getKind() == RepositoryLibraryType.REPOSITORY_LIBRARY_KIND && libraryEx.getProperties() instanceof RepositoryLibraryProperties && isLibraryNeedToBeReloaded(libraryEx, (RepositoryLibraryProperties) libraryEx.getProperties());
}
});
for (Library library : libraries) {
final LibraryEx libraryEx = (LibraryEx) library;
RepositoryUtils.reloadDependencies(project, libraryEx);
}
}
}, project.getDisposed());
}
});
}
use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project azure-tools-for-java by Microsoft.
the class SparkLibraryOptionsPanel method calculateSuitableLibraries.
private List<Library> calculateSuitableLibraries() {
ArrayList suitableLibraries = new ArrayList();
Library[] libraries = this.librariesContainer.getAllLibraries();
for (int i = 0; i < libraries.length; ++i) {
Library library = libraries[i];
PersistentLibraryKind type = ((LibraryEx) library).getKind();
if (type != null && type instanceof SparkLibraryKind) {
suitableLibraries.add(library);
}
}
return suitableLibraries;
}
use of com.intellij.openapi.roots.impl.libraries.LibraryEx in project intellij-community by JetBrains.
the class ModuleRootModificationUtil method addModuleLibrary.
public static void addModuleLibrary(@NotNull Module module, @Nullable String libName, @NotNull List<String> classesRoots, @NotNull List<String> sourceRoots, @NotNull List<String> excludedRoots, @NotNull DependencyScope scope, boolean exported) {
updateModel(module, model -> {
LibraryEx library = (LibraryEx) model.getModuleLibraryTable().createLibrary(libName);
LibraryEx.ModifiableModelEx libraryModel = library.getModifiableModel();
for (String root : classesRoots) {
libraryModel.addRoot(root, OrderRootType.CLASSES);
}
for (String root : sourceRoots) {
libraryModel.addRoot(root, OrderRootType.SOURCES);
}
for (String excluded : excludedRoots) {
libraryModel.addExcludedRoot(excluded);
}
LibraryOrderEntry entry = model.findLibraryOrderEntry(library);
assert entry != null : library;
entry.setScope(scope);
entry.setExported(exported);
ApplicationManager.getApplication().invokeAndWait(() -> WriteAction.run(libraryModel::commit));
});
}
Aggregations