use of com.intellij.openapi.roots.libraries.ui.OrderRoot 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.ui.OrderRoot in project azure-tools-for-java by Microsoft.
the class ApplicationInsightsPanel method configureAzureSDK.
private void configureAzureSDK() {
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
for (OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
if (orderEntry instanceof ModuleLibraryOrderEntryImpl && AzureLibrary.APP_INSIGHTS.getName().equals(((ModuleLibraryOrderEntryImpl) orderEntry).getLibraryName())) {
return;
}
}
final LibrariesContainer.LibraryLevel level = LibrariesContainer.LibraryLevel.MODULE;
AccessToken token = WriteAction.start();
try {
Library newLibrary = LibrariesContainerFactory.createContainer(modifiableModel).createLibrary(AzureLibrary.APP_INSIGHTS.getName(), level, new ArrayList<OrderRoot>());
for (OrderEntry orderEntry : modifiableModel.getOrderEntries()) {
if (orderEntry instanceof ModuleLibraryOrderEntryImpl && AzureLibrary.APP_INSIGHTS.getName().equals(((ModuleLibraryOrderEntryImpl) orderEntry).getLibraryName())) {
((ModuleLibraryOrderEntryImpl) orderEntry).setExported(true);
break;
}
}
Library.ModifiableModel newLibraryModel = newLibrary.getModifiableModel();
AddLibraryUtility.addLibraryFiles(new File(PluginHelper.getAzureLibLocation()), newLibraryModel, AzureLibrary.APP_INSIGHTS.getFiles());
newLibraryModel.commit();
modifiableModel.commit();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
token.finish();
}
}
use of com.intellij.openapi.roots.libraries.ui.OrderRoot in project intellij-community by JetBrains.
the class RepositoryAttachHandler method notifyArtifactsDownloaded.
public static void notifyArtifactsDownloaded(Project project, List<OrderRoot> roots) {
final StringBuilder sb = new StringBuilder();
final String title = "The following files were downloaded:";
sb.append("<ol>");
for (OrderRoot root : roots) {
sb.append("<li>");
sb.append(root.getFile().getName());
sb.append("</li>");
}
sb.append("</ol>");
Notifications.Bus.notify(new Notification("Repository", title, sb.toString(), NotificationType.INFORMATION), project);
}
use of com.intellij.openapi.roots.libraries.ui.OrderRoot in project intellij-community by JetBrains.
the class MarkLibraryRootAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = getEventProject(e);
if (project == null)
return;
final List<VirtualFile> jars = getRoots(e);
if (jars.isEmpty())
return;
final List<OrderRoot> roots = RootDetectionUtil.detectRoots(jars, null, project, new DefaultLibraryRootsComponentDescriptor());
new CreateLibraryFromFilesDialog(project, roots).show();
}
use of com.intellij.openapi.roots.libraries.ui.OrderRoot in project intellij-community by JetBrains.
the class CreateModuleLibraryFromFilesTest method testJarAndSources.
public void testJarAndSources() {
Library library = assertOneElement(createLibraries(new OrderRoot(getJDomJar(), OrderRootType.CLASSES), new OrderRoot(getJDomSources(), OrderRootType.SOURCES)));
assertNull(library.getName());
assertSameElements(library.getFiles(OrderRootType.CLASSES), getJDomJar());
assertSameElements(library.getFiles(OrderRootType.SOURCES), getJDomSources());
}
Aggregations