本文整理汇总了Java中com.intellij.openapi.vfs.LocalFileSystem.refreshAndFindFileByIoFile方法的典型用法代码示例。如果您正苦于以下问题:Java LocalFileSystem.refreshAndFindFileByIoFile方法的具体用法?Java LocalFileSystem.refreshAndFindFileByIoFile怎么用?Java LocalFileSystem.refreshAndFindFileByIoFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.LocalFileSystem
的用法示例。
在下文中一共展示了LocalFileSystem.refreshAndFindFileByIoFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFromTempFile
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
public static FileContent createFromTempFile(Project project, String name, String ext, @NotNull byte[] content) throws IOException {
File tempFile = FileUtil.createTempFile(name, "." + ext);
if (content.length != 0) {
FileUtil.writeToFile(tempFile, content);
}
tempFile.deleteOnExit();
final LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile file = lfs.findFileByIoFile(tempFile);
if (file == null) {
file = lfs.refreshAndFindFileByIoFile(tempFile);
}
if (file != null) {
return new FileContent(project, file);
}
throw new IOException("Can not create temp file for revision content");
}
示例2: openFiles
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
private void openFiles(final Project project, final List<File> fileList, EditorWindow editorWindow) {
if (editorWindow == null && myEditor != null) {
editorWindow = findEditorWindow(project);
}
final LocalFileSystem fileSystem = LocalFileSystem.getInstance();
for (File file : fileList) {
final VirtualFile vFile = fileSystem.refreshAndFindFileByIoFile(file);
final FileEditorManagerEx fileEditorManager = (FileEditorManagerEx) FileEditorManager.getInstance(project);
if (vFile != null) {
if (editorWindow != null) {
fileEditorManager.openFileWithProviders(vFile, true, editorWindow);
}
else {
new OpenFileDescriptor(project, vFile).navigate(true);
}
}
}
}
示例3: doCheckout
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
public void doCheckout(@NotNull final Project project, @Nullable final Listener listener, @Nullable String predefinedRepositoryUrl) {
BasicAction.saveAll();
GitCloneDialog dialog = new GitCloneDialog(project, predefinedRepositoryUrl);
if (!dialog.showAndGet()) {
return;
}
dialog.rememberSettings();
final LocalFileSystem lfs = LocalFileSystem.getInstance();
final File parent = new File(dialog.getParentDirectory());
VirtualFile destinationParent = lfs.findFileByIoFile(parent);
if (destinationParent == null) {
destinationParent = lfs.refreshAndFindFileByIoFile(parent);
}
if (destinationParent == null) {
return;
}
final String sourceRepositoryURL = dialog.getSourceRepositoryURL();
final String directoryName = dialog.getDirectoryName();
final String parentDirectory = dialog.getParentDirectory();
clone(project, myGit, listener, destinationParent, sourceRepositoryURL, directoryName, parentDirectory);
}
示例4: setupRootModel
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
@Override
public void setupRootModel(final ModifiableRootModel modifiableRootModel) throws ConfigurationException {
super.setupRootModel(modifiableRootModel);
String contentEntryPath = getContentEntryPath();
if (StringUtil.isEmpty(contentEntryPath)) {
throw new ConfigurationException("There is no valid content entry path associated with the module. Unable to generate template directory structure.");
}
LocalFileSystem fileSystem = getInstance();
VirtualFile modelContentRootDir = fileSystem.refreshAndFindFileByIoFile(new File(contentEntryPath));
if (modelContentRootDir == null) {
throw new ConfigurationException("Model content root directory '" + contentEntryPath + "' could not be found. Unable to generate template directory structure.");
}
ContentEntry content = modifiableRootModel.addContentEntry(modelContentRootDir);
try {
VirtualFile sourceCodeDir = VfsUtil.createDirectories(modelContentRootDir.getPath() + "/src/main/java");
VfsUtil.createDirectories(modelContentRootDir.getPath() + "/src/main/java/com/processing/sketch");
VirtualFile resources = VfsUtil.createDirectories(modelContentRootDir.getPath() + "/src/main/resources");
content.addSourceFolder(sourceCodeDir, false);
content.addSourceFolder(resources, JavaResourceRootType.RESOURCE, JavaResourceRootType.RESOURCE.createDefaultProperties());
} catch (IOException io) {
logger.error("Unable to generate template directory structure:", io);
throw new ConfigurationException("Unable to generate template directory structure.");
}
VirtualFile sketchPackagePointer = getInstance().refreshAndFindFileByPath(getContentEntryPath() + "/src/main/java/com/processing/sketch");
if (generateTemplateSketchClass) {
ApplicationManager.getApplication().runWriteAction(new CreateSketchTemplateFile(sketchPackagePointer));
}
}
示例5: refreshOutputDirectories
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
public static void refreshOutputDirectories(Collection<File> outputs, boolean async) {
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
List<VirtualFile> toRefresh = new ArrayList<VirtualFile>();
int newDirectories = 0;
for (File ioOutput : outputs) {
VirtualFile output = fileSystem.findFileByIoFile(ioOutput);
if (output != null) {
toRefresh.add(output);
}
else if (ioOutput.exists()) {
VirtualFile parent = fileSystem.refreshAndFindFileByIoFile(ioOutput.getParentFile());
if (parent != null) {
parent.getChildren();
toRefresh.add(parent);
newDirectories++;
}
}
}
if (newDirectories > 10) {
LOG.info(newDirectories + " new output directories were created, refreshing their parents together to avoid too many rootsChange events");
RefreshQueue.getInstance().refresh(async, false, null, toRefresh);
}
else {
LOG.debug("Refreshing " + outputs.size() + " outputs");
fileSystem.refreshIoFiles(outputs, async, false, null);
}
}
示例6: findValidParentAccurately
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
@Nullable
public static VirtualFile findValidParentAccurately(final FilePath filePath) {
if (filePath.getVirtualFile() != null) return filePath.getVirtualFile();
final LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile result = lfs.findFileByIoFile(filePath.getIOFile());
if (result != null) return result;
if (! ApplicationManager.getApplication().isReadAccessAllowed()) {
result = lfs.refreshAndFindFileByIoFile(filePath.getIOFile());
if (result != null) return result;
}
return getValidParentUnderReadAction(filePath);
}
示例7: refreshPassedFilesAndMoveToChangelist
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
@CalledInAwt
public static void refreshPassedFilesAndMoveToChangelist(@NotNull final Project project,
final Collection<FilePath> directlyAffected,
final Collection<VirtualFile> indirectlyAffected,
final Consumer<Collection<FilePath>> targetChangelistMover) {
final LocalFileSystem lfs = LocalFileSystem.getInstance();
for (FilePath filePath : directlyAffected) {
lfs.refreshAndFindFileByIoFile(filePath.getIOFile());
}
lfs.refreshFiles(indirectlyAffected, false, true, null);
if (project.isDisposed()) return;
final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
if (! directlyAffected.isEmpty() && targetChangelistMover != null) {
changeListManager.invokeAfterUpdate(new Runnable() {
@Override
public void run() {
targetChangelistMover.consume(directlyAffected);
}
}, InvokeAfterUpdateMode.SYNCHRONOUS_CANCELLABLE,
VcsBundle.message("change.lists.manager.move.changes.to.list"),
new Consumer<VcsDirtyScopeManager>() {
@Override
public void consume(final VcsDirtyScopeManager vcsDirtyScopeManager) {
markDirty(vcsDirtyScopeManager, directlyAffected, indirectlyAffected);
}
}, null);
} else {
markDirty(VcsDirtyScopeManager.getInstance(project), directlyAffected, indirectlyAffected);
}
}
示例8: FileGroupingProjectNode
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
public FileGroupingProjectNode(Project project, File file, ViewSettings viewSettings) {
super(project, file, viewSettings);
final LocalFileSystem lfs = LocalFileSystem.getInstance();
myVirtualFile = lfs.findFileByIoFile(file);
if (myVirtualFile == null) {
myVirtualFile = lfs.refreshAndFindFileByIoFile(file);
}
}
示例9: appendNestedVcsRootsToDirt
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
public static void appendNestedVcsRootsToDirt(final VcsDirtyScope dirtyScope, GitVcs vcs, final ProjectLevelVcsManager vcsManager) {
final Set<FilePath> recursivelyDirtyDirectories = dirtyScope.getRecursivelyDirtyDirectories();
if (recursivelyDirtyDirectories.isEmpty()) {
return;
}
final LocalFileSystem lfs = LocalFileSystem.getInstance();
final Set<VirtualFile> rootsUnderGit = new HashSet<VirtualFile>(Arrays.asList(vcsManager.getRootsUnderVcs(vcs)));
final Set<VirtualFile> inputColl = new HashSet<VirtualFile>(rootsUnderGit);
final Set<VirtualFile> existingInScope = new HashSet<VirtualFile>();
for (FilePath dir : recursivelyDirtyDirectories) {
VirtualFile vf = dir.getVirtualFile();
if (vf == null) {
vf = lfs.findFileByIoFile(dir.getIOFile());
}
if (vf == null) {
vf = lfs.refreshAndFindFileByIoFile(dir.getIOFile());
}
if (vf != null) {
existingInScope.add(vf);
}
}
inputColl.addAll(existingInScope);
FileUtil.removeAncestors(inputColl, new Convertor<VirtualFile, String>() {
@Override
public String convert(VirtualFile o) {
return o.getPath();
}
}, new PairProcessor<VirtualFile, VirtualFile>() {
@Override
public boolean process(VirtualFile parent, VirtualFile child) {
if (! existingInScope.contains(child) && existingInScope.contains(parent)) {
debug("adding git root for check: " + child.getPath());
((VcsModifiableDirtyScope)dirtyScope).addDirtyDirRecursively(VcsUtil.getFilePath(child));
}
return true;
}
}
);
}
示例10: crawlWCRoots
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
public static Collection<VirtualFile> crawlWCRoots(final Project project, File path, SvnWCRootCrawler callback, ProgressIndicator progress) {
final LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile vf = lfs.findFileByIoFile(path);
if (vf == null) {
vf = lfs.refreshAndFindFileByIoFile(path);
}
if (vf == null) return Collections.emptyList();
return crawlWCRoots(project, vf, callback, progress);
}
示例11: run
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
public void run() {
final LocalFileSystem lfs = LocalFileSystem.getInstance();
final FileGroup conflictedGroup = myUpdatedFiles.getGroupById(FileGroup.MERGED_WITH_TREE_CONFLICT);
final Collection<String> conflictedFiles = conflictedGroup.getFiles();
final Collection<VirtualFile> parents = new ArrayList<VirtualFile>();
if ((conflictedFiles != null) && (! conflictedFiles.isEmpty())) {
for (final String conflictedFile : conflictedFiles) {
final File file = new File(conflictedFile);
final VirtualFile vfFile = lfs.refreshAndFindFileByIoFile(file);
if (vfFile != null) {
parents.add(vfFile);
continue;
}
final File parent = file.getParentFile();
VirtualFile vf = lfs.findFileByIoFile(parent);
if (vf == null) {
vf = lfs.refreshAndFindFileByIoFile(parent);
}
if (vf != null) {
parents.add(vf);
}
}
}
if (! parents.isEmpty()) {
RefreshQueue.getInstance().refresh(true, true, new Runnable() {
public void run() {
myDirtyScopeManager.filesDirty(null, parents);
}
}, parents);
}
}
示例12: resolveAllBranchPoints
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
@NotNull
private Set<Pair<VirtualFile, SvnBranchConfigurationNew>> resolveAllBranchPoints() {
final LocalFileSystem lfs = LocalFileSystem.getInstance();
final UrlSerializationHelper helper = new UrlSerializationHelper(SvnVcs.getInstance(myProject));
final Set<Pair<VirtualFile, SvnBranchConfigurationNew>> branchPointsToLoad = ContainerUtil.newHashSet();
for (Map.Entry<String, SvnBranchConfiguration> entry : myConfigurationBean.myConfigurationMap.entrySet()) {
final SvnBranchConfiguration configuration = entry.getValue();
final VirtualFile root = lfs.refreshAndFindFileByIoFile(new File(entry.getKey()));
if (root == null) {
LOG.info("root not found: " + entry.getKey());
continue;
}
final SvnBranchConfiguration configToConvert;
if ((! myConfigurationBean.mySupportsUserInfoFilter) || configuration.isUserinfoInUrl()) {
configToConvert = helper.afterDeserialization(entry.getKey(), configuration);
} else {
configToConvert = configuration;
}
final SvnBranchConfigurationNew newConfig = new SvnBranchConfigurationNew();
newConfig.setTrunkUrl(configToConvert.getTrunkUrl());
newConfig.setUserinfoInUrl(configToConvert.isUserinfoInUrl());
for (String branchUrl : configToConvert.getBranchUrls()) {
List<SvnBranchItem> stored = getStored(branchUrl);
if (stored != null && ! stored.isEmpty()) {
newConfig.addBranches(branchUrl, new InfoStorage<List<SvnBranchItem>>(stored, InfoReliability.setByUser));
} else {
branchPointsToLoad.add(Pair.create(root, newConfig));
newConfig.addBranches(branchUrl, new InfoStorage<List<SvnBranchItem>>(new ArrayList<SvnBranchItem>(), InfoReliability.empty));
}
}
myBunch.updateForRoot(root, new InfoStorage<SvnBranchConfigurationNew>(newConfig, InfoReliability.setByUser), false);
}
return branchPointsToLoad;
}
示例13: simpleExternalStatusImpl
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
private void simpleExternalStatusImpl() {
final File sourceFile = new File(myWorkingCopyDir.getPath(), "source" + File.separator + "s1.txt");
final File externalFile = new File(myWorkingCopyDir.getPath(), "source" + File.separator + "external" + File.separator + "t12.txt");
final LocalFileSystem lfs = LocalFileSystem.getInstance();
final VirtualFile vf1 = lfs.refreshAndFindFileByIoFile(sourceFile);
final VirtualFile vf2 = lfs.refreshAndFindFileByIoFile(externalFile);
Assert.assertNotNull(vf1);
Assert.assertNotNull(vf2);
VcsTestUtil.editFileInCommand(myProject, vf1, "test externals 123" + System.currentTimeMillis());
VcsTestUtil.editFileInCommand(myProject, vf2, "test externals 123" + System.currentTimeMillis());
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
clManager.ensureUpToDate(false);
final Change change1 = clManager.getChange(vf1);
final Change change2 = clManager.getChange(vf2);
Assert.assertNotNull(change1);
Assert.assertNotNull(change2);
Assert.assertNotNull(change1.getBeforeRevision());
Assert.assertNotNull(change2.getBeforeRevision());
Assert.assertNotNull(change1.getAfterRevision());
Assert.assertNotNull(change2.getAfterRevision());
}
示例14: testSimpleExternalsStatus
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
@Test
public void testSimpleExternalsStatus() throws Exception {
prepareExternal();
final File sourceFile = new File(myWorkingCopyDir.getPath(), "source" + File.separator + "s1.txt");
final File externalFile = new File(myWorkingCopyDir.getPath(), "source" + File.separator + "external" + File.separator + "t12.txt");
final LocalFileSystem lfs = LocalFileSystem.getInstance();
final VirtualFile vf1 = lfs.refreshAndFindFileByIoFile(sourceFile);
final VirtualFile vf2 = lfs.refreshAndFindFileByIoFile(externalFile);
Assert.assertNotNull(vf1);
Assert.assertNotNull(vf2);
VcsTestUtil.editFileInCommand(myProject, vf1, "test externals 123" + System.currentTimeMillis());
VcsTestUtil.editFileInCommand(myProject, vf2, "test externals 123" + System.currentTimeMillis());
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
clManager.ensureUpToDate(false);
final Change change1 = clManager.getChange(vf1);
final Change change2 = clManager.getChange(vf2);
Assert.assertNotNull(change1);
Assert.assertNotNull(change2);
Assert.assertNotNull(change1.getBeforeRevision());
Assert.assertNotNull(change2.getBeforeRevision());
Assert.assertNotNull(change1.getAfterRevision());
Assert.assertNotNull(change2.getAfterRevision());
}
示例15: findFileByIoFileRefreshIfNeeded
import com.intellij.openapi.vfs.LocalFileSystem; //导入方法依赖的package包/类
/**
* Like {@link com.intellij.openapi.vfs.VfsUtil#findFileByIoFile} with refresh set to true.
*
* <p>Note: there are restrictions on the calling context. See comments for
* refreshAndFindFileByIoFile.
*/
@Nullable
static VirtualFile findFileByIoFileRefreshIfNeeded(File file) {
LocalFileSystem fileSystem = getInstance().getSystem();
VirtualFile virtualFile = fileSystem.findFileByIoFile(file);
if (virtualFile == null || !virtualFile.isValid()) {
virtualFile = fileSystem.refreshAndFindFileByIoFile(file);
}
return virtualFile;
}