當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。