Java Code Examples for com.intellij.openapi.roots.LibraryOrderEntry#getLibrary()
The following examples show how to use
com.intellij.openapi.roots.LibraryOrderEntry#getLibrary() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LibraryPackagingElement.java From consulo with Apache License 2.0 | 6 votes |
@javax.annotation.Nullable public Library findLibrary(@Nonnull PackagingElementResolvingContext context) { if (myModuleName == null) { return context.findLibrary(myLevel, myLibraryName); } final ModulesProvider modulesProvider = context.getModulesProvider(); final Module module = modulesProvider.getModule(myModuleName); if (module != null) { for (OrderEntry entry : modulesProvider.getRootModel(module).getOrderEntries()) { if (entry instanceof LibraryOrderEntry) { final LibraryOrderEntry libraryEntry = (LibraryOrderEntry)entry; if (libraryEntry.isModuleLevel()) { final String libraryName = libraryEntry.getLibraryName(); if (libraryName != null && libraryName.equals(myLibraryName)) { return libraryEntry.getLibrary(); } } } } } return null; }
Example 2
Source File: ChooseLibrariesDialogBase.java From consulo with Apache License 2.0 | 6 votes |
protected void collectChildren(Object element, final List<Object> result) { if (element instanceof Application) { Collections.addAll(result, ProjectManager.getInstance().getOpenProjects()); final LibraryTablesRegistrar instance = LibraryTablesRegistrar.getInstance(); result.add(instance.getLibraryTable()); //1 result.addAll(instance.getCustomLibraryTables()); //2 } else if (element instanceof Project) { Collections.addAll(result, ModuleManager.getInstance((Project)element).getModules()); result.add(LibraryTablesRegistrar.getInstance().getLibraryTable((Project)element)); } else if (element instanceof LibraryTable) { Collections.addAll(result, ((LibraryTable)element).getLibraries()); } else if (element instanceof Module) { for (OrderEntry entry : ModuleRootManager.getInstance((Module)element).getOrderEntries()) { if (entry instanceof LibraryOrderEntry) { final LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry)entry; if (LibraryTableImplUtil.MODULE_LEVEL.equals(libraryOrderEntry.getLibraryLevel())) { final Library library = libraryOrderEntry.getLibrary(); result.add(library); } } } } }
Example 3
Source File: ProjectStructureConfigurable.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public AsyncResult<Void> select(@Nonnull LibraryOrderEntry libraryOrderEntry, final boolean requestFocus) { final Library lib = libraryOrderEntry.getLibrary(); if (lib == null || lib.getTable() == null) { return selectOrderEntry(libraryOrderEntry.getOwnerModule(), libraryOrderEntry); } Place place = createPlaceFor(getConfigurableFor(lib)); place.putPath(BaseStructureConfigurable.TREE_NAME, libraryOrderEntry.getLibraryName()); return navigateTo(place, requestFocus); }
Example 4
Source File: CamelService.java From camel-idea-plugin with Apache License 2.0 | 4 votes |
/** * Scan for Camel project present and setup {@link CamelCatalog} to use same version of Camel as the project does. * These two version needs to be aligned to offer the best tooling support on the given project. */ public void scanForCamelProject(@NotNull Project project, @NotNull Module module) { for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) { if (!(entry instanceof LibraryOrderEntry)) { continue; } LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry) entry; String name = libraryOrderEntry.getPresentableName().toLowerCase(); if (!libraryOrderEntry.getScope().isForProductionCompile() && !libraryOrderEntry.getScope().isForProductionRuntime()) { continue; } final Library library = libraryOrderEntry.getLibrary(); if (library == null) { continue; } String[] split = name.split(":"); if (split.length < 3) { continue; } int startIdx = 0; if (split[0].equalsIgnoreCase("maven") || split[0].equalsIgnoreCase("gradle") || split[0].equalsIgnoreCase("sbt")) { startIdx = 1; } boolean hasVersion = split.length > (startIdx + 2); String groupId = split[startIdx++].trim(); String artifactId = split[startIdx++].trim(); String version = null; if (hasVersion) { version = split[startIdx].trim(); // adjust snapshot which must be in uppercase version = version.replace("snapshot", "SNAPSHOT"); } projectLibraries.add(library); if (isSlf4jMavenDependency(groupId, artifactId)) { slf4japiLibrary = library; } else if (isCamelCoreMavenDependency(groupId, artifactId)) { camelCoreLibrary = library; // okay its a camel project setCamelPresent(true); String currentVersion = getCamelCatalogService(project).get().getLoadedVersion(); if (currentVersion == null) { // okay no special version was loaded so its the catalog version we are using currentVersion = getCamelCatalogService(project).get().getCatalogVersion(); } if (isThereDifferentVersionToBeLoaded(version, currentVersion)) { boolean notifyNewCamelCatalogVersionLoaded = false; boolean downloadAllowed = getCamelPreferenceService().isDownloadCatalog(); if (downloadAllowed) { notifyNewCamelCatalogVersionLoaded = downloadNewCamelCatalogVersion(project, module, version, notifyNewCamelCatalogVersionLoaded); } if (notifyNewCamelCatalogVersionLoaded(notifyNewCamelCatalogVersionLoaded)) { expireOldCamelCatalogVersion(); } } // only notify this once on startup (or if a new version was successfully loaded) if (camelVersionNotification == null) { currentVersion = getCamelCatalogService(project).get().getLoadedVersion(); if (currentVersion == null) { // okay no special version was loaded so its the catalog version we are using currentVersion = getCamelCatalogService(project).get().getCatalogVersion(); } showCamelCatalogVersionAtPluginStart(project, currentVersion); } } } }
Example 5
Source File: CamelService.java From camel-idea-plugin with Apache License 2.0 | 4 votes |
/** * Scan for Camel component (both from Apache Camel and 3rd party components) */ public void scanForCamelDependencies(@NotNull Project project, @NotNull Module module) { boolean thirdParty = getCamelPreferenceService().isScanThirdPartyComponents(); CamelCatalog camelCatalog = getCamelCatalogService(project).get(); List<String> missingJSonSchemas = new ArrayList<>(); for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) { if (entry instanceof LibraryOrderEntry) { LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry) entry; String name = libraryOrderEntry.getPresentableName().toLowerCase(); if (libraryOrderEntry.getScope().isForProductionCompile() || libraryOrderEntry.getScope().isForProductionRuntime()) { final Library library = libraryOrderEntry.getLibrary(); if (library == null) { continue; } String[] split = name.split(":"); if (split.length < 3) { continue; } int startIdx = 0; if (split[0].equalsIgnoreCase("maven") || split[0].equalsIgnoreCase("gradle") || split[0].equalsIgnoreCase("sbt")) { startIdx = 1; } String groupId = split[startIdx++].trim(); String artifactId = split[startIdx].trim(); // is it a known library then continue if (containsLibrary(artifactId, true)) { continue; } if ("org.apache.camel".equals(groupId)) { addLibrary(artifactId); } else if (thirdParty) { addCustomCamelComponentsFromDependency(camelCatalog, library, artifactId, missingJSonSchemas); } } } } if (!missingJSonSchemas.isEmpty()) { String components = missingJSonSchemas.stream().collect(Collectors.joining(",")); String message = "The following Camel components with artifactId [" + components + "] does not include component JSon schema metadata which is required for the Camel IDEA plugin to support these components."; Icon icon = getCamelPreferenceService().getCamelIcon(); camelMissingJSonSchemaNotification = CAMEL_NOTIFICATION_GROUP.createNotification(message, NotificationType.WARNING).setImportant(true).setIcon(icon); camelMissingJSonSchemaNotification.notify(project); } }
Example 6
Source File: AddLibraryTargetDirectoryToProjectViewAttachSourcesProvider.java From intellij with Apache License 2.0 | 4 votes |
@NotNull @Override public Collection<AttachSourcesAction> getActions( List<LibraryOrderEntry> orderEntries, final PsiFile psiFile) { Project project = psiFile.getProject(); BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData(); if (blazeProjectData == null) { return ImmutableList.of(); } List<Library> librariesToAttachSourceTo = Lists.newArrayList(); for (LibraryOrderEntry orderEntry : orderEntries) { Library library = orderEntry.getLibrary(); WorkspacePath workspacePath = AddLibraryTargetDirectoryToProjectViewAction.getDirectoryToAddForLibrary( project, library); if (workspacePath == null) { continue; } librariesToAttachSourceTo.add(library); } if (librariesToAttachSourceTo.isEmpty()) { return ImmutableList.of(); } return ImmutableList.of( new AttachSourcesAction() { @Override public String getName() { return "Add Source Directories To Project View"; } @Override public String getBusyText() { return "Adding directories..."; } @Override public ActionCallback perform(List<LibraryOrderEntry> orderEntriesContainingFile) { AddLibraryTargetDirectoryToProjectViewAction.addDirectoriesToProjectView( project, librariesToAttachSourceTo); return ActionCallback.DONE; } }); }
Example 7
Source File: BlazeAttachSourceProvider.java From intellij with Apache License 2.0 | 4 votes |
@Override public Collection<AttachSourcesAction> getActions( List<LibraryOrderEntry> orderEntries, final PsiFile psiFile) { Project project = psiFile.getProject(); BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData(); if (blazeProjectData == null) { return ImmutableList.of(); } List<BlazeLibrary> librariesToAttachSourceTo = Lists.newArrayList(); for (LibraryOrderEntry orderEntry : orderEntries) { Library library = orderEntry.getLibrary(); if (library == null) { continue; } String name = library.getName(); if (name == null) { continue; } LibraryKey libraryKey = LibraryKey.fromIntelliJLibraryName(name); if (AttachedSourceJarManager.getInstance(project).hasSourceJarAttached(libraryKey)) { continue; } BlazeJarLibrary blazeLibrary = LibraryActionHelper.findLibraryFromIntellijLibrary(project, blazeProjectData, library); if (blazeLibrary == null) { continue; } LibraryArtifact libraryArtifact = blazeLibrary.libraryArtifact; if (libraryArtifact.getSourceJars().isEmpty()) { continue; } librariesToAttachSourceTo.add(blazeLibrary); } if (librariesToAttachSourceTo.isEmpty()) { return ImmutableList.of(); } // Hack: When sources are requested and we have them, we attach them automatically in the // background. if (attachAutomatically.getValue()) { TransactionGuard.getInstance() .submitTransactionLater( project, () -> { attachSources(project, blazeProjectData, librariesToAttachSourceTo); }); return ImmutableList.of(); } return ImmutableList.of( new AttachSourcesAction() { @Override public String getName() { return "Attach Blaze Source Jars"; } @Override public String getBusyText() { return "Attaching source jars..."; } @Override public ActionCallback perform(List<LibraryOrderEntry> orderEntriesContainingFile) { ActionCallback callback = new ActionCallback().doWhenDone(() -> navigateToSource(psiFile)); Transactions.submitTransaction( project, () -> { attachSources(project, blazeProjectData, librariesToAttachSourceTo); callback.setDone(); }); return callback; } }); }
Example 8
Source File: ModuleLibraryTable.java From consulo with Apache License 2.0 | 4 votes |
@Override public Library convert(LibraryOrderEntry o) { return o.getLibrary(); }