use of org.eclipse.wst.common.componentcore.resources.IVirtualFolder in project webtools.sourceediting by eclipse.
the class ModuleCoreSupportDelegate 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) {
/*
* It can take the better part of a full second to do this, so
* cache the result.
*/
IPath resolved = null;
Map mapForBaseResource = null;
mapForBaseResource = (Map) fResolvedMap.get(basePath);
if (mapForBaseResource != null) {
Reference resolvedReference = (Reference) mapForBaseResource.get(reference);
if (resolvedReference != null)
resolved = (IPath) resolvedReference.get();
} else {
mapForBaseResource = new HashMap();
fResolvedMap.put(basePath, mapForBaseResource);
}
if (resolved == null) {
IFile baseFile = ResourcesPlugin.getWorkspace().getRoot().getFile(basePath);
IVirtualResource[] virtualResources = ComponentCore.createResources(baseFile);
for (int i = 0; i < virtualResources.length; i++) {
IPath baseRuntimePath = virtualResources[i].getRuntimePath();
IPath referenceRuntimePath = null;
if (reference.startsWith(SLASH)) {
referenceRuntimePath = new Path(reference);
} else {
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].getProject().equals(project) && underlyingFiles[j].exists()) {
mapForBaseResource.put(reference, new SoftReference(underlyingFiles[j].getFullPath()));
resolved = underlyingFiles[j].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].getProject().equals(project) && underlyingFolders[j].isAccessible()) {
return underlyingFolders[j].getFullPath();
}
}
} else {
// check assembled projects
return resolveInReferenced(project, referenceRuntimePath);
}
}
}
}
return resolved;
} else {
IVirtualFile virtualFile = ComponentCore.createFile(project, new Path(reference));
if (virtualFile != null && virtualFile.exists()) {
return virtualFile.getUnderlyingFile().getFullPath();
}
}
return null;
}
use of org.eclipse.wst.common.componentcore.resources.IVirtualFolder in project liferay-ide by liferay.
the class FlexibleProject method getDescriptorFile.
@Override
public IFile getDescriptorFile(String name) {
IFile retval = null;
IFolder defaultDocrootFolder = getDefaultDocrootFolder();
if (FileUtil.exists(defaultDocrootFolder)) {
retval = defaultDocrootFolder.getFile(new Path("WEB-INF").append(name));
}
if (retval != null) {
return retval;
}
// fallback to looping through all virtual folders
IVirtualFolder webappRoot = _getVirtualDocroot(getProject());
if (webappRoot == null) {
return retval;
}
for (IContainer container : webappRoot.getUnderlyingFolders()) {
if (FileUtil.exists(container)) {
IFile descriptorFile = container.getFile(new Path("WEB-INF").append(name));
if (descriptorFile.exists()) {
retval = descriptorFile;
break;
}
}
}
return retval;
}
use of org.eclipse.wst.common.componentcore.resources.IVirtualFolder in project liferay-ide by liferay.
the class FlexibleProject method findDocrootResource.
@Override
public IResource findDocrootResource(IPath path) {
IVirtualFolder docroot = _getVirtualDocroot(getProject());
if (docroot == null) {
return null;
}
IVirtualResource virtualResource = docroot.findMember(path);
if ((virtualResource == null) || !virtualResource.exists()) {
return null;
}
for (IResource resource : virtualResource.getUnderlyingResources()) {
if (FileUtil.exists(resource) && resource instanceof IFile) {
return resource;
}
}
return null;
}
use of org.eclipse.wst.common.componentcore.resources.IVirtualFolder in project mdw-designer by CenturyLinkCloud.
the class WorkflowProject method getWebContentFolder.
public IFolder getWebContentFolder() {
IVirtualComponent webComponent = ComponentCore.createComponent(getWebProject());
IVirtualFolder webRootFolder = webComponent.getRootFolder();
return (IFolder) webRootFolder.getUnderlyingFolder();
}
Aggregations