Search in sources :

Example 6 with IVirtualFolder

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

use of org.eclipse.wst.common.componentcore.resources.IVirtualFolder 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 8 with IVirtualFolder

use of org.eclipse.wst.common.componentcore.resources.IVirtualFolder 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 9 with IVirtualFolder

use of org.eclipse.wst.common.componentcore.resources.IVirtualFolder 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 resourcesPath = referencedPathRoot.append(FacetModuleCoreSupport.META_INF_RESOURCES);
                    if (resourcesPath != null && component.getProject().findMember(resourcesPath.removeFirstSegments(1)) != null) {
                        paths.add(resourcesPath);
                    }
                }
            }
        }
    } 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 10 with IVirtualFolder

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

the class FacetModuleCoreSupportDelegate 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;
            IPath referencedPathRoot = rootFolder.getWorkspaceRelativePath();
            /* http://bugs.eclipse.org/410161 */
            if (referencedPathRoot != null) {
                /*
					 * See Servlet 3.0, section 4.6, web fragments as required
					 * projects
					 */
                IPath resolved = referencedPathRoot.append(FacetModuleCoreSupport.META_INF_RESOURCES).append(runtimeReference);
                if (resolved != null && component.getProject().findMember(resolved.removeFirstSegments(1)) != null) {
                    return resolved;
                }
            }
            // overlay?
            IVirtualResource member = rootFolder.findMember(runtimeReference);
            if (member != null) {
                return member.getWorkspaceRelativePath();
            }
        }
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) 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)

Aggregations

IVirtualFolder (org.eclipse.wst.common.componentcore.resources.IVirtualFolder)19 IPath (org.eclipse.core.runtime.IPath)14 IVirtualComponent (org.eclipse.wst.common.componentcore.resources.IVirtualComponent)12 IVirtualReference (org.eclipse.wst.common.componentcore.resources.IVirtualReference)8 IVirtualResource (org.eclipse.wst.common.componentcore.resources.IVirtualResource)8 IContainer (org.eclipse.core.resources.IContainer)7 Path (org.eclipse.core.runtime.Path)7 IFile (org.eclipse.core.resources.IFile)5 IFolder (org.eclipse.core.resources.IFolder)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 IProject (org.eclipse.core.resources.IProject)3 IResource (org.eclipse.core.resources.IResource)3 IVirtualFile (org.eclipse.wst.common.componentcore.resources.IVirtualFile)3 Reference (java.lang.ref.Reference)2 SoftReference (java.lang.ref.SoftReference)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CoreException (org.eclipse.core.runtime.CoreException)2 JavaModelException (org.eclipse.jdt.core.JavaModelException)2