Search in sources :

Example 11 with IVirtualFolder

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

the class SimpleWebFacetInstallDelegate method execute.

@Override
public void execute(IProject project, IProjectFacetVersion fv, Object config, IProgressMonitor monitor) throws CoreException {
    if (monitor != null)
        // $NON-NLS-1$
        monitor.beginTask("", 1);
    try {
        IDataModel model = (IDataModel) config;
        addNatures(project);
        final IVirtualComponent c = ComponentCore.createComponent(project, false);
        c.create(0, null);
        final IWorkspace ws = ResourcesPlugin.getWorkspace();
        final IPath pjpath = project.getFullPath();
        final IPath contentdir = setContentPropertyIfNeeded(model, pjpath, project);
        mkdirs(ws.getRoot().getFolder(contentdir));
        final IVirtualFolder webroot = c.getRootFolder();
        if (webroot.getProjectRelativePath().equals(new Path("/"))) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            webroot.createLink(new Path("/" + model.getStringProperty(ISimpleWebFacetInstallDataModelProperties.CONTENT_DIR)), 0, null);
        }
        ComponentUtilities.setServerContextRoot(project, model.getStringProperty(ISimpleWebFacetInstallDataModelProperties.CONTEXT_ROOT));
        try {
            ((IDataModelOperation) model.getProperty(FacetDataModelProvider.NOTIFICATION_OPERATION)).execute(monitor, null);
        } catch (ExecutionException e) {
            WSTWebPlugin.logError(e);
        }
    } finally {
        if (monitor != null)
            monitor.done();
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IWorkspace(org.eclipse.core.resources.IWorkspace) IVirtualFolder(org.eclipse.wst.common.componentcore.resources.IVirtualFolder) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent) ExecutionException(org.eclipse.core.commands.ExecutionException) IDataModelOperation(org.eclipse.wst.common.frameworks.datamodel.IDataModelOperation)

Example 12 with IVirtualFolder

use of org.eclipse.wst.common.componentcore.resources.IVirtualFolder in project mdw-designer by CenturyLinkCloud.

the class WorkflowProject method getEarContentFolder.

public IFolder getEarContentFolder() {
    if (isCloudProject()) {
        return getSourceProject().getFolder(new Path("deploy/ear"));
    } else // ear project
    {
        IVirtualComponent earComponent = ComponentCore.createComponent(getEarProject());
        if (earComponent == null)
            return null;
        IVirtualFolder earRootFolder = earComponent.getRootFolder();
        return (IFolder) earRootFolder.getUnderlyingFolder();
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IVirtualFolder(org.eclipse.wst.common.componentcore.resources.IVirtualFolder) IVirtualComponent(org.eclipse.wst.common.componentcore.resources.IVirtualComponent) IFolder(org.eclipse.core.resources.IFolder)

Example 13 with IVirtualFolder

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

the class ModuleSourcePathProvider method getDefaultSourcePaths.

public IIncludePathEntry[] getDefaultSourcePaths(IProject p) {
    if (ModuleCoreNature.isFlexibleProject(p)) {
        IVirtualFolder root = ComponentCore.createFolder(p, Path.ROOT);
        IResource[] underlyingResources = root.getUnderlyingResources();
        if (underlyingResources == null || underlyingResources.length == 0) {
            underlyingResources = new IResource[] { root.getUnderlyingResource() };
        }
        if (underlyingResources.length > 0 && underlyingResources[0] != null) {
            IPath[] paths = new IPath[underlyingResources.length];
            for (int i = 0; i < underlyingResources.length; i++) {
                paths[i] = underlyingResources[i].getFullPath();
            }
            if (paths.length > 0) {
                IIncludePathEntry[] entries = new IIncludePathEntry[paths.length];
                for (int i = 0; i < paths.length; i++) {
                    entries[i] = JavaScriptCore.newSourceEntry(paths[i]);
                }
                return entries;
            }
        }
    }
    return new IIncludePathEntry[] { JavaScriptCore.newSourceEntry(p.getFullPath(), ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null, new IIncludePathAttribute[] { JavaScriptCore.newIncludepathAttribute(PROVIDER_ATTRIBUTE_KEY_NAME, PROVIDER_ATTRIBUTE_KEY_VALUE) }) };
}
Also used : IPath(org.eclipse.core.runtime.IPath) IIncludePathEntry(org.eclipse.wst.jsdt.core.IIncludePathEntry) IVirtualFolder(org.eclipse.wst.common.componentcore.resources.IVirtualFolder) IResource(org.eclipse.core.resources.IResource)

Example 14 with IVirtualFolder

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

the class FacetModuleCoreSupportDelegate method resolve.

/**
 * @param basePath -
 *            the full path to a resource within the workspace
 * @param reference -
 *            the reference string to resolve
 * @return - the full path within the workspace that corresponds to the
 *         given reference according to the virtual pathing support
 */
static IPath resolve(IPath basePath, String reference) {
    if (reference == null || basePath == null || basePath.segmentCount() == 0)
        return null;
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(basePath.segment(0));
    if (!ModuleCoreNature.isFlexibleProject(project))
        return null;
    if (basePath.segmentCount() > 1) {
        IResource baseResource = ResourcesPlugin.getWorkspace().getRoot().findMember(basePath);
        if (baseResource != null) {
            IVirtualResource[] virtualResources = ComponentCore.createResources(baseResource);
            for (int i = 0; i < virtualResources.length; i++) {
                IPath referenceRuntimePath = null;
                if (reference.startsWith(SLASH)) {
                    referenceRuntimePath = new Path(reference);
                } else {
                    IPath baseRuntimePath = virtualResources[i].getRuntimePath();
                    referenceRuntimePath = baseRuntimePath.removeLastSegments(1).append(reference);
                }
                IVirtualFile virtualFile = ComponentCore.createFile(project, referenceRuntimePath);
                if (virtualFile != null && virtualFile.exists()) {
                    IFile[] underlyingFiles = virtualFile.getUnderlyingFiles();
                    for (int j = 0; j < underlyingFiles.length; j++) {
                        if (underlyingFiles[j].isAccessible()) {
                            return underlyingFiles[j].getFullPath();
                        }
                    }
                    if (underlyingFiles.length > 0) {
                        return underlyingFiles[0].getFullPath();
                    }
                } else {
                    // http://bugs.eclipse.org/338751
                    IVirtualFolder virtualFolder = ComponentCore.createFolder(project, referenceRuntimePath);
                    if (virtualFolder != null && virtualFolder.exists()) {
                        IContainer[] underlyingFolders = virtualFolder.getUnderlyingFolders();
                        for (int j = 0; j < underlyingFolders.length; j++) {
                            if (underlyingFolders[j].isAccessible()) {
                                return underlyingFolders[j].getFullPath();
                            }
                        }
                        if (underlyingFolders.length > 0) {
                            return underlyingFolders[0].getFullPath();
                        }
                    } else {
                        // check assembled projects
                        return resolveInReferenced(project, referenceRuntimePath);
                    }
                }
            }
        }
    } else {
        IVirtualFile virtualFile = ComponentCore.createFile(project, new Path(reference));
        if (virtualFile != null && virtualFile.exists()) {
            return virtualFile.getUnderlyingFile().getFullPath();
        }
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IVirtualFolder(org.eclipse.wst.common.componentcore.resources.IVirtualFolder) IVirtualResource(org.eclipse.wst.common.componentcore.resources.IVirtualResource) IProject(org.eclipse.core.resources.IProject) IVirtualFile(org.eclipse.wst.common.componentcore.resources.IVirtualFile) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource)

Example 15 with IVirtualFolder

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

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