Search in sources :

Example 1 with VirtualFileManager

use of com.intellij.openapi.vfs.VirtualFileManager in project intellij-community by JetBrains.

the class ResourceBundleManagerState method removeNonExistentFiles.

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;
}
Also used : VirtualFileManager(com.intellij.openapi.vfs.VirtualFileManager)

Example 2 with VirtualFileManager

use of com.intellij.openapi.vfs.VirtualFileManager in project intellij-community by JetBrains.

the class LoaderFactory method createClassLoader.

private static ClassLoader createClassLoader(final String runClasspath, final String moduleName) {
    final ArrayList<URL> urls = new ArrayList<>();
    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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MalformedURLException(java.net.MalformedURLException) VirtualFileManager(com.intellij.openapi.vfs.VirtualFileManager) JarFileSystemImpl(com.intellij.openapi.vfs.impl.jar.JarFileSystemImpl) URL(java.net.URL) MalformedURLException(java.net.MalformedURLException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 3 with VirtualFileManager

use of com.intellij.openapi.vfs.VirtualFileManager in project intellij-community by JetBrains.

the class MavenProjectsManager method importProjects.

public List<Module> importProjects(final IdeModifiableModelsProvider modelsProvider) {
    final Map<MavenProject, MavenProjectChanges> projectsToImportWithChanges;
    final boolean importModuleGroupsRequired;
    synchronized (myImportingDataLock) {
        projectsToImportWithChanges = new LinkedHashMap<>(myProjectsToImport);
        myProjectsToImport.clear();
        importModuleGroupsRequired = myImportModuleGroupsRequired;
        myImportModuleGroupsRequired = false;
    }
    final Ref<MavenProjectImporter> importer = new Ref<>();
    final Ref<List<MavenProjectsProcessorTask>> postTasks = new Ref<>();
    final Runnable r = () -> {
        MavenProjectImporter projectImporter = new MavenProjectImporter(myProject, myProjectsTree, getFileToModuleMapping(new MavenModelsProvider() {

            @Override
            public Module[] getModules() {
                return modelsProvider.getModules();
            }

            @Override
            public VirtualFile[] getContentRoots(Module module) {
                return modelsProvider.getContentRoots(module);
            }
        }), projectsToImportWithChanges, importModuleGroupsRequired, modelsProvider, getImportingSettings());
        importer.set(projectImporter);
        postTasks.set(projectImporter.importProject());
    };
    // called from wizard or ui
    if (ApplicationManager.getApplication().isDispatchThread()) {
        r.run();
    } else {
        MavenUtil.runInBackground(myProject, ProjectBundle.message("maven.project.importing"), false, new MavenTask() {

            @Override
            public void run(MavenProgressIndicator indicator) throws MavenProcessCanceledException {
                r.run();
            }
        }).waitFor();
    }
    VirtualFileManager fm = VirtualFileManager.getInstance();
    if (isNormalProject()) {
        fm.asyncRefresh(null);
    } else {
        fm.syncRefresh();
    }
    if (postTasks.get() != null) /*may be null if importing is cancelled*/
    {
        schedulePostImportTasks(postTasks.get());
    }
    // do not block user too often
    myImportingQueue.restartTimer();
    MavenProjectImporter projectImporter = importer.get();
    if (projectImporter == null)
        return Collections.emptyList();
    return projectImporter.getCreatedModules();
}
Also used : VirtualFileManager(com.intellij.openapi.vfs.VirtualFileManager) MavenProjectImporter(org.jetbrains.idea.maven.importing.MavenProjectImporter) DumbAwareRunnable(com.intellij.openapi.project.DumbAwareRunnable) Module(com.intellij.openapi.module.Module)

Example 4 with VirtualFileManager

use of com.intellij.openapi.vfs.VirtualFileManager in project intellij-community by JetBrains.

the class LocalHistoryImpl method initHistory.

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);
    myConnection = myBus.connect();
    myConnection.subscribe(VirtualFileManager.VFS_CHANGES, myEventDispatcher);
    VirtualFileManager fm = VirtualFileManager.getInstance();
    fm.addVirtualFileManagerListener(myEventDispatcher);
}
Also used : VirtualFileManager(com.intellij.openapi.vfs.VirtualFileManager)

Example 5 with VirtualFileManager

use of com.intellij.openapi.vfs.VirtualFileManager in project intellij-community by JetBrains.

the class DirectoryUrl method createPath.

@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 };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileManager(com.intellij.openapi.vfs.VirtualFileManager) PsiDirectory(com.intellij.psi.PsiDirectory) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

VirtualFileManager (com.intellij.openapi.vfs.VirtualFileManager)19 VirtualFile (com.intellij.openapi.vfs.VirtualFile)13 File (java.io.File)4 OrderRootType (com.intellij.openapi.roots.OrderRootType)3 Element (org.jdom.Element)3 NotNull (org.jetbrains.annotations.NotNull)3 Module (com.intellij.openapi.module.Module)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 JavadocOrderRootType (com.intellij.openapi.roots.JavadocOrderRootType)2 Nullable (org.jetbrains.annotations.Nullable)2 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)1 ResourceResolver (com.android.ide.common.resources.ResourceResolver)1 AttributesTableModel (com.android.tools.idea.editors.theme.attributes.AttributesTableModel)1 ConfiguredThemeEditorStyle (com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle)1 EditedStyleItem (com.android.tools.idea.editors.theme.datamodels.EditedStyleItem)1 AndroidModel (com.android.tools.idea.model.AndroidModel)1 IProperty (com.intellij.lang.properties.IProperty)1 ResourceBundle (com.intellij.lang.properties.ResourceBundle)1 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)1 XmlPropertiesFile (com.intellij.lang.properties.xml.XmlPropertiesFile)1