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 });
}
}
}
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;
}
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;
}
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);
}
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;
}
Aggregations