Search in sources :

Example 1 with LibraryRootsDetectorImpl

use of com.intellij.openapi.roots.libraries.ui.impl.LibraryRootsDetectorImpl in project intellij-community by JetBrains.

the class LibrarySourceRootDetectorUtil method scanAndSelectDetectedJavaSourceRoots.

/**
   * This method takes a candidates for the project root, then scans the candidates and
   * if multiple candidates or non root source directories are found within some
   * directories, it shows a dialog that allows selecting or deselecting them.
   * @param parent a parent parent or project
   * @param rootCandidates a candidates for roots
   * @return a array of source folders or empty array if non was selected or dialog was canceled.
   */
public static VirtualFile[] scanAndSelectDetectedJavaSourceRoots(Component parentComponent, final VirtualFile[] rootCandidates) {
    final List<OrderRoot> orderRoots = RootDetectionUtil.detectRoots(Arrays.asList(rootCandidates), parentComponent, null, new LibraryRootsDetectorImpl(Arrays.asList(Extensions.getExtensions(JAVA_SOURCE_ROOT_DETECTOR))), new OrderRootType[] { OrderRootType.SOURCES });
    final List<VirtualFile> result = new ArrayList<>();
    for (OrderRoot root : orderRoots) {
        result.add(root.getFile());
    }
    return VfsUtil.toVirtualFileArray(result);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LibraryRootsDetectorImpl(com.intellij.openapi.roots.libraries.ui.impl.LibraryRootsDetectorImpl) OrderRoot(com.intellij.openapi.roots.libraries.ui.OrderRoot)

Aggregations

OrderRoot (com.intellij.openapi.roots.libraries.ui.OrderRoot)1 LibraryRootsDetectorImpl (com.intellij.openapi.roots.libraries.ui.impl.LibraryRootsDetectorImpl)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1