Search in sources :

Example 41 with IClasspathAttribute

use of org.eclipse.jdt.core.IClasspathAttribute in project liferay-ide by liferay.

the class LiferayTomcatRuntimeClasspathProvider method getUpdatedJavadocEntries.

private IClasspathEntry[] getUpdatedJavadocEntries(IClasspathEntry[] entries, ILiferayTomcatRuntime liferayTomcatRuntime) {
    List<IClasspathEntry> updatedEntries = new ArrayList<IClasspathEntry>();
    String javadocURL = liferayTomcatRuntime.getJavadocURL();
    if (javadocURL != null) {
        for (IClasspathEntry existingEntry : entries) {
            IPath path = existingEntry.getPath();
            IClasspathEntry newEntry = null;
            for (String javadocJar : JARS) {
                if (path.lastSegment().equalsIgnoreCase(javadocJar)) {
                    IClasspathAttribute[] extraAttrs = existingEntry.getExtraAttributes();
                    List<IClasspathAttribute> newExtraAttrs = new ArrayList<IClasspathAttribute>();
                    IClasspathAttribute javadocAttr = newJavadocAttr(javadocURL);
                    newExtraAttrs.add(javadocAttr);
                    if (ListUtil.isNotEmpty(extraAttrs)) {
                        for (IClasspathAttribute attr : extraAttrs) {
                            if (!attr.getName().equals(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME)) {
                                newExtraAttrs.add(attr);
                            }
                        }
                    }
                    newEntry = JavaCore.newLibraryEntry(existingEntry.getPath(), existingEntry.getSourceAttachmentPath(), existingEntry.getSourceAttachmentRootPath(), existingEntry.getAccessRules(), newExtraAttrs.toArray(new IClasspathAttribute[0]), existingEntry.isExported());
                    break;
                }
            }
            if (newEntry != null) {
                updatedEntries.add(newEntry);
            } else {
                updatedEntries.add(existingEntry);
            }
        }
    } else {
        Collections.addAll(updatedEntries, entries);
    }
    return updatedEntries.toArray(new IClasspathEntry[0]);
}
Also used : IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ArrayList(java.util.ArrayList)

Example 42 with IClasspathAttribute

use of org.eclipse.jdt.core.IClasspathAttribute in project lwjgl by LWJGL.

the class LWJGLClasspathContainerPage method update.

protected void update() {
    IStatus status = null;
    IClasspathEntry[] libEntries = BuildPathSupport.getLWJGLLibraryEntries();
    IPath containerPath = LWJGLClasspathContainerInitializer.LWJGL_LIBRARY_PATH;
    containerEntryResult = JavaCore.newContainerEntry(containerPath);
    if (libEntries == null) {
        status = new Status(ERROR, Activator.PLUGIN_ID, "No LWJGL library found");
    } else if (labelResolvedPath != null && !labelResolvedPath.isDisposed()) {
        // implies all other labels to be created and not yet disposed
        if (libEntries != null) {
            Set<String> setLines = new TreeSet<String>();
            IPath path;
            for (IClasspathEntry entry : libEntries) {
                path = entry.getPath();
                if (path != null) {
                    setLines.add(getPathLabel(path));
                }
            }
            setLabel(labelResolvedPath, setLines);
            setLines.clear();
            for (IClasspathEntry entry : libEntries) {
                path = entry.getSourceAttachmentPath();
                if (path != null) {
                    setLines.add(getPathLabel(path));
                }
            }
            setLabel(labelResolvedSourcePath, setLines);
            setLines.clear();
            for (IClasspathEntry entry : libEntries) {
                if (entry.getExtraAttributes() != null) {
                    for (IClasspathAttribute attr : entry.getExtraAttributes()) {
                        if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attr.getName())) {
                            setLines.add(attr.getValue());
                            break;
                        }
                        if (JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY.equals(attr.getName())) {
                        }
                    }
                }
            }
            setLabel(labelResolvedDocPath, setLines);
            setLines.clear();
            for (IClasspathEntry entry : libEntries) {
                if (entry.getExtraAttributes() != null) {
                    for (IClasspathAttribute attr : entry.getExtraAttributes()) {
                        if (JavaRuntime.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY.equals(attr.getName())) {
                            setLines.add(attr.getValue());
                        }
                    }
                }
            }
            setLabel(labelNativePath, setLines);
        } else {
            labelResolvedPath.setText("not found");
            labelResolvedSourcePath.setText("not found");
            labelResolvedDocPath.setText("not found");
        }
    }
    if (status != null)
        updateStatus(status);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) IStatus(org.eclipse.core.runtime.IStatus) TreeSet(java.util.TreeSet) Set(java.util.Set) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry)

Example 43 with IClasspathAttribute

use of org.eclipse.jdt.core.IClasspathAttribute in project lwjgl by LWJGL.

the class LWJGLClasspathContainerInitializer method requestClasspathContainerUpdate.

/**
 * {@inheritDoc}
 * @see org.eclipse.jdt.core.ClasspathContainerInitializer#requestClasspathContainerUpdate(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject, org.eclipse.jdt.core.IClasspathContainer)
 */
public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException {
    IClasspathEntry[] entries = containerSuggestion.getClasspathEntries();
    if (entries.length == 1 && isValidLWJGLContainerPath(containerPath)) {
        // String version = containerPath.segment(1);
        // only modifiable entry in Javadoc location
        IClasspathAttribute[] extraAttributes = entries[0].getExtraAttributes();
        for (int i = 0; i < extraAttributes.length; i++) {
            IClasspathAttribute attrib = extraAttributes[i];
            if (attrib.getName().equals(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME)) {
                break;
            }
        }
        rebindClasspathEntries(project.getJavaModel(), containerPath);
    }
}
Also used : IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry)

Example 44 with IClasspathAttribute

use of org.eclipse.jdt.core.IClasspathAttribute in project azure-tools-for-java by Microsoft.

the class AIProjConfigWizardDialog method configureAzureSDK.

private void configureAzureSDK(IJavaProject proj) {
    try {
        IClasspathEntry[] classpath = proj.getRawClasspath();
        for (IClasspathEntry iclasspathEntry : classpath) {
            final IPath containerPath = iclasspathEntry.getPath();
            if (containerPath.toString().contains(Messages.azureSDKcontainerID)) {
                return;
            }
        }
        List<IClasspathEntry> list = new ArrayList<IClasspathEntry>(java.util.Arrays.asList(classpath));
        IClasspathAttribute[] attr = new IClasspathAttribute[1];
        attr[0] = JavaCore.newClasspathAttribute(Messages.jstDep, "/WEB-INF/lib");
        IClasspathEntry jarEntry = JavaCore.newContainerEntry(new Path(Messages.azureSDKcontainerID).append(getLatestSDKVersion()), null, attr, false);
        list.add(jarEntry);
        IClasspathEntry[] newClasspath = list.toArray(new IClasspathEntry[0]);
        proj.setRawClasspath(newClasspath, null);
        // Azure SDK configured - application insights configured for the first time for specific project
        Bundle bundle = Activator.getDefault().getBundle();
        if (bundle != null) {
            PluginUtil.showBusy(true, getShell());
            AppInsightsClient.create("Application Insights", bundle.getVersion().toString());
            PluginUtil.showBusy(false, getShell());
        }
    } catch (Exception e) {
        Activator.getDefault().log(e.getMessage(), e);
    }
}
Also used : IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException)

Example 45 with IClasspathAttribute

use of org.eclipse.jdt.core.IClasspathAttribute in project azure-tools-for-java by Microsoft.

the class ClasspathContainerPage method getSelection.

@Override
public IClasspathEntry getSelection() {
    IClasspathEntry classPathEntry = null;
    if (depCheck.getSelection()) {
        IClasspathAttribute[] attr = new IClasspathAttribute[1];
        attr[0] = JavaCore.newClasspathAttribute(Messages.jstDep, "/WEB-INF/lib");
        classPathEntry = JavaCore.newContainerEntry(entry, null, attr, true);
    } else {
        classPathEntry = JavaCore.newContainerEntry(entry);
    }
    return classPathEntry;
}
Also used : IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry)

Aggregations

IClasspathAttribute (org.eclipse.jdt.core.IClasspathAttribute)52 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)37 IPath (org.eclipse.core.runtime.IPath)26 ArrayList (java.util.ArrayList)17 IJavaProject (org.eclipse.jdt.core.IJavaProject)16 Path (org.eclipse.core.runtime.Path)11 HashMap (java.util.HashMap)9 CoreException (org.eclipse.core.runtime.CoreException)9 IAccessRule (org.eclipse.jdt.core.IAccessRule)9 File (java.io.File)6 LinkedHashMap (java.util.LinkedHashMap)6 IProject (org.eclipse.core.resources.IProject)6 Map (java.util.Map)5 IFolder (org.eclipse.core.resources.IFolder)5 Bundle (org.osgi.framework.Bundle)5 Iterator (java.util.Iterator)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 JavaModelException (org.eclipse.jdt.core.JavaModelException)4 URL (java.net.URL)3 IClasspathContainer (org.eclipse.jdt.core.IClasspathContainer)3