Java Code Examples for com.intellij.openapi.roots.libraries.LibraryTablesRegistrar#getInstance()

The following examples show how to use com.intellij.openapi.roots.libraries.LibraryTablesRegistrar#getInstance() . 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: LibrariesContainerFactory.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nonnull
public Library[] getLibraries(@Nonnull final LibraryLevel libraryLevel) {
  if (libraryLevel == LibraryLevel.MODULE && myModule != null) {
    return getModuleLibraries();
  }

  LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
  if (libraryLevel == LibraryLevel.GLOBAL) {
    return registrar.getLibraryTable().getLibraries();
  }

  if (libraryLevel == LibraryLevel.PROJECT && myProject != null) {
    return registrar.getLibraryTable(myProject).getLibraries();
  }

  return EMPTY_LIBRARIES_ARRAY;
}
 
Example 2
Source File: LibrariesContainerFactory.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public Library createLibrary(@Nonnull NewLibraryEditor libraryEditor,
                             @Nonnull LibraryLevel level) {
  if (level == LibraryLevel.MODULE && myRootModel != null) {
    return createLibraryInTable(libraryEditor, myRootModel.getModuleLibraryTable());
  }

  LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
  LibraryTable table;
  if (level == LibraryLevel.GLOBAL) {
    table = registrar.getLibraryTable();
  }
  else if (level == LibraryLevel.PROJECT && myProject != null) {
    table = registrar.getLibraryTable(myProject);
  }
  else {
    return null;
  }
  return createLibraryInTable(libraryEditor, table);
}
 
Example 3
Source File: ChooseLibrariesDialogBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 4
Source File: StructureConfigurableContext.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void resetLibraries() {
  final LibraryTablesRegistrar tablesRegistrar = LibraryTablesRegistrar.getInstance();

  myLevel2Providers.clear();
  myLevel2Providers.put(LibraryTablesRegistrar.APPLICATION_LEVEL, new LibrariesModifiableModel(tablesRegistrar.getLibraryTable(), myProject, this));
  myLevel2Providers.put(LibraryTablesRegistrar.PROJECT_LEVEL, new LibrariesModifiableModel(tablesRegistrar.getLibraryTable(myProject), myProject, this));
  for (final LibraryTable table : tablesRegistrar.getCustomLibraryTables()) {
    myLevel2Providers.put(table.getTableLevel(), new LibrariesModifiableModel(table, myProject, this));
  }
}
 
Example 5
Source File: ChooseLibrariesFromTablesDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static List<LibraryTable> getLibraryTables(final Project project, final boolean showCustomLibraryTables) {
  final List<LibraryTable> tables = new ArrayList<LibraryTable>();
  final LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
  if (project != null) {
    tables.add(registrar.getLibraryTable(project));
  }
  tables.add(registrar.getLibraryTable());
  if (showCustomLibraryTables) {
    for (LibraryTable table : registrar.getCustomLibraryTables()) {
      tables.add(table);
    }
  }
  return tables;
}
 
Example 6
Source File: ChooseLibrariesFromTablesDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
private boolean isProjectLibraryTable(LibraryTable libraryTable) {
  final LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
  return myProject != null && libraryTable.equals(registrar.getLibraryTable(myProject));
}