本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFileManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualFileManager.getInstance方法的具体用法?Java VirtualFileManager.getInstance怎么用?Java VirtualFileManager.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.VirtualFileManager
的用法示例。
在下文中一共展示了VirtualFileManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: fireEventsInWriteAction
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
protected void fireEventsInWriteAction() {
final VirtualFileManagerEx manager = (VirtualFileManagerEx)VirtualFileManager.getInstance();
manager.fireBeforeRefreshStart(myIsAsync);
try {
while (!myWorkQueue.isEmpty() || !myEvents.isEmpty()) {
PersistentFS.getInstance().processEvents(mergeEventsAndReset());
scan();
}
}
finally {
try {
manager.fireAfterRefreshFinish(myIsAsync);
}
finally {
if (myFinishRunnable != null) {
myFinishRunnable.run();
}
}
}
}
示例3: loadState
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
@Override
public void loadState(Element state) {
final VirtualFileManager vfManager = VirtualFileManager.getInstance();
for (Object child : state.getChildren(FILE_ELEMENT)) {
if (child instanceof Element) {
final Element fileElement = (Element)child;
final Attribute filePathAttr = fileElement.getAttribute(PATH_ATTR);
if (filePathAttr != null) {
final String filePath = filePathAttr.getValue();
VirtualFile vf = vfManager.findFileByUrl(filePath);
if (vf != null) {
myFiles.add(vf);
}
}
}
}
}
示例4: createPath
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
@Override
public Object[] createPath(final Project project) {
if (moduleName != null) {
final Module module = ApplicationManager.getApplication().runReadAction(new Computable<Module>() {
@Nullable
@Override
public Module compute() {
return ModuleManager.getInstance(project).findModuleByName(moduleName);
}
});
if (module == null) return null;
}
final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance();
final VirtualFile file = virtualFileManager.findFileByUrl(url);
if (file == null) return null;
final PsiDirectory directory = ApplicationManager.getApplication().runReadAction(new Computable<PsiDirectory>() {
@Nullable
@Override
public PsiDirectory compute() {
return PsiManager.getInstance(project).findDirectory(file);
}
});
if (directory == null) return null;
return new Object[]{directory};
}
示例5: 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);
}
示例6: getGoToDefinitionCallback
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
@Override
public ActionListener getGoToDefinitionCallback() {
EditedStyleItem item = (EditedStyleItem)getValueAt(1);
if (getCellClass(1) == ThemeEditorStyle.class) {
myGoToDefinitionAction.setItem(item);
return myGoToDefinitionAction;
}
VirtualFileManager manager = VirtualFileManager.getInstance();
ResourceValue resourceValue = myResourceResolver.resolveResValue(item.getItemResourceValue());
final File file = new File(resourceValue.getValue());
final VirtualFile virtualFile = file.exists() ? manager.findFileByUrl("file://" + file.getAbsolutePath()) : null;
if (virtualFile != null) {
myOpenFileAction.setFile(virtualFile);
return myOpenFileAction;
}
return null;
}
示例7: removeNonExistentFiles
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
public ResourceBundleManagerState removeNonExistentFiles() {
final ResourceBundleManagerState newState = new ResourceBundleManagerState();
final VirtualFileManager virtualFileManager = VirtualFileManager.getInstance();
for (final String dissociatedFileUrl : myDissociatedFiles) {
if (virtualFileManager.findFileByUrl(dissociatedFileUrl) != null) {
newState.myDissociatedFiles.add(dissociatedFileUrl);
}
}
for (CustomResourceBundleState customResourceBundle : myCustomResourceBundles) {
final CustomResourceBundleState updatedCustomResourceBundle = customResourceBundle.removeNonExistentFiles(virtualFileManager);
if (updatedCustomResourceBundle != null) {
newState.myCustomResourceBundles.add(updatedCustomResourceBundle);
}
}
return newState;
}
示例8: loadState
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
@Override
public void loadState(State state) {
synchronized (myStatus) {
myStatus.clear();
if (ContainerUtil.isEmpty(state.entries)) {
return;
}
final VirtualFileManager fileManager = VirtualFileManager.getInstance();
for (Entry entry : state.entries) {
if (entry.url == null || entry.status == null) continue;
final VirtualFile file = fileManager.findFileByUrl(entry.url);
if (file != null) {
myStatus.put(file, entry);
}
}
}
}
示例9: isUpToDate
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
public boolean isUpToDate(@NotNull VirtualFile sourceFile) {
if (sourceFile.getTimeStamp() != mySourceTimestamp) {
return false;
}
VirtualFileManager manager = VirtualFileManager.getInstance();
for (Map.Entry<String, Long> entry : myDependencies.entrySet()) {
final VirtualFile file = manager.findFileByUrl(entry.getKey());
if (file == null || file.getTimeStamp() != entry.getValue()) {
return false;
}
}
return true;
}
示例10: initHistory
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
protected void initHistory() {
ChangeListStorage storage;
try {
storage = new ChangeListStorageImpl(getStorageDir());
}
catch (Throwable e) {
LocalHistoryLog.LOG.warn("cannot create storage, in-memory implementation will be used", e);
storage = new InMemoryChangeListStorage();
}
myChangeList = new ChangeList(storage);
myVcs = new LocalHistoryFacade(myChangeList);
myGateway = new IdeaGateway();
myEventDispatcher = new LocalHistoryEventDispatcher(myVcs, myGateway);
CommandProcessor.getInstance().addCommandListener(myEventDispatcher);
VirtualFileManager fm = VirtualFileManager.getInstance();
fm.addVirtualFileListener(myEventDispatcher);
fm.addVirtualFileManagerListener(myEventDispatcher);
if (ApplicationManager.getApplication().isInternal() && !ApplicationManager.getApplication().isUnitTestMode()) {
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
@Override
public void run() {
validateStorage();
}
});
}
}
示例11: setUp
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
myHistory = new IdeDocumentHistoryImpl(getProject(), EditorFactory.getInstance(), new EditorManager(), VirtualFileManager.getInstance(), CommandProcessor.getInstance(), new Mock.MyToolWindowManager()) {
@Override
protected Pair<FileEditor,FileEditorProvider> getSelectedEditor() {
return Pair.create ((FileEditor)mySelectedEditor, myProvider);
}
@Override
protected void executeCommand(Runnable runnable, String name, Object groupId) {
myHistory.onCommandStarted();
runnable.run();
myHistory.onSelectionChanged();
myHistory.onCommandFinished(groupId);
}
};
mySelectedEditor = new Mock.MyFileEditor() {
@Override
@NotNull
public FileEditorState getState(@NotNull FileEditorStateLevel level) {
return myEditorState;
}
@Override
public void setState(@NotNull FileEditorState state) {
myEditorState = state;
}
};
mySelectedFile = new Mock.MyVirtualFile();
myEditorState = new MyState(false, "start");
myProvider = new Mock.MyFileEditorProvider() {
@Override
@NotNull
public String getEditorTypeId() {
return "EditorType";
}
};
}
示例12: setUp
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
myHistory = new IdeDocumentHistoryImpl(getProject(), EditorFactory.getInstance(),
myManager, VirtualFileManager.getInstance(), CommandProcessor.getInstance(), ToolWindowManager
.getInstance(getProject()));
myHistory.projectOpened();
}
示例13: CommonContentEntriesEditor
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
public CommonContentEntriesEditor(String moduleName, final ModuleConfigurationState state, JpsModuleSourceRootType<?>... rootTypes) {
super(state);
myState = state;
myModuleName = moduleName;
myModulesProvider = state.getModulesProvider();
for (JpsModuleSourceRootType<?> type : rootTypes) {
ContainerUtil.addIfNotNull(myEditHandlers, ModuleSourceRootEditHandler.getEditHandler(type));
}
final VirtualFileManagerAdapter fileManagerListener = new VirtualFileManagerAdapter() {
@Override
public void afterRefreshFinish(boolean asynchronous) {
if (state.getProject().isDisposed()) {
return;
}
final Module module = getModule();
if (module == null || module.isDisposed()) return;
for (final ContentEntryEditor editor : myEntryToEditorMap.values()) {
editor.update();
}
}
};
final VirtualFileManager fileManager = VirtualFileManager.getInstance();
fileManager.addVirtualFileManagerListener(fileManagerListener);
registerDisposable(new Disposable() {
@Override
public void dispose() {
fileManager.removeVirtualFileManagerListener(fileManagerListener);
}
});
}
示例14: convertToFiles
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
public static List<VirtualFile> convertToFiles(Collection<SimpleClasspathElement> cpeList)
{
VirtualFileManager fileManager = VirtualFileManager.getInstance();
List<VirtualFile> files = new ArrayList<VirtualFile>();
for (SimpleClasspathElement cpe : cpeList) {
for (String fileUrl : cpe.getClassesRootUrls()) {
VirtualFile file = fileManager.findFileByUrl(fileUrl);
if (file != null) {
files.add(file);
}
}
}
return files;
}
示例15: createClassLoader
import com.intellij.openapi.vfs.VirtualFileManager; //导入方法依赖的package包/类
private static ClassLoader createClassLoader(final String runClasspath, final String moduleName) {
final ArrayList<URL> urls = new ArrayList<URL>();
final VirtualFileManager manager = VirtualFileManager.getInstance();
final JarFileSystemImpl fileSystem = (JarFileSystemImpl)JarFileSystem.getInstance();
final StringTokenizer tokenizer = new StringTokenizer(runClasspath, File.pathSeparator);
while (tokenizer.hasMoreTokens()) {
final String s = tokenizer.nextToken();
try {
VirtualFile vFile = manager.findFileByUrl(VfsUtil.pathToUrl(s));
final File realFile = fileSystem.getMirroredFile(vFile);
urls.add(realFile != null ? realFile.toURI().toURL() : new File(s).toURI().toURL());
}
catch (Exception e) {
// ignore ?
}
}
try {
urls.add(new File(PathUtil.getJarPathForClass(Spacer.class)).toURI().toURL());
}
catch (MalformedURLException ignored) {
// ignore
}
final URL[] _urls = urls.toArray(new URL[urls.size()]);
return new DesignTimeClassLoader(Arrays.asList(_urls), LoaderFactory.class.getClassLoader(), moduleName);
}