当前位置: 首页>>代码示例>>Java>>正文


Java VirtualFile.getChildren方法代码示例

本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFile.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualFile.getChildren方法的具体用法?Java VirtualFile.getChildren怎么用?Java VirtualFile.getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.vfs.VirtualFile的用法示例。


在下文中一共展示了VirtualFile.getChildren方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findMapFiles

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@NotNull
private static Map<String, VirtualFile> findMapFiles(@NotNull VirtualFile baseDir,
                                                     @NotNull String filter,
                                                     @NotNull String path)
{
    Map<String, VirtualFile> files = new HashMap<>();
    if (!baseDir.isDirectory() || baseDir.getName().startsWith("."))
    {
        return files;
    }
    VirtualFile[] children = baseDir.getChildren();
    String currentPath = path.isEmpty() ? baseDir.getName() : path + "/" + baseDir.getName();
    for (VirtualFile child : children)
    {
        if (child.isDirectory())
        {
            files.putAll(findMapFiles(child, filter, currentPath));
        }
        else if (filter.equals(child.getName()))
        {
            files.put(currentPath, child);
        }
    }
    return files;
}
 
开发者ID:miche-atucha,项目名称:deps-checker,代码行数:26,代码来源:VirtualFileHelper.java

示例2: packCourse

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private static void packCourse(@NotNull final VirtualFile baseDir, String locationDir, String zipName, boolean showMessage) {
  try {
    final File zipFile = new File(locationDir, zipName + ".zip");
    ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
    VirtualFile[] courseFiles = baseDir.getChildren();
    for (VirtualFile file : courseFiles) {
      ZipUtil.addFileOrDirRecursively(zos, null, new File(file.getPath()), file.getName(), null, null);
    }
    zos.close();
    if (showMessage) {
      ApplicationManager.getApplication().invokeLater(
        () -> Messages.showInfoMessage("Course archive was saved to " + zipFile.getPath(),
                                       "Course Archive Was Created Successfully"));

    }
  }
  catch (IOException e1) {
    LOG.error(e1);
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:21,代码来源:CCCreateCourseArchive.java

示例3: getJavaFileTree

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static List<VirtualFile> getJavaFileTree(Project project, VirtualFile file, boolean recursive) {
    List<VirtualFile> list = new ArrayList<VirtualFile>();
    if (!file.isDirectory()) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
        if (psiFile instanceof PsiJavaFile || file.getFileType().equals(StdFileTypes.JAVA)) {
            list.add(file);
        }
    } else if (recursive) {
        VirtualFile[] vfs = file.getChildren();
        if (vfs != null) {
            for (VirtualFile vf : vfs) {
                list.addAll(Utils.getJavaFileTree(project, vf, recursive));
            }
        }
    }
    return list;
}
 
开发者ID:Jamling,项目名称:Android-ORM-ASPlugin,代码行数:18,代码来源:Utils.java

示例4: getSourceFile

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
public static VirtualFile getSourceFile(VirtualFile baseDir, String fileName) {
    fileName = (fileName != null && !fileName.isEmpty()) ? fileName : FILE_NAME;
    VirtualFile[] children = baseDir.getChildren();
    for (VirtualFile v : children) {
        if (v.isDirectory()) {
            VirtualFile vf = Utils.getSourceFile(v, fileName);
            if (vf != null) {
                return vf;
            }
        } else {
            if (fileName.equals(v.getName()) && PARENT_FOLDER_NAME.equals(v.getParent().getName())) {
                return v;
            }
        }
    }
    return null;
}
 
开发者ID:crowdin,项目名称:android-studio-plugin,代码行数:18,代码来源:Utils.java

示例5: getFirstTaskFile

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Nullable
private static VirtualFile getFirstTaskFile(@NotNull final VirtualFile taskDir, @NotNull final Project project) {
  for (VirtualFile virtualFile : taskDir.getChildren()) {
    if (StudyUtils.getTaskFile(project, virtualFile) != null) {
      return virtualFile;
    }
  }
  return null;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:10,代码来源:StudyNavigator.java

示例6: cleanSourceRoot

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private void cleanSourceRoot( @NotNull VirtualFile contentRoot )
{
  try
  {
    LocalFileSystem tempFs = (LocalFileSystem)contentRoot.getFileSystem();
    for( VirtualFile child : contentRoot.getChildren() )
    {
      if( !tempFs.exists( child ) )
      {
        try
        {
          tempFs.createChildFile( this, contentRoot, child.getName() );
        }
        catch( IOException ignore )
        {

        }

      }
      child.delete( this );
    }
  }
  catch( IOException e )
  {
    throw new RuntimeException( e );
  }
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:28,代码来源:AbstractManifoldCodeInsightTest.java

示例7: createFileMap

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
public void createFileMap(@NotNull VirtualFile file) {
    fileMap.clear();
    VirtualFile parent = file.getParent();
    VirtualFile[] childs = parent.getChildren();
    languages = new String[childs.length];
    int cnt = 0;
    for (VirtualFile each : childs) {
        languages[cnt] = each.getNameWithoutExtension();
        fileMap.put(languages[cnt], each);
        cnt++;
    }
}
 
开发者ID:PioBeat,项目名称:GravSupport,代码行数:14,代码来源:LanguageFolderStrategy.java

示例8: format

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
private void format(VirtualFile file) {
	if (file.isDirectory()) {
		for (int i = 0; i < file.getChildren().length; i++)
			format(file.getChildren()[i]);
	} else {
		if (isYamlFile(file.getExtension())) {
			log("format : " + file.getPath());
			try {
				formatYaml(file);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:xusida,项目名称:yaml-format,代码行数:16,代码来源:FormatYamlAction.java

示例9: actionPerformed

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {

    VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
    if (file == null) {
        showError("找不到目标文件");
        return;
    }

    if (!file.isDirectory()) {
        showError("请选择layout文件夹");
        return;
    } else if (!file.getName().startsWith("layout")) {
        showError("请选择layout文件夹");
        return;
    }

    VirtualFile[] children = file.getChildren();

    StringBuilder sb = new StringBuilder();

    for (VirtualFile child : children) {
        layoutChild(child, sb);
    }

    VirtualFile resDir = file.getParent();
    if (resDir.getName().equalsIgnoreCase("res")) {
        VirtualFile[] chids = resDir.getChildren();
        for (VirtualFile chid : chids) {
            if (chid.getName().startsWith("values")) {
                if (chid.isDirectory()) {
                    VirtualFile[] values = chid.getChildren();
                    for (VirtualFile value : values) {
                        if (value.getName().startsWith("strings")) {
                            try {
                                String content = new String(value.contentsToByteArray(), "utf-8");
                                System.out.println("utf-8=" + content);
                                String result = content.replace("</resources>", sb.toString() + "\n</resources>");
                                FileUtils.replaceContentToFile(value.getPath(), result);
                            } catch (IOException e1) {
                                e1.printStackTrace();
                            }
                        }
                    }
                }
            }
        }
    }

    e.getActionManager().getAction(IdeActions.ACTION_SYNCHRONIZE).actionPerformed(e);

}
 
开发者ID:zhouzhuo810,项目名称:StringKiller,代码行数:53,代码来源:LayoutDirAction.java

示例10: textChanged

import com.intellij.openapi.vfs.VirtualFile; //导入方法依赖的package包/类
@Override
    public void textChanged(DocumentEvent event) {
        logger.debug("PDE core library directory browser text-field value changed to: " + localPdeLibraryBrowser.getText());

        String pathToPdeLibraryDir = localPdeLibraryBrowser.getText();

        if (! pathToPdeLibraryDir.isEmpty()) {
            VirtualFile pdeLibraryDirVirtualFile = LocalFileSystem.getInstance().findFileByPath(pathToPdeLibraryDir);

            if (pdeLibraryDirVirtualFile == null) {
                pdeCoreLibraryDirSelectErrorLabel.setText("Not a valid path.");
                pdeCoreLibraryDirSelectErrorLabel.setVisible(true);
                return;
            }

            if (! pdeLibraryDirVirtualFile.isDirectory()) {
                pdeCoreLibraryDirSelectErrorLabel.setText("Not a directory.");
                pdeCoreLibraryDirSelectErrorLabel.setVisible(true);
                return;
            }

            VirtualFile[] entries = pdeLibraryDirVirtualFile.getChildren();

            if (entries.length == 0) {
                pdeCoreLibraryDirSelectErrorLabel.setText("Directory empty.");
                pdeCoreLibraryDirSelectErrorLabel.setVisible(true);
                return;
            }

            boolean coreJarFound = false;
            for (VirtualFile virtualFile : entries) {
                if (virtualFile.getName().equals("core.jar")) {
                    coreJarFound = true;
                }
            }

            if (coreJarFound) {
                pdeCoreLibraryDirSelectErrorLabel.setVisible(false);
            } else {
                pdeCoreLibraryDirSelectErrorLabel.setText("No 'core.jar' found.");
                pdeCoreLibraryDirSelectErrorLabel.setVisible(true);
            }
        } else {
            pdeCoreLibraryDirSelectErrorLabel.setText("No directory selected.");
        }
}
 
开发者ID:mistodev,项目名称:processing-idea,代码行数:47,代码来源:ConfigureProcessingProject.java


注:本文中的com.intellij.openapi.vfs.VirtualFile.getChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。