Search in sources :

Example 1 with OrderRoot

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);
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DefaultLibraryRootsComponentDescriptor(com.intellij.openapi.roots.ui.configuration.libraryEditor.DefaultLibraryRootsComponentDescriptor) LibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) OrderRoot(com.intellij.openapi.roots.libraries.ui.OrderRoot) NotNull(org.jetbrains.annotations.NotNull) NewLibraryConfiguration(com.intellij.openapi.roots.libraries.NewLibraryConfiguration)

Example 2 with OrderRoot

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();
    }
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) OrderEntry(com.intellij.openapi.roots.OrderEntry) AccessToken(com.intellij.openapi.application.AccessToken) ModuleLibraryOrderEntryImpl(com.intellij.openapi.roots.impl.ModuleLibraryOrderEntryImpl) LibrariesContainer(com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer) OrderRoot(com.intellij.openapi.roots.libraries.ui.OrderRoot) Library(com.intellij.openapi.roots.libraries.Library) File(java.io.File)

Example 3 with OrderRoot

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);
}
Also used : OrderRoot(com.intellij.openapi.roots.libraries.ui.OrderRoot) Notification(com.intellij.notification.Notification)

Example 4 with OrderRoot

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();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) DefaultLibraryRootsComponentDescriptor(com.intellij.openapi.roots.ui.configuration.libraryEditor.DefaultLibraryRootsComponentDescriptor) OrderRoot(com.intellij.openapi.roots.libraries.ui.OrderRoot)

Example 5 with OrderRoot

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());
}
Also used : OrderRoot(com.intellij.openapi.roots.libraries.ui.OrderRoot) Library(com.intellij.openapi.roots.libraries.Library)

Aggregations

OrderRoot (com.intellij.openapi.roots.libraries.ui.OrderRoot)27 VirtualFile (com.intellij.openapi.vfs.VirtualFile)12 Library (com.intellij.openapi.roots.libraries.Library)8 NotNull (org.jetbrains.annotations.NotNull)7 DefaultLibraryRootsComponentDescriptor (com.intellij.openapi.roots.ui.configuration.libraryEditor.DefaultLibraryRootsComponentDescriptor)5 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)4 Project (com.intellij.openapi.project.Project)4 File (java.io.File)4 OrderRootType (com.intellij.openapi.roots.OrderRootType)3 Pair (com.intellij.openapi.util.Pair)3 AndroidSdkAdditionalData (org.jetbrains.android.sdk.AndroidSdkAdditionalData)3 Nullable (org.jetbrains.annotations.Nullable)3 AccessToken (com.intellij.openapi.application.AccessToken)2 Module (com.intellij.openapi.module.Module)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 SdkModificator (com.intellij.openapi.projectRoots.SdkModificator)2 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)2 OrderEntry (com.intellij.openapi.roots.OrderEntry)2 ModuleLibraryOrderEntryImpl (com.intellij.openapi.roots.impl.ModuleLibraryOrderEntryImpl)2 LibraryEx (com.intellij.openapi.roots.impl.libraries.LibraryEx)2