Search in sources :

Example 1 with FlexibleProjectContainer

use of org.eclipse.jst.common.jdt.internal.classpath.FlexibleProjectContainer in project liferay-ide by liferay.

the class SDKProjectBuilder method updateClasspath.

protected IStatus updateClasspath(IProject project) throws CoreException {
    FlexibleProjectContainer container = J2EEComponentClasspathContainerUtils.getInstalledWebAppLibrariesContainer(project);
    if (container == null) {
        return Status.OK_STATUS;
    }
    container.refresh();
    container = J2EEComponentClasspathContainerUtils.getInstalledWebAppLibrariesContainer(project);
    IClasspathEntry[] webappEntries = container.getClasspathEntries();
    for (IClasspathEntry entry2 : webappEntries) {
        String segment = entry2.getPath().lastSegment();
        if (segment.equals(getProject().getName() + "-service.jar")) {
            IFolder folder = getProject().getFolder(ISDKConstants.DEFAULT_DOCROOT_FOLDER + "/WEB-INF/service");
            ((ClasspathEntry) entry2).sourceAttachmentPath = folder.getFullPath();
            break;
        }
    }
    ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer("org.eclipse.jst.j2ee.internal.web.container");
    IJavaProject javaProject = JavaCore.create(project);
    initializer.requestClasspathContainerUpdate(container.getPath(), javaProject, container);
    return Status.OK_STATUS;
}
Also used : FlexibleProjectContainer(org.eclipse.jst.common.jdt.internal.classpath.FlexibleProjectContainer) IJavaProject(org.eclipse.jdt.core.IJavaProject) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ClasspathContainerInitializer(org.eclipse.jdt.core.ClasspathContainerInitializer) IFolder(org.eclipse.core.resources.IFolder)

Example 2 with FlexibleProjectContainer

use of org.eclipse.jst.common.jdt.internal.classpath.FlexibleProjectContainer in project liferay-ide by liferay.

the class PluginPackageResourceListener method updateWebClasspathContainer.

protected void updateWebClasspathContainer(IVirtualComponent rootComponent, List<IVirtualReference> addRefs) throws CoreException {
    IProject project = rootComponent.getProject();
    IJavaProject javaProject = JavaCore.create(project);
    FlexibleProjectContainer container = J2EEComponentClasspathContainerUtils.getInstalledWebAppLibrariesContainer(project);
    if (container == null) {
        return;
    }
    container.refresh();
    // need to regrab this to get newest container
    container = J2EEComponentClasspathContainerUtils.getInstalledWebAppLibrariesContainer(project);
    if (container == null) {
        return;
    }
    IClasspathEntry[] webappEntries = container.getClasspathEntries();
    for (IClasspathEntry entry : webappEntries) {
        String archiveName = entry.getPath().lastSegment();
        for (IVirtualReference ref : addRefs) {
            if (ref.getArchiveName().equals(archiveName)) {
                IFile referencedFile = (IFile) ref.getReferencedComponent().getAdapter(IFile.class);
                IProject referencedFileProject = referencedFile.getProject();
                // IDE-110 IDE-648
                IFolder folder = referencedFileProject.getFolder(ISDKConstants.DEFAULT_DOCROOT_FOLDER + "/WEB-INF/service");
                ((ClasspathEntry) entry).sourceAttachmentPath = folder.getFullPath();
            }
        }
    }
    ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer("org.eclipse.jst.j2ee.internal.web.container");
    initializer.requestClasspathContainerUpdate(container.getPath(), javaProject, container);
}
Also used : FlexibleProjectContainer(org.eclipse.jst.common.jdt.internal.classpath.FlexibleProjectContainer) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IVirtualReference(org.eclipse.wst.common.componentcore.resources.IVirtualReference) IProject(org.eclipse.core.resources.IProject) ClasspathContainerInitializer(org.eclipse.jdt.core.ClasspathContainerInitializer) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IFolder (org.eclipse.core.resources.IFolder)2 ClasspathContainerInitializer (org.eclipse.jdt.core.ClasspathContainerInitializer)2 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)2 IJavaProject (org.eclipse.jdt.core.IJavaProject)2 FlexibleProjectContainer (org.eclipse.jst.common.jdt.internal.classpath.FlexibleProjectContainer)2 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IVirtualReference (org.eclipse.wst.common.componentcore.resources.IVirtualReference)1