Search in sources :

Example 1 with AntInstallation

use of com.intellij.lang.ant.config.impl.AntInstallation in project intellij-community by JetBrains.

the class AntUIUtil method customizeReference.

public static void customizeReference(AntReference antReference, SimpleColoredComponent component, GlobalAntConfiguration configuration) {
    AntInstallation antInstallation = antReference.find(configuration);
    if (antInstallation != null)
        customizeAnt(antInstallation.getProperties(), component);
    else {
        component.setIcon(PlatformIcons.INVALID_ENTRY_ICON);
        component.append(antReference.getName(), SimpleTextAttributes.ERROR_ATTRIBUTES);
    }
}
Also used : AntInstallation(com.intellij.lang.ant.config.impl.AntInstallation)

Example 2 with AntInstallation

use of com.intellij.lang.ant.config.impl.AntInstallation in project intellij-community by JetBrains.

the class AntDomDocumentationProvider method getHelpFile.

@Nullable
private static VirtualFile getHelpFile(final PsiElement element) {
    final XmlTag xmlTag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
    if (xmlTag == null) {
        return null;
    }
    final AntDomElement antElement = AntSupport.getAntDomElement(xmlTag);
    if (antElement == null) {
        return null;
    }
    final AntDomProject antProject = antElement.getAntProject();
    if (antProject == null) {
        return null;
    }
    final AntInstallation installation = antProject.getAntInstallation();
    if (installation == null) {
        // not configured properly and bundled installation missing
        return null;
    }
    final String antHomeDir = AntInstallation.HOME_DIR.get(installation.getProperties());
    if (antHomeDir == null) {
        return null;
    }
    @NonNls String path = antHomeDir + "/docs/manual";
    String url;
    if (new File(path).exists()) {
        url = VirtualFileManager.constructUrl(LocalFileSystem.PROTOCOL, FileUtil.toSystemIndependentName(path));
    } else {
        path = antHomeDir + "/docs.zip";
        if (new File(path).exists()) {
            url = VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, FileUtil.toSystemIndependentName(path) + JarFileSystem.JAR_SEPARATOR + "docs/manual");
        } else {
            return null;
        }
    }
    final VirtualFile documentationRoot = VirtualFileManager.getInstance().findFileByUrl(url);
    if (documentationRoot == null) {
        return null;
    }
    return getHelpFile(antElement, documentationRoot);
}
Also used : NonNls(org.jetbrains.annotations.NonNls) AntDomElement(com.intellij.lang.ant.dom.AntDomElement) AntInstallation(com.intellij.lang.ant.config.impl.AntInstallation) PsiFile(com.intellij.psi.PsiFile) File(java.io.File) XmlTag(com.intellij.psi.xml.XmlTag) AntDomProject(com.intellij.lang.ant.dom.AntDomProject) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with AntInstallation

use of com.intellij.lang.ant.config.impl.AntInstallation in project intellij-community by JetBrains.

the class AntDomProject method getClassLoader.

@NotNull
public final ClassLoader getClassLoader() {
    ClassLoader loader = myClassLoader;
    if (loader == null) {
        final XmlTag tag = getXmlTag();
        final PsiFile containingFile = tag.getContainingFile();
        final AntBuildFileImpl buildFile = (AntBuildFileImpl) AntConfigurationBase.getInstance(containingFile.getProject()).getAntBuildFile(containingFile);
        if (buildFile != null) {
            loader = buildFile.getClassLoader();
        } else {
            AntInstallation antInstallation = getAntInstallation();
            loader = antInstallation.getClassLoader();
        }
        myClassLoader = loader;
    }
    return loader;
}
Also used : AntBuildFileImpl(com.intellij.lang.ant.config.impl.AntBuildFileImpl) PsiFile(com.intellij.psi.PsiFile) AntInstallation(com.intellij.lang.ant.config.impl.AntInstallation) XmlTag(com.intellij.psi.xml.XmlTag) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with AntInstallation

use of com.intellij.lang.ant.config.impl.AntInstallation in project intellij-community by JetBrains.

the class AntSetPanel method apply.

void apply() {
    for (AntInstallation ant : myForm.getRemovedAnts()) {
        myAntConfiguration.removeConfiguration(ant);
    }
    final Map<AntReference, AntInstallation> currentAnts = myAntConfiguration.getConfiguredAnts();
    for (AntInstallation installation : currentAnts.values()) {
        installation.updateClasspath();
    }
    for (AntInstallation ant : myForm.getAddedAnts()) {
        myAntConfiguration.addConfiguration(ant);
    }
    myForm.applyModifications();
}
Also used : AntReference(com.intellij.lang.ant.config.impl.AntReference) AntInstallation(com.intellij.lang.ant.config.impl.AntInstallation)

Example 5 with AntInstallation

use of com.intellij.lang.ant.config.impl.AntInstallation in project intellij-community by JetBrains.

the class AntDomProject method loadPredefinedProperties.

@SuppressWarnings({ "UseOfObsoleteCollectionType" })
private Map<String, String> loadPredefinedProperties(final Hashtable properties, final Map<String, String> externalProps) {
    final Map<String, String> destination = new HashMap<>();
    if (properties != null) {
        final Enumeration props = properties.keys();
        while (props.hasMoreElements()) {
            final String name = (String) props.nextElement();
            final String value = (String) properties.get(name);
            appendProperty(destination, name, value);
        }
    }
    //}
    if (externalProps != null) {
        for (final String name : externalProps.keySet()) {
            final String value = externalProps.get(name);
            appendProperty(destination, name, value);
        }
    }
    String basedir = getProjectBasedirPath();
    if (basedir == null) {
        basedir = ".";
    }
    if (!FileUtil.isAbsolute(basedir)) {
        final String containigFileDir = getContainingFileDir();
        if (containigFileDir != null) {
            try {
                basedir = new File(containigFileDir, basedir).getCanonicalPath();
            } catch (IOException ignored) {
            }
        }
    }
    appendProperty(destination, "basedir", FileUtil.toSystemIndependentName(basedir));
    final AntInstallation installation = getAntInstallation();
    final String homeDir = installation.getHomeDir();
    if (homeDir != null) {
        appendProperty(destination, "ant.home", FileUtil.toSystemIndependentName(homeDir));
    }
    appendProperty(destination, "ant.version", installation.getVersion());
    final String projectName = getName().getRawText();
    appendProperty(destination, "ant.project.name", (projectName == null) ? "" : projectName);
    final Sdk jdkToRunWith = getTargetJdk();
    final String version = jdkToRunWith != null ? jdkToRunWith.getVersionString() : null;
    appendProperty(destination, "ant.java.version", version != null ? version : SystemInfo.JAVA_VERSION);
    final VirtualFile containingFile = getXmlTag().getContainingFile().getOriginalFile().getVirtualFile();
    if (containingFile != null) {
        final String antFilePath = containingFile.getPath();
        appendProperty(destination, "ant.file", antFilePath);
        if (projectName != null) {
            appendProperty(destination, "ant.file." + projectName, antFilePath);
            appendProperty(destination, "ant.file.type." + projectName, "file");
        }
    }
    return destination;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HashMap(com.intellij.util.containers.HashMap) IOException(java.io.IOException) AntInstallation(com.intellij.lang.ant.config.impl.AntInstallation) Sdk(com.intellij.openapi.projectRoots.Sdk) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) File(java.io.File)

Aggregations

AntInstallation (com.intellij.lang.ant.config.impl.AntInstallation)6 PsiFile (com.intellij.psi.PsiFile)3 XmlTag (com.intellij.psi.xml.XmlTag)2 File (java.io.File)2 AntConfigurationBase (com.intellij.lang.ant.config.AntConfigurationBase)1 AntBuildFileImpl (com.intellij.lang.ant.config.impl.AntBuildFileImpl)1 AntReference (com.intellij.lang.ant.config.impl.AntReference)1 AntDomElement (com.intellij.lang.ant.dom.AntDomElement)1 AntDomProject (com.intellij.lang.ant.dom.AntDomProject)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 HashMap (com.intellij.util.containers.HashMap)1 IOException (java.io.IOException)1 NonNls (org.jetbrains.annotations.NonNls)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1