Java Code Examples for com.intellij.openapi.roots.libraries.LibraryTable#getModifiableModel()

The following examples show how to use com.intellij.openapi.roots.libraries.LibraryTable#getModifiableModel() . 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: ClasspathPanelImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nonnull
public LibraryTableModifiableModelProvider getModifiableModelProvider(@Nonnull 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);
  }
}
 
Example 2
Source File: LibrariesContainerFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static Library createLibraryInTable(final @Nonnull NewLibraryEditor editor, final LibraryTable table) {
  LibraryTableBase.ModifiableModelEx modifiableModel = (LibraryTableBase.ModifiableModelEx) table.getModifiableModel();
  final String name = StringUtil.isEmpty(editor.getName()) ? null : getUniqueLibraryName(editor.getName(), modifiableModel);
  final LibraryType<?> type = editor.getType();
  Library library = modifiableModel.createLibrary(name, type == null ? null : type.getKind());
  final LibraryEx.ModifiableModelEx model = (LibraryEx.ModifiableModelEx)library.getModifiableModel();
  editor.applyTo(model);
  model.commit();
  modifiableModel.commit();
  return library;
}
 
Example 3
Source File: StructureConfigurableContext.java    From consulo with Apache License 2.0 5 votes vote down vote up
public LibraryTable.ModifiableModel getModifiableLibraryTable(@Nonnull LibraryTable table) {
  final String tableLevel = table.getTableLevel();
  if (tableLevel.equals(LibraryTableImplUtil.MODULE_LEVEL)) {
    return table.getModifiableModel();
  }
  return myLevel2Providers.get(tableLevel);
}