Search in sources :

Example 6 with IClasspathContainer

use of org.eclipse.jdt.core.IClasspathContainer in project che by eclipse.

the class SetContainerOperation method verbose_set_container.

private void verbose_set_container() {
    Util.verbose(//$NON-NLS-1$
    "CPContainer SET  - setting container\n" + "	container path: " + this.containerPath + //$NON-NLS-1$
    '\n' + //$NON-NLS-1$
    "	projects: {" + org.eclipse.jdt.internal.compiler.util.Util.toString(this.affectedProjects, new org.eclipse.jdt.internal.compiler.util.Util.Displayable() {

        public String displayString(Object o) {
            return ((IJavaProject) o).getElementName();
        }
    }) + //$NON-NLS-1$
    "}\n	values: {\n" + org.eclipse.jdt.internal.compiler.util.Util.toString(this.respectiveContainers, new org.eclipse.jdt.internal.compiler.util.Util.Displayable() {

        public String displayString(Object o) {
            //$NON-NLS-1$
            StringBuffer buffer = new StringBuffer("		");
            if (o == null) {
                //$NON-NLS-1$
                buffer.append("<null>");
                return buffer.toString();
            }
            IClasspathContainer container = (IClasspathContainer) o;
            buffer.append(container.getDescription());
            //$NON-NLS-1$
            buffer.append(" {\n");
            IClasspathEntry[] entries = container.getClasspathEntries();
            if (entries != null) {
                for (int i = 0; i < entries.length; i++) {
                    //$NON-NLS-1$
                    buffer.append(" 			");
                    buffer.append(entries[i]);
                    buffer.append('\n');
                }
            }
            //$NON-NLS-1$
            buffer.append(" 		}");
            return buffer.toString();
        }
    }) + //$NON-NLS-1$
    "\n	}");
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer)

Example 7 with IClasspathContainer

use of org.eclipse.jdt.core.IClasspathContainer in project bndtools by bndtools.

the class BndtoolsBuilder method requestClasspathContainerUpdate.

/**
     * Request the classpath container be updated for this project.
     * <p>
     * The classpath container may have added errors to the model which the caller must check for.
     *
     * @return {@code true} if this project has a bnd classpath container and the classpath was changed. {@code false}
     *         if this project does not have a bnd classpath container or the classpath was not changed.
     */
private boolean requestClasspathContainerUpdate() throws CoreException {
    IJavaProject javaProject = JavaCore.create(getProject());
    if (javaProject == null) {
        // project is not a java project
        return false;
    }
    IClasspathContainer oldContainer = BndContainerInitializer.getClasspathContainer(javaProject);
    if (oldContainer == null) {
        // project does not have a BndContainer
        return false;
    }
    BndContainerInitializer.requestClasspathContainerUpdate(javaProject);
    return oldContainer != BndContainerInitializer.getClasspathContainer(javaProject);
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer)

Example 8 with IClasspathContainer

use of org.eclipse.jdt.core.IClasspathContainer in project xtext-xtend by eclipse.

the class XtendContainerInitializer method initialize.

/**
 * {@inheritDoc}
 */
@Override
public void initialize(final IPath containerPath, final IJavaProject project) throws CoreException {
    if (isXtendPath(containerPath)) {
        IClasspathContainer container = new XtendClasspathContainer(containerPath);
        JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, new IClasspathContainer[] { container }, null);
    }
}
Also used : IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer)

Example 9 with IClasspathContainer

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

the class SDKClasspathContainerInitializer method initialize.

@Override
public void initialize(IPath containerPath, IJavaProject project) throws CoreException {
    IClasspathContainer classpathContainer = null;
    String root = containerPath.segment(0);
    if (!SDKClasspathContainer.ID.equals(root)) {
        String msg = "Invalid plugin classpath container, expecting container root ";
        throw new CoreException(ProjectCore.createErrorStatus(msg + SDKClasspathContainer.ID));
    }
    PortalBundle bundle = ServerUtil.getPortalBundle(project.getProject());
    if (bundle == null) {
        String msg = "Invalid sdk properties setting.";
        throw new CoreException(ProjectCore.createErrorStatus(msg));
    }
    IPath globalDir = bundle.getAppServerLibGlobalDir();
    IPath portalDir = bundle.getAppServerPortalDir();
    IPath bundleDir = bundle.getAppServerDir();
    IPath[] bundleDependencyJars = bundle.getBundleDependencyJars();
    IPath[] sdkDependencyJarPaths = _getSDKDependencies(project);
    if (portalDir == null) {
        return;
    }
    classpathContainer = new SDKClasspathContainer(containerPath, project, portalDir, null, null, globalDir, bundleDir, bundleDependencyJars, sdkDependencyJarPaths);
    IJavaProject[] projects = { project };
    IClasspathContainer[] containers = { classpathContainer };
    JavaCore.setClasspathContainer(containerPath, projects, containers, null);
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) CoreException(org.eclipse.core.runtime.CoreException) PortalBundle(com.liferay.ide.server.core.portal.PortalBundle) IPath(org.eclipse.core.runtime.IPath) IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer)

Example 10 with IClasspathContainer

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

the class PluginClasspathContainerInitializer method initialize.

@Override
public void initialize(IPath containerPath, IJavaProject project) throws CoreException {
    IClasspathContainer classpathContainer = null;
    int count = containerPath.segmentCount();
    if (count != 2) {
        String msg = "Invalid plugin classpath container should expecting 2 segments.";
        throw new CoreException(ProjectCore.createErrorStatus(msg));
    }
    String root = containerPath.segment(0);
    if (!ID.equals(root)) {
        String msg = "Invalid plugin classpath container, expecting container root ";
        throw new CoreException(ProjectCore.createErrorStatus(msg + ID));
    }
    String finalSegment = containerPath.segment(1);
    IPath portalDir = ServerUtil.getPortalDir(project);
    if (portalDir == null) {
        return;
    }
    String javadocURL = null;
    IPath sourceLocation = null;
    try {
        ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(project.getProject());
        if (liferayRuntime != null) {
            javadocURL = liferayRuntime.getJavadocURL();
            sourceLocation = liferayRuntime.getSourceLocation();
        }
    } catch (Exception e) {
        ProjectCore.logError(e);
    }
    classpathContainer = getCorrectContainer(containerPath, finalSegment, project, portalDir, javadocURL, sourceLocation);
    IJavaProject[] projects = { project };
    IClasspathContainer[] containers = { classpathContainer };
    JavaCore.setClasspathContainer(containerPath, projects, containers, null);
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) CoreException(org.eclipse.core.runtime.CoreException) IPath(org.eclipse.core.runtime.IPath) ILiferayRuntime(com.liferay.ide.server.core.ILiferayRuntime) IClasspathContainer(org.eclipse.jdt.core.IClasspathContainer) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

IClasspathContainer (org.eclipse.jdt.core.IClasspathContainer)34 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)16 IJavaProject (org.eclipse.jdt.core.IJavaProject)16 IPath (org.eclipse.core.runtime.IPath)13 CoreException (org.eclipse.core.runtime.CoreException)10 ClasspathContainerInitializer (org.eclipse.jdt.core.ClasspathContainerInitializer)8 ArrayList (java.util.ArrayList)6 JavaModelException (org.eclipse.jdt.core.JavaModelException)6 Map (java.util.Map)5 IProject (org.eclipse.core.resources.IProject)5 HashMap (java.util.HashMap)4 WeakHashMap (java.util.WeakHashMap)3 IClasspathAttribute (org.eclipse.jdt.core.IClasspathAttribute)3 ILiferayRuntime (com.liferay.ide.server.core.ILiferayRuntime)2 PortalBundle (com.liferay.ide.server.core.portal.PortalBundle)2 IResource (org.eclipse.core.resources.IResource)2 IStatus (org.eclipse.core.runtime.IStatus)2 Path (org.eclipse.core.runtime.Path)2 IJavaModelStatus (org.eclipse.jdt.core.IJavaModelStatus)2 ClasspathDecorations (org.eclipse.jst.common.jdt.internal.classpath.ClasspathDecorations)2