Package com.intellij.openapi.vfs

Examples of com.intellij.openapi.vfs.VirtualFile


        final Artifact[] artifacts = getPomClassPathArtifacts(pProject, pPomUrl);
        final Set<VirtualFile> files = new HashSet<VirtualFile>(artifacts.length);

        for (Artifact artifact : artifacts) {
            final VirtualFile file = repoMgr.findFile(pPomUrl, artifact);
            if (file != null && file.isValid() && !file.isDirectory() && FileUtils.exists(file))
                files.add(file);
        }

        return files.toArray(new VirtualFile[files.size()]);
    }
View Full Code Here


        boolean recreate = true;
        PsiProject psi = get(KEY, pPomUrl);

        if (psi != null) {
            final XmlFile xmlFile = psi.getXmlFile();
            final VirtualFile psiFile = xmlFile.getVirtualFile();
            if (psiFile != null) {
                final String psiUrl = psiFile.getUrl();
                recreate = !pPomUrl.equals(psiUrl);
            }
        }

        if (recreate) {
            final VirtualFile file = getFile(pPomUrl);
            if (file == null)
                return null;

            final XmlFile xmlFile = PsiUtils.findXmlFile(project, file);
            if (xmlFile == null)
View Full Code Here

     * @return list of plugins found in the maven installation
     */
    public PluginGoalContainer[] getPlugins() {
        synchronized (this) {
            boolean reload = true;
            final VirtualFile cacheFile = getPluginsCacheFile();
            if (pluginsCacheFile == cacheFile)
                reload = false;
            else if (pluginsCacheFile != null && pluginsCacheFile.equals(cacheFile))
                reload = false;

View Full Code Here

                    prg.setFraction(1);
                }
                return new PluginGoalContainer[0];
            }

            final VirtualFile pluginsDir = pPluginsCacheFile.getParent();
            if (pluginsDir == null || !pluginsDir.isValid() || !FileUtils.exists(pluginsDir) || !pluginsDir.isDirectory()) {
                if (prg != null) {
                    prg.setText("No available plugins found.");
                    prg.setFraction(1);
                }
                return new PluginGoalContainer[0];
            }

            final Properties props = new Properties();
            final byte[] data = pPluginsCacheFile.contentsToByteArray();
            final ByteArrayInputStream stream = new ByteArrayInputStream(data);
            props.load(stream);

            if (prg != null) {
                prg.setText("Found " + props.size() + " plugins.");
                prg.setIndeterminate(false);
                prg.setFraction(0);
            }

            final Set<PluginGoalContainer> plugins = new HashSet<PluginGoalContainer>(30);
            final Set<Map.Entry<Object, Object>> entries = props.entrySet();

            final int pluginCount = entries.size();

            for (Map.Entry<Object, Object> entry : entries) {
                final String pluginName = entry.getValue().toString();
                final String artifactId = entry.getKey().toString();

                if (prg != null) {
                    prg.setText("Loading plugin '" + pluginName + "'");
                    prg.setFraction((double) counter / (double) pluginCount);
                    counter++;
                }

                final VirtualFile pluginDir = pluginsDir.findChild(artifactId);
                if (pluginDir == null || !pluginDir.isValid() || !FileUtils.exists(pluginDir) || !pluginDir.isDirectory()) {
                    if (prg != null)
                        prg.setText("Could not load plugin '" + pluginName + "'");
                    continue;
                }
View Full Code Here

        final DefaultPluginGoalContainer plugin = new DefaultPluginGoalContainer();

        //
        //parse plugin POM
        //
        final VirtualFile pluginPom = pPluginDir.findChild("project.xml");
        if (pluginPom != null && pluginPom.isValid() && FileUtils.exists(pluginPom))
            plugin.setPomFile(pluginPom);
        else
            return null;

        final XmlFile pomPsi = PsiUtils.findXmlFile(project, pluginPom);
        if (pomPsi == null)
            return null;

        plugin.setId(new XmlTagPath(pomPsi, POM_ID_XPATH).getStringValue());
        plugin.setGroupId(new XmlTagPath(pomPsi, POM_GROUP_ID_XPATH).getStringValue());
        plugin.setArtifactId(new XmlTagPath(pomPsi, POM_ARTIFACT_ID_XPATH).getStringValue());
        plugin.setVersion(new XmlTagPath(pomPsi, POM_VERSION_XPATH).getStringValue());
        plugin.setName(new XmlTagPath(pomPsi, POM_NAME_XPATH).getStringValue());
        plugin.setDescription(new XmlTagPath(pomPsi, POM_DESC_XPATH).getStringValue());

        //
        //parse plugin Jelly script
        //
        final VirtualFile jellyFile = pPluginDir.findChild("plugin.jelly");
        if (jellyFile != null && jellyFile.isValid() && FileUtils.exists(jellyFile))
            plugin.setScriptFile(jellyFile);
        else
            return null;

        final XmlFile jellyPsi = PsiUtils.findXmlFile(project, jellyFile);
View Full Code Here

        if (referenceDir == null) {
            super.onFileChoosen(pChosenFile);
            return;
        }

        VirtualFile parent = referenceDir;
        int levels = 0;
        while (parent != null && !VfsUtil.isAncestor(parent, pChosenFile, false)) {
            levels++;
            parent = parent.getParent();
        }

        final StringBuilder buf = new StringBuilder();
        buf.append(StringUtils.repeat("../", levels));
        buf.append(VfsUtil.getRelativePath(pChosenFile, parent, '/'));
View Full Code Here

    public PomRepoManager(final Project pProject) {
        super(pProject);
    }

    public VirtualFile findFile(final String pPomUrl, final Artifact pArtifact) {
        final VirtualFile localRepo = getLocalRepositoryDirectory(pPomUrl);
        if (localRepo == null)
            return null;

        final FileFinder finder = new FileFinder(localRepo, pArtifact);
        IDEUtils.runCommand(project, finder);
View Full Code Here

        if (localRepo == null)
            return false;

        final URI localRepoRootUri = localRepo.getRootURI();
        try {
            final VirtualFile localRepoFile = VfsUtil.findFileByURL(localRepoRootUri.toURL());
            final FileFinder finder = new FileFinder(localRepoFile, pArtifact);
            IDEUtils.runCommand(project, finder);
            return finder.isFound();
        }
        catch (MalformedURLException e) {
View Full Code Here

            //
            //calculate the dependency's location in the local repository
            //
            final PomRepoManager repoMgr = PomRepoManager.getInstance(project);
            final VirtualFile file = repoMgr.findFile(problem.getPomUrl(), artifact);
            if (file == null || !file.isValid() || !FileUtils.exists(file)) {
                final String msg = RES.get("dep.missing.problem.desc", artifact);
                UIUtils.showError(project, msg);
                return;
            }
View Full Code Here

        //check maven cmdline options
        if (!StringUtils.equals(mavenMgr.getMavenOptions(), ui.mavenOptionsField.getText()))
            return true;

        //check maven home
        final VirtualFile mavenHome = mavenMgr.getMavenHome();
        final VirtualFile selectedHome;
        final String selectedHomeValue = ui.mavenHomeField.getText();
        if (selectedHomeValue == null || selectedHomeValue.trim().length() == 0)
            selectedHome = null;
        else {
            final String selectedPath = selectedHomeValue.replace(File.separatorChar, '/');
View Full Code Here

TOP

Related Classes of com.intellij.openapi.vfs.VirtualFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.