Search in sources :

Example 1 with IVirtualReference

use of org.eclipse.wst.common.componentcore.resources.IVirtualReference 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)

Example 2 with IVirtualReference

use of org.eclipse.wst.common.componentcore.resources.IVirtualReference in project webtools.sourceediting by eclipse.

the class ModuleCoreSupportDelegate method resolveInReferenced.

private static IPath resolveInReferenced(IProject project, IPath runtimeReference) {
    IVirtualReference[] references = ComponentCore.createComponent(project).getReferences();
    if (references != null) {
        for (int i = 0; i < references.length; i++) {
            IVirtualComponent referencedComponent = references[i].getReferencedComponent();
            if (referencedComponent == null)
                continue;
            IVirtualComponent component = referencedComponent.getComponent();
            if (component == null)
                continue;
            IVirtualFolder rootFolder = component.getRootFolder();
            if (rootFolder == null)
                continue;
            // overlay?
            IVirtualResource member = rootFolder.findMember(runtimeReference);
            if (member != null) {
                return member.getWorkspaceRelativePath();
            }
        }
    }
    return null;
}
Also used : IVirtualReference(org.eclipse.wst.common.componentcore.resources.IVirtualReference) IVirtualFolder(org.eclipse.wst.common.componentcore.resources.IVirtualFolder) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent) IVirtualResource(org.eclipse.wst.common.componentcore.resources.IVirtualResource)

Example 3 with IVirtualReference

use of org.eclipse.wst.common.componentcore.resources.IVirtualReference in project webtools.sourceediting by eclipse.

the class ModuleCoreSupportDelegate method resolveInReferenced.

private static IPath resolveInReferenced(IProject project, IPath runtimeReference) {
    IVirtualReference[] references = ComponentCore.createComponent(project).getReferences();
    if (references != null) {
        for (int i = 0; i < references.length; i++) {
            IVirtualComponent referencedComponent = references[i].getReferencedComponent();
            if (referencedComponent == null)
                continue;
            IVirtualComponent component = referencedComponent.getComponent();
            if (component == null)
                continue;
            IVirtualFolder rootFolder = component.getRootFolder();
            if (rootFolder == null)
                continue;
            // overlay?
            IVirtualResource member = rootFolder.findMember(runtimeReference);
            if (member != null) {
                return member.getWorkspaceRelativePath();
            }
        }
    }
    return null;
}
Also used : IVirtualReference(org.eclipse.wst.common.componentcore.resources.IVirtualReference) IVirtualFolder(org.eclipse.wst.common.componentcore.resources.IVirtualFolder) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent) IVirtualResource(org.eclipse.wst.common.componentcore.resources.IVirtualResource)

Example 4 with IVirtualReference

use of org.eclipse.wst.common.componentcore.resources.IVirtualReference in project webtools.sourceediting by eclipse.

the class FacetModuleCoreSupportDelegate method getAcceptableRootPaths.

static IPath[] getAcceptableRootPaths(IProject project) {
    if (!ModuleCoreNature.isFlexibleProject(project)) {
        return new IPath[] { project.getFullPath() };
    }
    List paths = new ArrayList();
    IVirtualFolder componentFolder = ComponentCore.createFolder(project, Path.ROOT);
    if (componentFolder != null && componentFolder.exists()) {
        IContainer[] workspaceFolders = componentFolder.getUnderlyingFolders();
        for (int i = 0; i < workspaceFolders.length; i++) {
            if (workspaceFolders[i].getFolder(FacetModuleCoreSupport.META_INF_RESOURCES_PATH).isAccessible())
                paths.add(workspaceFolders[i].getFullPath().append(FacetModuleCoreSupport.META_INF_RESOURCES_PATH));
            else
                paths.add(workspaceFolders[i].getFullPath());
        }
        IVirtualReference[] references = ComponentCore.createComponent(project).getReferences();
        if (references != null) {
            for (int i = 0; i < references.length; i++) {
                IVirtualComponent referencedComponent = references[i].getReferencedComponent();
                if (referencedComponent == null)
                    continue;
                IVirtualComponent component = referencedComponent.getComponent();
                if (component == null)
                    continue;
                IVirtualFolder rootFolder = component.getRootFolder();
                if (rootFolder == null)
                    continue;
                IPath referencedPathRoot = rootFolder.getWorkspaceRelativePath();
                /* http://bugs.eclipse.org/410161 */
                if (referencedPathRoot != null) {
                    /*
						 * See Servlet 3.0, section 4.6 ; this is the only
						 * referenced module/component type we support
						 */
                    IPath resources = referencedPathRoot.append(FacetModuleCoreSupport.META_INF_RESOURCES);
                    if (resources != null && component.getProject().findMember(resources.removeFirstSegments(1)) != null) {
                        paths.add(resources);
                    }
                }
            }
        }
    } else {
        paths.add(project.getFullPath());
    }
    return (IPath[]) paths.toArray(new IPath[paths.size()]);
}
Also used : IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IVirtualFolder(org.eclipse.wst.common.componentcore.resources.IVirtualFolder) IVirtualReference(org.eclipse.wst.common.componentcore.resources.IVirtualReference) IContainer(org.eclipse.core.resources.IContainer) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent)

Example 5 with IVirtualReference

use of org.eclipse.wst.common.componentcore.resources.IVirtualReference in project webtools.sourceediting by eclipse.

the class FacetModuleCoreSupportDelegate method getAcceptableRootPaths.

static IPath[] getAcceptableRootPaths(IProject project) {
    if (!ModuleCoreNature.isFlexibleProject(project)) {
        return new IPath[] { project.getFullPath() };
    }
    List paths = new ArrayList();
    IVirtualFolder componentFolder = ComponentCore.createFolder(project, Path.ROOT);
    if (componentFolder != null && componentFolder.exists()) {
        IContainer[] workspaceFolders = componentFolder.getUnderlyingFolders();
        for (int i = 0; i < workspaceFolders.length; i++) {
            if (workspaceFolders[i].getFolder(FacetModuleCoreSupport.META_INF_RESOURCES_PATH).isAccessible())
                paths.add(workspaceFolders[i].getFullPath().append(FacetModuleCoreSupport.META_INF_RESOURCES_PATH));
            else
                paths.add(workspaceFolders[i].getFullPath());
        }
        IVirtualReference[] references = ComponentCore.createComponent(project).getReferences();
        if (references != null) {
            for (int i = 0; i < references.length; i++) {
                IVirtualComponent referencedComponent = references[i].getReferencedComponent();
                if (referencedComponent == null)
                    continue;
                IVirtualComponent component = referencedComponent.getComponent();
                if (component == null)
                    continue;
                IVirtualFolder rootFolder = component.getRootFolder();
                if (rootFolder == null)
                    continue;
                IPath referencedPathRoot = rootFolder.getWorkspaceRelativePath();
                /* http://bugs.eclipse.org/410161 */
                if (referencedPathRoot != null) {
                    /*
						 * See Servlet 3.0, section 4.6 ; this is the only
						 * referenced module/component type we support
						 */
                    IPath resources = referencedPathRoot.append(FacetModuleCoreSupport.META_INF_RESOURCES);
                    if (resources != null && component.getProject().findMember(resources.removeFirstSegments(1)) != null) {
                        paths.add(resources);
                    }
                }
            }
        }
    } else {
        paths.add(project.getFullPath());
    }
    return (IPath[]) paths.toArray(new IPath[paths.size()]);
}
Also used : IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IVirtualFolder(org.eclipse.wst.common.componentcore.resources.IVirtualFolder) IVirtualReference(org.eclipse.wst.common.componentcore.resources.IVirtualReference) IContainer(org.eclipse.core.resources.IContainer) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent)

Aggregations

IVirtualReference (org.eclipse.wst.common.componentcore.resources.IVirtualReference)12 IVirtualComponent (org.eclipse.wst.common.componentcore.resources.IVirtualComponent)11 IPath (org.eclipse.core.runtime.IPath)6 IVirtualFolder (org.eclipse.wst.common.componentcore.resources.IVirtualFolder)6 ArrayList (java.util.ArrayList)5 List (java.util.List)3 IContainer (org.eclipse.core.resources.IContainer)3 IFile (org.eclipse.core.resources.IFile)3 IVirtualResource (org.eclipse.wst.common.componentcore.resources.IVirtualResource)3 IProject (org.eclipse.core.resources.IProject)2 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1 IFolder (org.eclipse.core.resources.IFolder)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 Path (org.eclipse.core.runtime.Path)1 ClasspathContainerInitializer (org.eclipse.jdt.core.ClasspathContainerInitializer)1