本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFileManager类的典型用法代码示例。如果您正苦于以下问题:Java VirtualFileManager类的具体用法?Java VirtualFileManager怎么用?Java VirtualFileManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VirtualFileManager类属于com.intellij.openapi.vfs包,在下文中一共展示了VirtualFileManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReaderByUrl
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
@Nullable
public static Reader getReaderByUrl(final String surl, final HttpConfigurable httpConfigurable, final ProgressIndicator pi) throws IOException {
if (surl.startsWith(JAR_PROTOCOL)) {
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(BrowserUtil.getDocURL(surl));
if (file == null) {
return null;
}
return new StringReader(VfsUtil.loadText(file));
}
URL url = BrowserUtil.getURL(surl);
if (url == null) {
return null;
}
httpConfigurable.prepareURL(url.toString());
final URLConnection urlConnection = url.openConnection();
final String contentEncoding = urlConnection.getContentEncoding();
final InputStream inputStream =
pi != null ? UrlConnectionUtil.getConnectionInputStreamWithException(urlConnection, pi) : urlConnection.getInputStream();
//noinspection IOResourceOpenedButNotSafelyClosed
return contentEncoding != null ? new InputStreamReader(inputStream, contentEncoding) : new InputStreamReader(inputStream);
}
示例2: actionPerformed
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
public void actionPerformed(AnActionEvent e) {
VcsContext context = CvsContextWrapper.createCachedInstance(e);
final VirtualFile[] selectedFiles = context.getSelectedFiles();
ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
public void run() {
ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
for (int i = 0; i < selectedFiles.length; i++) {
File file = CvsVfsUtil.getFileFor(selectedFiles[i]);
if (progressIndicator != null){
progressIndicator.setFraction((double)i/(double)selectedFiles.length);
progressIndicator.setText(file.getAbsolutePath());
}
CvsUtil.removeEntryFor(file);
}
}
}, CvsBundle.message("operation.name.undo.add"), true, context.getProject());
VirtualFileManager.getInstance().asyncRefresh(null);
}
示例3: createXLineBreakpoint
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
private <B extends XBreakpoint<?>> XLineBreakpoint createXLineBreakpoint(Class<? extends XBreakpointType<B, ?>> typeCls,
Element breakpointNode) throws InvalidDataException {
final String url = breakpointNode.getAttributeValue("url");
VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url);
if (vFile == null) {
throw new InvalidDataException(DebuggerBundle.message("error.breakpoint.file.not.found", url));
}
final Document doc = FileDocumentManager.getInstance().getDocument(vFile);
if (doc == null) {
throw new InvalidDataException(DebuggerBundle.message("error.cannot.load.breakpoint.file", url));
}
final int line;
try {
//noinspection HardCodedStringLiteral
line = Integer.parseInt(breakpointNode.getAttributeValue("line"));
}
catch (Exception e) {
throw new InvalidDataException("Line number is invalid for breakpoint");
}
return addXLineBreakpoint(typeCls, doc, line);
}
示例4: restoreSources
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
private void restoreSources() {
Runnable runnable = new Runnable() {
@Override
public void run() {
try {
FileUtil.copyDir(new File(JavaTestUtil.getJavaTestDataPath() + "/psi/arrayIndexOutOfBounds/src"),
VfsUtilCore.virtualToIoFile(myProjectRoot));
}
catch (IOException e) {
LOG.error(e);
}
VirtualFileManager.getInstance().syncRefresh();
}
};
CommandProcessor.getInstance().executeCommand(myProject, runnable, "", null);
}
示例5: deleteNewPackage
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
private void deleteNewPackage() {
Runnable runnable = new Runnable() {
@Override
public void run() {
final PsiPackage aPackage = JavaPsiFacade.getInstance(myPsiManager.getProject()).findPackage("anotherBla");
assertNotNull("Package anotherBla not found", aPackage);
WriteCommandAction.runWriteCommandAction(null, new Runnable() {
@Override
public void run() {
aPackage.getDirectories()[0].delete();
}
});
VirtualFileManager.getInstance().syncRefresh();
}
};
CommandProcessor.getInstance().executeCommand(myProject, runnable, "", null);
}
示例6: getNotExcludedRoots
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
private Set<VirtualFile> getNotExcludedRoots() {
Set<VirtualFile> roots = new LinkedHashSet<VirtualFile>();
String[] excludedRootUrls = getLibraryEditor().getExcludedRootUrls();
Set<VirtualFile> excludedRoots = new HashSet<VirtualFile>();
for (String url : excludedRootUrls) {
ContainerUtil.addIfNotNull(excludedRoots, VirtualFileManager.getInstance().findFileByUrl(url));
}
for (PersistentOrderRootType type : OrderRootType.getAllPersistentTypes()) {
VirtualFile[] files = getLibraryEditor().getFiles(type);
for (VirtualFile file : files) {
if (!VfsUtilCore.isUnder(file, excludedRoots)) {
roots.add(PathUtil.getLocalFile(file));
}
}
}
return roots;
}
示例7: getOutputPaths
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
public static String[] getOutputPaths(Module[] modules) {
final Set<String> outputPaths = new OrderedSet<String>();
for (Module module : modules) {
final CompilerModuleExtension compilerModuleExtension = !module.isDisposed()? CompilerModuleExtension.getInstance(module) : null;
if (compilerModuleExtension == null) {
continue;
}
String outputPathUrl = compilerModuleExtension.getCompilerOutputUrl();
if (outputPathUrl != null) {
outputPaths.add(VirtualFileManager.extractPath(outputPathUrl).replace('/', File.separatorChar));
}
String outputPathForTestsUrl = compilerModuleExtension.getCompilerOutputUrlForTests();
if (outputPathForTestsUrl != null) {
outputPaths.add(VirtualFileManager.extractPath(outputPathForTestsUrl).replace('/', File.separatorChar));
}
}
return ArrayUtil.toStringArray(outputPaths);
}
示例8: getAnnotationProcessorsGenerationPath
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
@Nullable
public static String getAnnotationProcessorsGenerationPath(Module module) {
final AnnotationProcessingConfiguration config = CompilerConfiguration.getInstance(module.getProject()).getAnnotationProcessingConfiguration(module);
final String sourceDirName = config.getGeneratedSourcesDirectoryName(false);
if (config.isOutputRelativeToContentRoot()) {
final String[] roots = ModuleRootManager.getInstance(module).getContentRootUrls();
if (roots.length == 0) {
return null;
}
if (roots.length > 1) {
Arrays.sort(roots, URLS_COMPARATOR);
}
return StringUtil.isEmpty(sourceDirName)? VirtualFileManager.extractPath(roots[0]): VirtualFileManager.extractPath(roots[0]) + "/" + sourceDirName;
}
final String path = getModuleOutputPath(module, false);
if (path == null) {
return null;
}
return StringUtil.isEmpty(sourceDirName)? path : path + "/" + sourceDirName;
}
示例9: removeNonExistentFiles
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
@Nullable
public CustomResourceBundleState removeNonExistentFiles(final VirtualFileManager virtualFileManager) {
final List<String> existentFiles = ContainerUtil.filter(myFileUrls, new Condition<String>() {
@Override
public boolean value(String url) {
return virtualFileManager.findFileByUrl(url) != null;
}
});
if (existentFiles.isEmpty()) {
return null;
}
final CustomResourceBundleState customResourceBundleState = new CustomResourceBundleState();
customResourceBundleState.myFileUrls.addAll(existentFiles);
customResourceBundleState.myBaseName = myBaseName;
return customResourceBundleState;
}
示例10: saveCredentials
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
public void saveCredentials() {
if (myGetPassword == null) return;
// if checkbox is selected, save on disk. Otherwise in memory. Don't read password safe settings.
final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance();
final String url = VirtualFileManager.extractPath(myGetPassword.getURL());
final String key = keyForUrlAndLogin(url, myGetPassword.getUserName());
try {
if (myGetPassword.isRememberPassword()) {
PasswordSafe.getInstance().storePassword(myProject, HgCommandAuthenticator.class, key, myGetPassword.getPassword());
}
else if (passwordSafe.getSettings().getProviderType() != PasswordSafeSettings.ProviderType.DO_NOT_STORE) {
passwordSafe.getMemoryProvider().storePassword(myProject, HgCommandAuthenticator.class, key, myGetPassword.getPassword());
}
final HgVcs vcs = HgVcs.getInstance(myProject);
if (vcs != null) {
vcs.getGlobalSettings().addRememberedUrl(url, myGetPassword.getUserName());
}
}
catch (PasswordSafeException e) {
LOG.info("Couldn't store the password for key [" + key + "]", e);
}
}
示例11: attachJdkAnnotations
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
public static void attachJdkAnnotations(@NotNull SdkModificator modificator) {
String homePath = FileUtil.toSystemIndependentName(PathManager.getHomePath());
VirtualFileManager fileManager = VirtualFileManager.getInstance();
// release build?
String releaseLocation = homePath + "/plugins/android/lib/androidAnnotations.jar";
VirtualFile root = fileManager.findFileByUrl("jar://" + releaseLocation + "!/");
for (String relativePath : DEVELOPMENT_ANNOTATIONS_PATHS) {
if (root != null) break;
String developmentLocation = homePath + relativePath;
root = LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(developmentLocation));
}
if (root == null) {
// error message tailored for release build file layout
LOG.error("jdk annotations not found in: " + releaseLocation);
return;
}
OrderRootType annoType = AnnotationOrderRootType.getInstance();
modificator.removeRoot(root, annoType);
modificator.addRoot(root, annoType);
}
示例12: disposeComponent
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
@Override
public void disposeComponent() {
if (!isInitialized.getAndSet(false)) return;
long period = Registry.intValue("localHistory.daysToKeep") * 1000L * 60L * 60L * 24L;
VirtualFileManager fm = VirtualFileManager.getInstance();
fm.removeVirtualFileListener(myEventDispatcher);
fm.removeVirtualFileManagerListener(myEventDispatcher);
CommandProcessor.getInstance().removeCommandListener(myEventDispatcher);
validateStorage();
LocalHistoryLog.LOG.debug("Purging local history...");
myChangeList.purgeObsolete(period);
validateStorage();
myChangeList.close();
LocalHistoryLog.LOG.debug("Local history storage successfully closed.");
ShutDownTracker.getInstance().unregisterShutdownTask(myShutdownTask);
}
示例13: getReference
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
@Nullable
@Override
public RefEntity getReference(final String type, final String fqName) {
for (RefManagerExtension extension : myExtensions.values()) {
final RefEntity refEntity = extension.getReference(type, fqName);
if (refEntity != null) return refEntity;
}
if (SmartRefElementPointer.FILE.equals(type)) {
return RefFileImpl.fileFromExternalName(this, fqName);
}
if (SmartRefElementPointer.MODULE.equals(type)) {
return RefModuleImpl.moduleFromName(this, fqName);
}
if (SmartRefElementPointer.PROJECT.equals(type)) {
return getRefProject();
}
if (SmartRefElementPointer.DIR.equals(type)) {
String url = VfsUtilCore.pathToUrl(PathMacroManager.getInstance(getProject()).expandPath(fqName));
VirtualFile vFile = VirtualFileManager.getInstance().findFileByUrl(url);
if (vFile != null) {
final PsiDirectory dir = PsiManager.getInstance(getProject()).findDirectory(vFile);
return getReference(dir);
}
}
return null;
}
示例14: reparseFiles
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
/**
* Forces a reparse of the specified collection of files.
*
* @param files the files to reparse.
*/
public static void reparseFiles(@NotNull final Collection<VirtualFile> files) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
// files must be processed under one write action to prevent firing event for invalid files.
final Set<VFilePropertyChangeEvent> events = new THashSet<VFilePropertyChangeEvent>();
for (VirtualFile file : files) {
saveOrReload(file, events);
}
BulkFileListener publisher = ApplicationManager.getApplication().getMessageBus().syncPublisher(VirtualFileManager.VFS_CHANGES);
List<VFileEvent> eventList = new ArrayList<VFileEvent>(events);
publisher.before(eventList);
publisher.after(eventList);
}
});
}
示例15: getLocation
import com.intellij.openapi.vfs.VirtualFileManager; //导入依赖的package包/类
protected Location getLocation(@NotNull Project project, @NotNull GlobalSearchScope searchScope, String locationUrl) {
if (locationUrl != null && myLocator != null) {
String protocolId = VirtualFileManager.extractProtocol(locationUrl);
if (protocolId != null) {
String path = VirtualFileManager.extractPath(locationUrl);
if (!DumbService.isDumb(project) || DumbService.isDumbAware(myLocator)) {
List<Location> locations = myLocator.getLocation(protocolId, path, project, searchScope);
if (!locations.isEmpty()) {
return locations.get(0);
}
}
}
}
return null;
}