Java Code Examples for com.intellij.openapi.vfs.VirtualFile#EMPTY_ARRAY

The following examples show how to use com.intellij.openapi.vfs.VirtualFile#EMPTY_ARRAY . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Nonnull
protected final VirtualFile[] getSelectedFiles() {
  final TreePath[] selectionPaths = myTree.getSelectionPaths();
  if (selectionPaths == null) {
    return VirtualFile.EMPTY_ARRAY;
  }
  final List<VirtualFile> selected = new ArrayList<VirtualFile>();
  for (TreePath treePath : selectionPaths) {
    final DefaultMutableTreeNode node = (DefaultMutableTreeNode)treePath.getLastPathComponent();
    final Object nodeDescriptor = node.getUserObject();
    if (!(nodeDescriptor instanceof FileNodeDescriptor)) {
      return VirtualFile.EMPTY_ARRAY;
    }
    final FileElement fileElement = ((FileNodeDescriptor)nodeDescriptor).getElement();
    final VirtualFile file = fileElement.getFile();
    if (file != null) {
      selected.add(file);
    }
  }
  return selected.toArray(new VirtualFile[selected.size()]);
}
 
Example 2
Source Project: consulo   File: LibraryGroupNode.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
static VirtualFile[] getLibraryRoots(@Nonnull LibraryOrderEntry orderEntry) {
  Library library = orderEntry.getLibrary();
  if (library == null) return VirtualFile.EMPTY_ARRAY;
  OrderRootType[] rootTypes = LibraryType.getDefaultExternalRootTypes();
  if (library instanceof LibraryEx) {
    if (((LibraryEx)library).isDisposed()) return VirtualFile.EMPTY_ARRAY;
    PersistentLibraryKind<?> libKind = ((LibraryEx)library).getKind();
    if (libKind != null) {
      rootTypes = LibraryType.findByKind(libKind).getExternalRootTypes();
    }
  }
  final ArrayList<VirtualFile> files = new ArrayList<VirtualFile>();
  for (OrderRootType rootType : rootTypes) {
    files.addAll(Arrays.asList(library.getFiles(rootType)));
  }
  return VfsUtilCore.toVirtualFileArray(files);
}
 
Example 3
@RequiredReadAction
@Nonnull
@Override
public VirtualFile[] getGeneratedFiles() {
  String[] generatedFilePaths = getGeneratedFilePaths();
  if (generatedFilePaths.length == 0) {
    return VirtualFile.EMPTY_ARRAY;
  }
  List<VirtualFile> list = new ArrayList<>();
  for (String generatedFilePath : generatedFilePaths) {
    VirtualFile fileByPath = LocalFileSystem.getInstance().findFileByPath(generatedFilePath);
    if (fileByPath != null) {
      list.add(fileByPath);
    }
  }
  return VfsUtilCore.toVirtualFileArray(list);
}
 
Example 4
Source Project: consulo   File: FileChooserDialogImpl.java    License: Apache License 2.0 6 votes vote down vote up
private VirtualFile[] getSelectedFilesInt() {
  if (myTreeIsUpdating || !myUiUpdater.isEmpty()) {
    if (isTextFieldActive() && !StringUtil.isEmpty(myPathTextField.getTextFieldText())) {
      LookupFile toFind = myPathTextField.getFile();
      if (toFind instanceof LocalFsFinder.VfsFile && toFind.exists()) {
        VirtualFile file = ((LocalFsFinder.VfsFile)toFind).getFile();
        if (file != null) {
          return new VirtualFile[]{file};
        }
      }
    }
    return VirtualFile.EMPTY_ARRAY;
  }

  return myFileSystemTree.getSelectedFiles();
}
 
Example 5
@Override
public VirtualFile[] selectFiles(@NotNull JComponent parent,
                                 @Nullable VirtualFile initialSelection,
                                 @Nullable Module contextModule,
                                 @NotNull LibraryEditor libraryEditor) {
  final VirtualFile vFile = Util.showSpecifyJavadocUrlDialog(parent);
  if (vFile != null) {
    return new VirtualFile[]{vFile};
  }
  return VirtualFile.EMPTY_ARRAY;
}
 
Example 6
Source Project: consulo   File: FileIncludeManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public VirtualFile[] getIncludedFiles(@Nonnull VirtualFile file, boolean compileTimeOnly, boolean recursively) {
  if (file instanceof VirtualFileWithId) {
    return myIncludedHolder.getAllFiles(file, compileTimeOnly, recursively);
  }
  else {
    return VirtualFile.EMPTY_ARRAY;
  }
}
 
Example 7
@Nonnull
@Override
public VirtualFile[] getExcludeRootsForProject() {
  VirtualFile outputPath = CompilerConfiguration.getInstance(myProject).getCompilerOutput();
  if (outputPath != null) {
    return new VirtualFile[]{outputPath};
  }
  return VirtualFile.EMPTY_ARRAY;
}
 
Example 8
@Override
@Nonnull
public VirtualFile[] getFiles(OrderRootType type) {
  if (type == SourcesOrderRootType.getInstance()) {
    return myModuleRootLayer.getContentFolderFiles(ContentFolderScopes.productionAndTest());
  }
  return VirtualFile.EMPTY_ARRAY;
}
 
Example 9
@Nonnull
private static VirtualFile[] getLibraryFiles(@Nonnull Library library, @Nullable StructureConfigurableContext context) {
  if (((LibraryEx)library).isDisposed()) {
    return VirtualFile.EMPTY_ARRAY;
  }
  return context != null ? context.getLibraryFiles(library, BinariesOrderRootType.getInstance()) : library.getFiles(BinariesOrderRootType.getInstance());
}
 
Example 10
@Override
public VirtualFile[] selectFiles(@Nonnull JComponent parent,
                                 @Nullable VirtualFile initialSelection,
                                 @Nullable Module contextModule,
                                 @Nonnull LibraryEditor libraryEditor) {
  final VirtualFile vFile = Util.showSpecifyJavadocUrlDialog(parent);
  if (vFile != null) {
    return new VirtualFile[]{vFile};
  }
  return VirtualFile.EMPTY_ARRAY;
}
 
Example 11
Source Project: consulo   File: FileIncludeManagerImpl.java    License: Apache License 2.0 5 votes vote down vote up
private VirtualFile[] getFiles(@Nonnull VirtualFile file, boolean compileTimeOnly) {
  PsiFile psiFile = myPsiManager.findFile(file);
  if (psiFile == null) {
    return VirtualFile.EMPTY_ARRAY;
  }
  if (compileTimeOnly) {
    return CachedValuesManager.getManager(myProject).getParameterizedCachedValue(psiFile, COMPILE_TIME_KEY, COMPILE_TIME_PROVIDER, false, psiFile);
  }
  return CachedValuesManager.getManager(myProject).getParameterizedCachedValue(psiFile, RUNTIME_KEY, RUNTIME_PROVIDER, false, psiFile);
}
 
Example 12
Source Project: consulo   File: FileSystemTreeImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public VirtualFile[] getSelectedFiles() {
  final TreePath[] paths = myTree.getSelectionPaths();
  if (paths == null) return VirtualFile.EMPTY_ARRAY;

  final List<VirtualFile> files = new ArrayList<>();
  for (TreePath path : paths) {
    VirtualFile file = getVirtualFile(path);
    if (file != null && file.isValid()) {
      files.add(file);
    }
  }
  return VfsUtilCore.toVirtualFileArray(files);
}
 
Example 13
protected VirtualFile[] getVirtualFiles(AnActionEvent e) {
  final VirtualFile[] files = e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY);
  if (files != null) return files;

  final VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
  return file == null ? VirtualFile.EMPTY_ARRAY : new VirtualFile[]{file};
}
 
Example 14
Source Project: consulo   File: ModuleRootsProcessor.java    License: Apache License 2.0 4 votes vote down vote up
@Nonnull
@Deprecated
@DeprecationInfo(value = "Override #processFiles()")
public VirtualFile[] getFiles(@Nonnull ModuleRootModel moduleRootModel, @Nonnull Predicate<ContentFolderTypeProvider> predicate) {
  return VirtualFile.EMPTY_ARRAY;
}
 
Example 15
Source Project: consulo   File: UnknownOrderEntryImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public VirtualFile[] getFiles(OrderRootType type) {
  return VirtualFile.EMPTY_ARRAY;
}
 
Example 16
Source Project: consulo   File: RecursionDlg.java    License: Apache License 2.0 4 votes vote down vote up
private void setupControls() {
  setTitle("Update Copyright");

  setOKButtonText("Run");

  ButtonGroup group = new ButtonGroup();
  group.add(rbFile);
  group.add(rbAll);

  rbFile.setMnemonic('F');
  rbAll.setMnemonic('A');
  cbSubdirs.setMnemonic('I');

  if (file.isDirectory()) {
    rbFile.setText("File");
    rbFile.setEnabled(false);
    rbAll.setText("All files in " + file.getPresentableUrl());
    rbAll.setSelected(true);
    cbSubdirs.setSelected(true);
    cbSubdirs.setEnabled(true);
  }
  else {
    VirtualFile parent = file.getParent();
    rbFile.setText("File '" + file.getPresentableUrl() + '\'');
    rbFile.setSelected(true);
    if (parent != null) {
      rbAll.setText("All files in " + parent.getPresentableUrl());
      cbSubdirs.setSelected(true);
      cbSubdirs.setEnabled(false);
    }
    else {
      rbAll.setVisible(false);
      cbSubdirs.setVisible(false);
    }
  }

  VirtualFile check = file;
  if (!file.isDirectory()) {
    check = file.getParent();
  }
  ProjectRootManager prm = ProjectRootManager.getInstance(project);
  ProjectFileIndex pfi = prm.getFileIndex();

  VirtualFile[] children = check != null ? check.getChildren() : VirtualFile.EMPTY_ARRAY;
  boolean hasSubdirs = false;
  for (int i = 0; i < children.length && !hasSubdirs; i++) {
    if (children[i].isDirectory() && !pfi.isExcluded(children[i])) {
      hasSubdirs = true;
    }
  }

  cbSubdirs.setVisible(hasSubdirs);
  if (!hasSubdirs) {
    cbSubdirs.setEnabled(false);
    mainPanel.remove(cbSubdirs);
  }

  ActionListener listener = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      if (cbSubdirs.isVisible()) {
        cbSubdirs.setEnabled(rbAll.isSelected());
      }
    }
  };

  rbFile.addActionListener(listener);
  rbAll.addActionListener(listener);
}
 
Example 17
Source Project: consulo   File: LibraryImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public VirtualFile[] getExcludedRoots() {
  return myExcludedRoots != null ? myExcludedRoots.getFiles() : VirtualFile.EMPTY_ARRAY;
}
 
Example 18
Source Project: consulo   File: DummyCompileContext.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public VirtualFile[] getSourceRoots(Module module) {
  return VirtualFile.EMPTY_ARRAY;
}
 
Example 19
Source Project: consulo   File: DummyCompileContext.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public VirtualFile[] getAllOutputDirectories() {
  return VirtualFile.EMPTY_ARRAY;
}
 
Example 20
Source Project: consulo   File: FileTreeModel.java    License: Apache License 2.0 4 votes vote down vote up
private VirtualFile[] getChildren(VirtualFile file) {
  if (file.isDirectory()) return file.getChildren();
  if (!descriptor.isChooseJarContents() || !FileElement.isArchive(file)) return null;
  VirtualFile archiveRootForLocalFile = ArchiveVfsUtil.getArchiveRootForLocalFile(file);
  return archiveRootForLocalFile == null ? VirtualFile.EMPTY_ARRAY : archiveRootForLocalFile.getChildren();
}