use of com.intellij.openapi.roots.libraries.LibraryTable in project intellij-community by JetBrains.
the class RootsChangedTest method testProjectLibraryChangeEvent.
public void testProjectLibraryChangeEvent() throws Exception {
final LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject);
verifyLibraryTableEditing(projectLibraryTable);
}
use of com.intellij.openapi.roots.libraries.LibraryTable in project intellij-community by JetBrains.
the class RootsChangedTest method testProjectLibraryEventsInUncommittedModel.
public void testProjectLibraryEventsInUncommittedModel() throws Exception {
final LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(myProject);
verifyLibraryTableEditingInUncommittedModel(projectLibraryTable);
}
use of com.intellij.openapi.roots.libraries.LibraryTable in project intellij-community by JetBrains.
the class ModuleRootsExternalizationTest method testModuleLibraries.
public void testModuleLibraries() throws Exception {
File moduleFile = new File(getTestRoot(), "test.iml");
Module module = createModule(moduleFile);
final ModuleRootManagerImpl moduleRootManager = (ModuleRootManagerImpl) ModuleRootManager.getInstance(module);
final ModifiableRootModel rootModel = moduleRootManager.getModifiableModel();
final LibraryTable moduleLibraryTable = rootModel.getModuleLibraryTable();
final Library unnamedLibrary = moduleLibraryTable.createLibrary();
final File unnamedLibClasses = new File(getTestRoot(), "unnamedLibClasses");
final VirtualFile unnamedLibClassesRoot = LocalFileSystem.getInstance().findFileByIoFile(unnamedLibClasses);
final Library.ModifiableModel libraryModifyableModel = unnamedLibrary.getModifiableModel();
libraryModifyableModel.addRoot(unnamedLibClassesRoot.getUrl(), OrderRootType.CLASSES);
final Library namedLibrary = moduleLibraryTable.createLibrary("namedLibrary");
final File namedLibClasses = new File(getTestRoot(), "namedLibClasses");
final VirtualFile namedLibClassesRoot = LocalFileSystem.getInstance().findFileByIoFile(namedLibClasses);
final Library.ModifiableModel namedLibraryModel = namedLibrary.getModifiableModel();
namedLibraryModel.addRoot(namedLibClassesRoot.getUrl(), OrderRootType.CLASSES);
ApplicationManager.getApplication().runWriteAction(() -> {
libraryModifyableModel.commit();
namedLibraryModel.commit();
});
final Iterator libraryIterator = moduleLibraryTable.getLibraryIterator();
assertEquals(libraryIterator.next(), unnamedLibrary);
assertEquals(libraryIterator.next(), namedLibrary);
ApplicationManager.getApplication().runWriteAction(rootModel::commit);
final Element element = new Element("root");
moduleRootManager.getState().writeExternal(element);
assertElementEquals(element, "<root inherit-compiler-output=\"true\">" + "<exclude-output />" + "<orderEntry type=\"sourceFolder\" forTests=\"false\" />" + "<orderEntry type=\"module-library\">" + "<library>" + "<CLASSES><root url=\"file://$MODULE_DIR$/unnamedLibClasses\" /></CLASSES>" + "<JAVADOC />" + "<SOURCES />" + "</library>" + "</orderEntry>" + "<orderEntry type=\"module-library\">" + "<library name=\"namedLibrary\">" + "<CLASSES><root url=\"file://$MODULE_DIR$/namedLibClasses\" /></CLASSES>" + "<JAVADOC />" + "<SOURCES />" + "</library>" + "</orderEntry>" + "</root>", module);
}
use of com.intellij.openapi.roots.libraries.LibraryTable in project intellij-community by JetBrains.
the class ClasspathPanelImpl method doEdit.
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();
}
use of com.intellij.openapi.roots.libraries.LibraryTable in project intellij-community by JetBrains.
the class LibrariesContainerFactory method createLibraryInTable.
@NotNull
private static Library createLibraryInTable(@NotNull final NewLibraryEditor editor, final LibraryTable table) {
LibraryTable.ModifiableModel modifiableModel = 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;
}
Aggregations