use of org.eclipse.wst.common.componentcore.resources.IVirtualFolder in project liferay-ide by liferay.
the class FlexibleProject method _getDefaultDocroot.
private static IFolder _getDefaultDocroot(IProject project) {
IVirtualFolder webappRoot = _getVirtualDocroot(project);
if (webappRoot == null) {
return null;
}
try {
IPath defaultFolder = J2EEModuleVirtualComponent.getDefaultDeploymentDescriptorFolder(webappRoot);
if (defaultFolder == null) {
return null;
}
IFolder folder = project.getFolder(defaultFolder);
if (folder.exists()) {
return folder;
}
} catch (Exception e) {
ProjectCore.logError("Could not determine default docroot", e);
}
return null;
}
use of org.eclipse.wst.common.componentcore.resources.IVirtualFolder in project liferay-ide by liferay.
the class PluginFacetInstall method configureDeploymentAssembly.
protected void configureDeploymentAssembly(String srcPath, String deployPath) {
IVirtualComponent vProject = ComponentCore.createComponent(project);
IVirtualFolder vProjectFolder = vProject.getRootFolder();
IVirtualFolder deployFolder = vProjectFolder.getFolder(new Path(deployPath));
try {
deployFolder.createLink(new Path(srcPath), IResource.FORCE, null);
} catch (CoreException ce) {
ProjectCore.logError("Unable to create link", ce);
}
try {
IPath outputLocation = JavaCore.create(project).getOutputLocation();
vProject.setMetaProperty(IModuleConstants.PROJ_REL_JAVA_OUTPUT_PATH, outputLocation.toPortableString());
} catch (JavaModelException jme) {
ProjectCore.logError("Unable to set java-ouput-path", jme);
}
}
use of org.eclipse.wst.common.componentcore.resources.IVirtualFolder in project liferay-ide by liferay.
the class ProjectUtil method fixExtProjectSrcFolderLinks.
public static void fixExtProjectSrcFolderLinks(IProject extProject) throws JavaModelException {
if (extProject == null) {
return;
}
IJavaProject javaProject = JavaCore.create(extProject);
if (javaProject == null) {
return;
}
IVirtualComponent c = ComponentCore.createComponent(extProject, false);
if (c == null) {
return;
}
IVirtualFolder jsrc = c.getRootFolder().getFolder("/WEB-INF/classes");
if (jsrc == null) {
return;
}
IClasspathEntry[] cp = javaProject.getRawClasspath();
for (int i = 0; i < cp.length; i++) {
IClasspathEntry cpe = cp[i];
if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
IPath path = cpe.getPath().removeFirstSegments(1);
if (path.segmentCount() > 0) {
try {
IFolder srcFolder = CoreUtil.getWorkspaceRoot().getFolder(cpe.getPath());
IVirtualResource[] virtualResource = ComponentCore.createResources(srcFolder);
if (virtualResource.length == 0) {
jsrc.createLink(cpe.getPath().removeFirstSegments(1), 0, null);
}
} catch (Exception e) {
ProjectCore.logError(e);
}
}
}
}
}
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;
}
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;
}
Aggregations