use of com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor in project kotlin by JetBrains.
the class KotlinDebuggerTestCase method configureLibrary.
private static void configureLibrary(@NotNull ModifiableRootModel model, @NotNull String libraryName, @NotNull File classes, @NotNull File sources) {
NewLibraryEditor customLibEditor = new NewLibraryEditor();
customLibEditor.setName(libraryName);
customLibEditor.addRoot(VfsUtil.getUrlForLibraryRoot(classes), OrderRootType.CLASSES);
customLibEditor.addRoot(VfsUtil.getUrlForLibraryRoot(sources), OrderRootType.SOURCES);
ConfigLibraryUtil.addLibrary(customLibEditor, model);
}
use of com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor in project kotlin by JetBrains.
the class KotlinJdkAndLibraryProjectDescriptor method configureModule.
@Override
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model) {
NewLibraryEditor editor = new NewLibraryEditor();
editor.setName(LIBRARY_NAME);
editor.addRoot(VfsUtil.getUrlForLibraryRoot(libraryFile), OrderRootType.CLASSES);
ConfigLibraryUtil.addLibrary(editor, model);
}
use of com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor in project intellij-community by JetBrains.
the class NewLibraryChooser method createLibrary.
@Nullable
public Library createLibrary() {
final NewLibraryConfiguration configuration = CreateNewLibraryAction.createNewLibraryConfiguration(myLibraryType, myParentComponent, myProject);
if (configuration == null)
return null;
final NewLibraryEditor libraryEditor = new NewLibraryEditor(configuration.getLibraryType(), configuration.getProperties());
libraryEditor.setName(configuration.getDefaultLibraryName());
configuration.addRoots(libraryEditor);
final LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
List<LibraryTable> tables = Arrays.asList(myRootModel.getModuleLibraryTable(), registrar.getLibraryTable(myProject), registrar.getLibraryTable());
CreateNewLibraryDialog dialog = new CreateNewLibraryDialog(myParentComponent, myContext, libraryEditor, tables, 1);
final Module contextModule = LangDataKeys.MODULE_CONTEXT.getData(DataManager.getInstance().getDataContext(myParentComponent));
dialog.setContextModule(contextModule);
if (dialog.showAndGet()) {
return dialog.createLibrary();
}
return null;
}
use of com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor in project intellij-community by JetBrains.
the class DownloadableLibraryPropertiesEditor method edit.
protected void edit() {
final ModalityState current = ModalityState.current();
myDescription.fetchVersions(new DownloadableFileSetVersions.FileSetVersionsCallback<FrameworkLibraryVersion>() {
@Override
public void onSuccess(@NotNull final List<? extends FrameworkLibraryVersion> versions) {
ApplicationManager.getApplication().invokeLater(() -> {
String pathForDownloaded = "";
final VirtualFile existingRootDirectory = myEditorComponent.getExistingRootDirectory();
if (existingRootDirectory != null) {
pathForDownloaded = existingRootDirectory.getPath();
} else {
final VirtualFile baseDir = myEditorComponent.getBaseDirectory();
if (baseDir != null) {
pathForDownloaded = baseDir.getPath() + "/lib";
}
}
final LibraryDownloadSettings initialSettings = new LibraryDownloadSettings(getCurrentVersion(versions), myLibraryType, LibrariesContainer.LibraryLevel.PROJECT, pathForDownloaded);
final LibraryDownloadSettings settings = DownloadingOptionsDialog.showDialog(getMainPanel(), initialSettings, versions, false);
if (settings != null) {
final NewLibraryEditor editor = settings.download(getMainPanel(), null);
if (editor != null) {
final LibraryEditorBase target = (LibraryEditorBase) myEditorComponent.getLibraryEditor();
target.removeAllRoots();
myEditorComponent.renameLibrary(editor.getName());
target.setType(myLibraryType);
editor.applyTo(target);
myEditorComponent.updateRootsTree();
myCurrentVersionString = settings.getVersion().getVersionString();
setModified();
}
}
}, current);
}
});
}
use of com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor in project intellij-community by JetBrains.
the class LibraryOptionsPanel method doCreate.
private void doCreate(boolean useDefaultSettings) {
final NewLibraryConfiguration libraryConfiguration = useDefaultSettings ? myLibraryDescription.createNewLibraryWithDefaultSettings(getBaseDirectory()) : myLibraryDescription.createNewLibrary(myCreateButton, getBaseDirectory());
if (libraryConfiguration != null) {
final NewLibraryEditor libraryEditor = new NewLibraryEditor(libraryConfiguration.getLibraryType(), libraryConfiguration.getProperties());
libraryEditor.setName(myLibrariesContainer.suggestUniqueLibraryName(libraryConfiguration.getDefaultLibraryName()));
libraryConfiguration.addRoots(libraryEditor);
if (myLibraryComboBoxModel.get(0) == null) {
myLibraryComboBoxModel.remove(0);
}
myLibraryComboBoxModel.add(libraryEditor);
myLibraryComboBoxModel.setSelectedItem(libraryEditor);
myButtonEnumModel.setSelected(Choice.USE_LIBRARY);
}
}
Aggregations