Package com.intellij.openapi.vfs

Examples of com.intellij.openapi.vfs.VirtualFile


        final MavenPluginsManager plgMgr = MavenPluginsManager.getInstance(project);
        final PluginGoalContainer[] plugins = plgMgr.getPlugins();
        final Set<Report> reports = new HashSet<Report>(plugins.length);

        for (final PluginGoalContainer plugin : plugins) {
            final VirtualFile script = plugin.getScriptFile().getFile();
            if (script == null || !script.isValid() || !FileUtils.exists(script))
                continue;

            final String id;
            if (plugin.getArtifactId() != null)
                id = plugin.getArtifactId();
View Full Code Here


     * @param pName   name of the property to resolve
     *
     * @return property value, or {@code null} if it could not be found
     */
    public String getProperty(final String pPomUrl, final String pName) {
        final VirtualFile pPomFile = PomManager.getInstance(project).getFile(pPomUrl);

        //
        //check some preconfigured properties that are not present in
        //configuration files, but Maven expects them because they are
        //passed by the maven shell scripts
        //
        final MavenManager mavenMgr = MavenManager.getInstance();
        final VirtualFile mavenHome = mavenMgr.getMavenHome();
        if (pName.equals("maven.home"))
            return mavenHome == null ? null : mavenHome.getPath();

        //
        //system properties
        //
        String value = System.getProperty(pName);
        if (value != null && value.trim().length() > 0)
            return resolveProperty(pPomFile, value);

        //
        //user properties
        //
        try {
            final VirtualFile home = getUserHome();
            if (home != null && home.isValid() && home.isDirectory() && FileUtils.exists(home)) {
                final VirtualFile propsFile = home.findChild("build.properties");
                if (propsFile != null && propsFile.isValid() && !propsFile.isDirectory() && FileUtils.exists(
                        propsFile)) {
                    value = getFilePropertyValue(propsFile, pName);
                    if (value != null)
                        return resolveProperty(pPomFile, value);
                }
            }
        }
        catch (IOException e) {
            LOG.warn(e.getMessage(), e);
        }

        //
        //starting to use POM - get POM directory
        //
        if (pPomFile != null) {
            final VirtualFile dir = pPomFile.getParent();
            if (dir != null) {
                //
                //build properties
                //
                try {
                    value = getFilePropertyValue(dir, "build.properties", pName);
                    if (value != null)
                        return resolveProperty(pPomFile, value);
                }
                catch (IOException e) {
                    LOG.warn(e.getMessage(), e);
                }

                //
                //project properties
                //
                try {
                    value = getFilePropertyValue(dir, "project.properties", pName);
                    if (value != null)
                        return resolveProperty(pPomFile, value);
                }
                catch (IOException e) {
                    LOG.warn(e.getMessage(), e);
                }
            }
        }

        if (mavenHome == null || !FileUtils.exists(mavenHome) || !mavenHome.isValid() || !mavenHome.isDirectory())
            return null;
        final String baseJarUrl = "jar://" + mavenHome.getPath() + "/lib/maven.jar!/";

        //
        //maven defaults properties
        //
        try {
            final String url = baseJarUrl + "defaults.properties";
            final VirtualFile propsFile = VirtualFileManager.getInstance().findFileByUrl(url);
            if (propsFile != null) {
                value = getFilePropertyValue(propsFile, pName);
                if (value != null)
                    return resolveProperty(pPomFile, value);
            }
        }
        catch (IOException e) {
            LOG.warn(e.getMessage(), e);
        }

        //
        //maven driver properties
        //
        try {
            final String url = baseJarUrl + "driver.properties";
            final VirtualFile propsFile = VirtualFileManager.getInstance().findFileByUrl(url);
            if (propsFile != null) {
                value = getFilePropertyValue(propsFile, pName);
                if (value != null)
                    return resolveProperty(pPomFile, value);
            }
View Full Code Here

     * @param pValue  the string containing expressions
     *
     * @return expanded string with property values
     */
    public String resolveProperty(final String pPomUrl, final String pValue) {
        final VirtualFile pomFile = PomManager.getInstance(project).getFile(pPomUrl);
        return resolveProperty(pomFile, pValue);
    }
View Full Code Here

        }
    }

    public void actionPerformed(final AnActionEvent pEvent) {
        final Goal[] goals = getGoals(pEvent);
        final VirtualFile file = getPomFile(pEvent);
        final Project project = getProject(pEvent);
        if (project != null && goals != null && goals.length > 0 && file != null && file.isValid() && !file.isDirectory())
            PomPluginGoalsManager.getInstance(project).execute(file, goals);
    }
View Full Code Here

     * @throws IOException if an error occurs while reading the file
     */
    private String getFilePropertyValue(final VirtualFile pFile,
                                        final String pChildFileName,
                                        final String pName) throws IOException {
        final VirtualFile child = pFile.findFileByRelativePath(pChildFileName);
        if (child != null && child.isValid() && !child.isDirectory() && FileUtils.exists(child))
            return getFilePropertyValue(child, pName);
        else
            return null;
    }
View Full Code Here

    public GeneralInfoPanel(final PsiProject psiProject) {
        project = psiProject;
        projectModel = new BeanAdapter(project, true);
        orgModel = new BeanAdapter(project.getOrganization(), true);

        final VirtualFile virtualFile = project.getXmlFile().getVirtualFile();
        if (virtualFile == null)
            throw new IllegalStateException("PSI file has no virtual project.");
        final VirtualFile dir = virtualFile.getParent();

        extendField = new RelativeTextFieldWithBrowseButton(dir);
        logoUriField = new RelativeTextFieldWithBrowseButton(dir);
        orgLogoUrlField = new RelativeTextFieldWithBrowseButton(dir);
View Full Code Here

        if (project == null) {
            pEvent.getPresentation().setEnabled(false);
            return;
        }

        final VirtualFile file = getVirtualFile(pEvent);
        final PomManager pomMgr = PomManager.getInstance(project);

        final boolean enabled = file != null && !pomMgr.contains(file.getUrl());
        if (pEvent.getPlace().equalsIgnoreCase(PomManagerPanel.PLACE))
            pEvent.getPresentation().setEnabled(enabled);
        else
            pEvent.getPresentation().setVisible(enabled);
    }
View Full Code Here

                    PomManagerPanel.class,
                    comp);
            return pomPanel.getSelectedPomUrl();
        }
        else {
            final VirtualFile file = getVirtualFile(pEvent);
            if (file == null || !file.isValid() || !FileUtils.exists(file))
                return null;
            else
                return file.getUrl();
        }
    }
View Full Code Here

                    PomManagerPanel.class,
                    comp);
            return pomPanel.getSelectedPomUrl();
        }
        else {
            final VirtualFile file = getVirtualFile(pEvent);
            if (file == null || !file.isValid() || !FileUtils.exists(file))
                return null;
            else
                return file.getUrl();
        }
    }
View Full Code Here

        final MavenManager mavenMgr = MavenManager.getInstance();

        //
        //make sure the user has set the Maven home location
        //
        final VirtualFile mavenHome = mavenMgr.getMavenHome();
        if (mavenHome == null || !mavenHome.isValid() || !FileUtils.exists(mavenHome))
            throw new MavenHomeUndefinedException();

        //
        //important locations for the command line
        //
        final VirtualFile foreheadConf = mavenHome.findFileByRelativePath(FOREHEAD_CONF_FILE);
        final VirtualFile jdkHome = pJvm.getHomeDirectory();
        VirtualFile javaEndorsed = jdkHome.findFileByRelativePath(JRE_ENDORSED_DIR_NAME);
        if (javaEndorsed == null)
            javaEndorsed = jdkHome.findFileByRelativePath(JDK_ENDORSED_DIR_NAME);

        final VirtualFile mavenEndorsed = mavenHome.findFileByRelativePath(MAVEN_ENDORSED_DIR_NAME);
        final VirtualFile foreheadJar = mavenHome.findFileByRelativePath(FOREHEAD_JAR_FILE);

        final StringBuilder endorsedBuf = new StringBuilder();
        if (javaEndorsed != null) {
            endorsedBuf.append(FileUtils.getAbsolutePath(javaEndorsed));
            endorsedBuf.append(File.pathSeparatorChar);
        }
        if (mavenEndorsed != null)
            endorsedBuf.append(FileUtils.getAbsolutePath(mavenEndorsed));
        final String endorsedDirs = endorsedBuf.toString();

        //
        //setup commandline
        //
        final VirtualFile dir = pPomFile.getParent();
        if (dir == null)
            throw new IllegalArgumentException("POM file has no directory.");
        setWorkingDirectory(FileUtils.getAbsolutePath(dir));
        setJdk(pJvm);
        setMainClass(FOREHEAD_MAIN_CLASS);
View Full Code Here

TOP

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

Copyright © 2015 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.