Search in sources :

Example 26 with IVirtualComponent

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

the class ComponentDeployable method addUtilMember.

protected void addUtilMember(IVirtualComponent parent, IVirtualReference reference, IPath runtimePath) {
    IModuleFile mf = null;
    final String archiveName2 = reference.getArchiveName();
    final String archiveName = new Path(archiveName2).lastSegment();
    final IVirtualComponent virtualComp = reference.getReferencedComponent();
    IFile ifile = virtualComp.getAdapter(IFile.class);
    if (ifile != null) {
        // In Workspace
        String name = null != archiveName ? archiveName : ifile.getName();
        mf = new ModuleFile(ifile, name, runtimePath.makeRelative());
    } else {
        File extFile = virtualComp.getAdapter(File.class);
        String name = null != archiveName ? archiveName : extFile.getName();
        mf = new ModuleFile(extFile, name, runtimePath.makeRelative());
    }
    IModuleResource moduleParent = getExistingModuleResource(members, mf.getModuleRelativePath());
    if (moduleParent != null && moduleParent instanceof ModuleFolder) {
        addMembersToModuleFolder((ModuleFolder) moduleParent, new IModuleResource[] { mf });
    } else {
        if (mf.getModuleRelativePath().isEmpty()) {
            members.add(mf);
        } else {
            if (moduleParent == null) {
                moduleParent = ensureParentExists(mf.getModuleRelativePath(), (IContainer) parent.getRootFolder().getUnderlyingResource());
            }
            addMembersToModuleFolder((ModuleFolder) moduleParent, new IModuleResource[] { mf });
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IFile(org.eclipse.core.resources.IFile) IModuleFile(org.eclipse.wst.server.core.model.IModuleFile) ModuleFile(org.eclipse.wst.server.core.util.ModuleFile) IModuleFile(org.eclipse.wst.server.core.model.IModuleFile) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent) IContainer(org.eclipse.core.resources.IContainer) ModuleFile(org.eclipse.wst.server.core.util.ModuleFile) IFile(org.eclipse.core.resources.IFile) IModuleFile(org.eclipse.wst.server.core.model.IModuleFile) File(java.io.File) ModuleFolder(org.eclipse.wst.server.core.util.ModuleFolder) IModuleFolder(org.eclipse.wst.server.core.model.IModuleFolder)

Example 27 with IVirtualComponent

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

the class ComponentDeployable method members.

@Override
public IModuleResource[] members() throws CoreException {
    members.clear();
    IVirtualComponent vc = ComponentCore.createComponent(getProject());
    if (vc != null) {
        IVirtualFolder vFolder = vc.getRootFolder();
        IModuleResource[] mr = getMembers(vFolder, Path.EMPTY);
        int size = mr.length;
        for (int j = 0; j < size; j++) {
            members.add(mr[j]);
        }
        addUtilMembers(vc);
    }
    IModuleResource[] mr = new IModuleResource[members.size()];
    members.toArray(mr);
    return mr;
}
Also used : IModuleResource(org.eclipse.wst.server.core.model.IModuleResource) IVirtualFolder(org.eclipse.wst.common.componentcore.resources.IVirtualFolder) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent)

Example 28 with IVirtualComponent

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

the class ModuleCoreSupportDelegate method getWebContentRootPath.

/**
 * @param project
 * @return the IPath to the "root" of the web contents
 */
static IPath getWebContentRootPath(IProject project) {
    if (project == null)
        return null;
    if (!ModuleCoreNature.isFlexibleProject(project))
        return null;
    IPath path = null;
    IVirtualComponent component = ComponentCore.createComponent(project);
    if (component != null && component.exists()) {
        path = component.getRootFolder().getWorkspaceRelativePath();
    }
    return path;
}
Also used : IPath(org.eclipse.core.runtime.IPath) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent)

Example 29 with IVirtualComponent

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

the class StaticWebDeployableObjectAdapterUtil method getModuleObject.

public static IModuleArtifact getModuleObject(Object obj) {
    IResource resource = null;
    if (obj instanceof IResource)
        resource = (IResource) obj;
    else if (obj instanceof IAdaptable)
        resource = ((IAdaptable) obj).getAdapter(IResource.class);
    if (resource == null)
        return null;
    if (resource instanceof IProject) {
        IProject project = (IProject) resource;
        if (hasInterestedComponents(project))
            // $NON-NLS-1$
            return new WebResource(getModule(project), new Path(""));
        return null;
    }
    IProject project = ProjectUtilities.getProject(resource);
    if (project != null && !hasInterestedComponents(project))
        return null;
    IVirtualComponent comp = ComponentCore.createComponent(project);
    // determine path
    IPath rootPath = comp.getRootFolder().getProjectRelativePath();
    IPath resourcePath = resource.getProjectRelativePath();
    // Check to make sure the resource is under the webApplication directory
    if (resourcePath.matchingFirstSegments(rootPath) != rootPath.segmentCount())
        return null;
    // Do not allow resource under the web-inf directory
    resourcePath = resourcePath.removeFirstSegments(rootPath.segmentCount());
    if (resourcePath.segmentCount() > 1 && resourcePath.segment(0).equals(INFO_DIRECTORY))
        return null;
    if (shouldExclude(resource))
        return null;
    // return Web resource type
    return new WebResource(getModule(project), resourcePath);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IAdaptable(org.eclipse.core.runtime.IAdaptable) IPath(org.eclipse.core.runtime.IPath) WebResource(org.eclipse.wst.server.core.util.WebResource) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

Example 30 with IVirtualComponent

use of org.eclipse.wst.common.componentcore.resources.IVirtualComponent in project liferay-ide by liferay.

the class PluginClasspathContainer method lookupPluginPackageFile.

protected IFile lookupPluginPackageFile() {
    IVirtualComponent component = ComponentCore.createComponent(javaProject.getProject());
    if (component == null) {
        return null;
    }
    IContainer resource = component.getRootFolder().getUnderlyingFolder();
    if (!(resource instanceof IFolder)) {
        return null;
    }
    IFolder webroot = (IFolder) resource;
    IFile pluginPackageFile = webroot.getFile("WEB-INF/" + ILiferayConstants.LIFERAY_PLUGIN_PACKAGE_PROPERTIES_FILE);
    /*
		 * IDE-226 the file may be missing because we are in an ext plugin which has a different layout
		 * check for ext-web in the path to the docroot
		 */
    String webrootFullPath = webroot.getFullPath().toPortableString();
    if (!pluginPackageFile.exists() && webrootFullPath.endsWith("WEB-INF/ext-web/docroot")) {
        // look for packages file in first docroot
        IPath path = webroot.getFullPath().removeFirstSegments(1);
        IPath parentDocroot = path.removeLastSegments(3);
        IFolder parentWebroot = javaProject.getProject().getFolder(parentDocroot);
        if (parentWebroot.exists()) {
            pluginPackageFile = parentWebroot.getFile("WEB-INF/" + ILiferayConstants.LIFERAY_PLUGIN_PACKAGE_PROPERTIES_FILE);
        }
    }
    return pluginPackageFile;
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent) IContainer(org.eclipse.core.resources.IContainer) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

IVirtualComponent (org.eclipse.wst.common.componentcore.resources.IVirtualComponent)39 IPath (org.eclipse.core.runtime.IPath)24 IVirtualFolder (org.eclipse.wst.common.componentcore.resources.IVirtualFolder)12 IVirtualReference (org.eclipse.wst.common.componentcore.resources.IVirtualReference)11 IProject (org.eclipse.core.resources.IProject)9 ArrayList (java.util.ArrayList)8 IContainer (org.eclipse.core.resources.IContainer)7 IFile (org.eclipse.core.resources.IFile)6 IFolder (org.eclipse.core.resources.IFolder)6 Path (org.eclipse.core.runtime.Path)6 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)5 CoreException (org.eclipse.core.runtime.CoreException)5 IVirtualResource (org.eclipse.wst.common.componentcore.resources.IVirtualResource)5 Test (org.junit.Test)5 JavaModelException (org.eclipse.jdt.core.JavaModelException)4 List (java.util.List)3 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 IOException (java.io.IOException)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2