use of com.intellij.openapi.roots.libraries.NewLibraryConfiguration in project intellij-community by JetBrains.
the class RepositoryAttachHandler method chooseLibraryAndDownload.
@Nullable
public static NewLibraryConfiguration chooseLibraryAndDownload(@NotNull final Project project, @Nullable final String initialFilter, JComponent parentComponent) {
RepositoryAttachDialog dialog = new RepositoryAttachDialog(project, initialFilter);
dialog.setTitle("Download Library From Maven Repository");
dialog.show();
if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
return null;
}
String copyTo = dialog.getDirectoryPath();
String coord = dialog.getCoordinateText();
boolean attachJavaDoc = dialog.getAttachJavaDoc();
boolean attachSources = dialog.getAttachSources();
List<MavenRepositoryInfo> repositories = dialog.getRepositories();
@Nullable NewLibraryConfiguration configuration = resolveAndDownload(project, coord, attachJavaDoc, attachSources, copyTo, repositories);
if (configuration == null) {
Messages.showErrorDialog(parentComponent, ProjectBundle.message("maven.downloading.failed", coord), CommonBundle.getErrorTitle());
}
return configuration;
}
use of com.intellij.openapi.roots.libraries.NewLibraryConfiguration in project azure-tools-for-java by Microsoft.
the class SparkLibraryDescription method getSparkSDKConfigurationFromLocalFile.
private NewLibraryConfiguration getSparkSDKConfigurationFromLocalFile() {
FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, false, true, false, true, false);
chooserDescriptor.setTitle("Select Spark SDK");
String pluginPath = PluginUtil.getPluginRootDirectory();
VirtualFile pluginVfs = LocalFileSystem.getInstance().findFileByPath(pluginPath);
VirtualFile chooseFile = FileChooser.chooseFile(chooserDescriptor, null, pluginVfs);
if (chooseFile == null) {
return null;
}
this.localPath = chooseFile.getPath();
final List<OrderRoot> roots = RootDetectionUtil.detectRoots(Arrays.asList(chooseFile), null, null, new DefaultLibraryRootsComponentDescriptor());
if (roots.isEmpty()) {
return null;
}
return new NewLibraryConfiguration(LibraryTypeServiceImpl.suggestLibraryName(roots), SparkLibraryType.getInstance(), new SparkLibraryProperties()) {
@Override
public void addRoots(@NotNull LibraryEditor libraryEditor) {
libraryEditor.addRoots(roots);
}
};
}
use of com.intellij.openapi.roots.libraries.NewLibraryConfiguration in project intellij-community by JetBrains.
the class CreateNewLibraryAction method createNewLibraryConfiguration.
@Nullable
public static NewLibraryConfiguration createNewLibraryConfiguration(@Nullable LibraryType type, @NotNull JComponent parentComponent, @NotNull Project project) {
final NewLibraryConfiguration configuration;
final VirtualFile baseDir = project.getBaseDir();
if (type != null) {
configuration = type.createNewLibrary(parentComponent, baseDir, project);
} else {
configuration = LibraryTypeService.getInstance().createLibraryFromFiles(new DefaultLibraryRootsComponentDescriptor(), parentComponent, baseDir, null, project);
}
if (configuration == null)
return null;
return configuration;
}
use of com.intellij.openapi.roots.libraries.NewLibraryConfiguration in project intellij-community by JetBrains.
the class CustomLibraryDescriptionBase method createNewLibrary.
@Override
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, VirtualFile contextDirectory) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, false, false, true);
descriptor.setTitle(IdeBundle.message("new.library.file.chooser.title"));
descriptor.setDescription(IdeBundle.message("new.library.file.chooser.description"));
final VirtualFile[] files = FileChooser.chooseFiles(descriptor, parentComponent, null, contextDirectory);
if (files.length == 0) {
return null;
}
return new NewLibraryConfiguration(myDefaultLibraryName, getDownloadableLibraryType(), new LibraryVersionProperties()) {
@Override
public void addRoots(@NotNull LibraryEditor editor) {
for (VirtualFile file : files) {
editor.addRoot(file, OrderRootType.CLASSES);
}
}
};
}
use of com.intellij.openapi.roots.libraries.NewLibraryConfiguration in project intellij-community by JetBrains.
the class GroovyLibraryDescription method createNewLibrary.
@Override
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, VirtualFile contextDirectory) {
VirtualFile initial = findFile(System.getenv(myEnvVariable));
if (initial == null && GROOVY_FRAMEWORK_NAME.equals(myFrameworkName) && SystemInfo.isLinux) {
initial = findFile("/usr/share/groovy");
}
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false) {
@Override
public boolean isFileSelectable(VirtualFile file) {
if (!super.isFileSelectable(file)) {
return false;
}
return findManager(file) != null;
}
};
descriptor.setTitle(myFrameworkName + " SDK");
descriptor.setDescription("Choose a directory containing " + myFrameworkName + " distribution");
final VirtualFile dir = FileChooser.chooseFile(descriptor, parentComponent, null, initial);
if (dir == null)
return null;
final GroovyLibraryPresentationProviderBase provider = findManager(dir);
if (provider == null) {
return null;
}
final String path = dir.getPath();
final String sdkVersion = provider.getSDKVersion(path);
if (AbstractConfigUtils.UNDEFINED_VERSION.equals(sdkVersion)) {
Messages.showErrorDialog(parentComponent, "Looks like " + myFrameworkName + " distribution in specified path is broken. Cannot determine version.", "Failed to Create Library");
return null;
}
return new NewLibraryConfiguration(provider.getLibraryPrefix() + "-" + sdkVersion) {
@Override
public void addRoots(@NotNull LibraryEditor editor) {
provider.fillLibrary(path, editor);
}
};
}
Aggregations