Search in sources :

Example 26 with OrderRoot

use of com.intellij.openapi.roots.libraries.ui.OrderRoot in project android by JetBrains.

the class AndroidSdks method addJavaDocAndSources.

private static boolean addJavaDocAndSources(@NotNull List<OrderRoot> orderRoots, @NotNull VirtualFile sdkFolder) {
    boolean found = false;
    VirtualFile javadocFolder = findJavadocFolder(sdkFolder);
    if (javadocFolder != null) {
        orderRoots.add(new OrderRoot(javadocFolder, JavadocOrderRootType.getInstance()));
        found = true;
    }
    VirtualFile sourcesFolder = sdkFolder.findChild(FD_SOURCES);
    if (sourcesFolder != null) {
        orderRoots.add(new OrderRoot(sourcesFolder, SOURCES));
        found = true;
    }
    return found;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) OrderRoot(com.intellij.openapi.roots.libraries.ui.OrderRoot)

Example 27 with OrderRoot

use of com.intellij.openapi.roots.libraries.ui.OrderRoot in project android by JetBrains.

the class AndroidFacetImporterBase method createNewAndroidSdkForMaven.

@Nullable
private static Sdk createNewAndroidSdkForMaven(File sdkPath, IAndroidTarget target) {
    AndroidSdks androidSdks = AndroidSdks.getInstance();
    Sdk sdk = null;
    Sdk jdk = Jdks.getInstance().chooseOrCreateJavaSdk();
    if (jdk != null) {
        String sdkName = "Maven " + androidSdks.chooseNameForNewLibrary(target);
        sdk = androidSdks.create(target, sdkPath, sdkName, jdk, false);
    }
    if (sdk == null) {
        return null;
    }
    SdkModificator modificator = sdk.getSdkModificator();
    for (OrderRoot root : androidSdks.getLibraryRootsForTarget(target, sdkPath, false)) {
        modificator.addRoot(root.getFile(), root.getType());
    }
    AndroidSdkAdditionalData data = androidSdks.getAndroidSdkAdditionalData(sdk);
    if (data != null) {
        final Sdk javaSdk = data.getJavaSdk();
        if (javaSdk != null) {
            for (VirtualFile file : javaSdk.getRootProvider().getFiles(OrderRootType.CLASSES)) {
                modificator.addRoot(file, OrderRootType.CLASSES);
            }
        } else {
            LOG.error("AndroidSdkUtils.createNewAndroidPlatform should return Android SDK with a valid JDK reference, or return null");
        }
    }
    modificator.commitChanges();
    return sdk;
}
Also used : AndroidSdks(com.android.tools.idea.sdk.AndroidSdks) AndroidSdkAdditionalData(org.jetbrains.android.sdk.AndroidSdkAdditionalData) OrderRoot(com.intellij.openapi.roots.libraries.ui.OrderRoot) Sdk(com.intellij.openapi.projectRoots.Sdk) SdkModificator(com.intellij.openapi.projectRoots.SdkModificator) Nullable(org.jetbrains.annotations.Nullable)

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