use of org.eclipse.wst.common.componentcore.internal.ComponentResource in project liferay-ide by liferay.
the class ModuleTraverser method traverseWebComponentLocalEntries.
private static void traverseWebComponentLocalEntries(WorkbenchComponent comp, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException {
IProject warProject = StructureEdit.getContainingProject(comp);
if (warProject == null || !warProject.hasNature(JavaCore.NATURE_ID)) {
return;
}
IJavaProject project = JavaCore.create(warProject);
List res = comp.getResources();
for (Iterator itorRes = res.iterator(); itorRes.hasNext(); ) {
ComponentResource childComp = (ComponentResource) itorRes.next();
IClasspathEntry cpe = getClasspathEntry(project, childComp.getSourcePath());
if (cpe == null)
continue;
visitor.visitWebResource(childComp.getRuntimePath(), getOSPath(warProject, project, cpe.getOutputLocation()));
}
// Include tagged classpath entries
Map classpathDeps = getComponentClasspathDependencies(project, true);
for (Iterator iterator = classpathDeps.keySet().iterator(); iterator.hasNext(); ) {
IClasspathEntry entry = (IClasspathEntry) iterator.next();
IClasspathAttribute attrib = (IClasspathAttribute) classpathDeps.get(entry);
boolean isClassFolder = isClassFolderEntry(entry);
String rtFolder = attrib.getValue();
if (rtFolder == null) {
if (isClassFolder) {
// $NON-NLS-1$
rtFolder = "/WEB-INF/classes";
} else {
// $NON-NLS-1$
rtFolder = "/WEB-INF/lib";
}
}
IPath entryPath = entry.getPath();
IResource entryRes = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
if (entryRes != null) {
entryPath = entryRes.getLocation();
}
// TODO Determine if different handling is needed for some use cases
if (isClassFolder) {
visitor.visitWebResource(new Path(rtFolder), getOSPath(warProject, project, entry.getPath()));
} else {
visitor.visitArchiveComponent(new Path(rtFolder), entryPath);
}
}
}
use of org.eclipse.wst.common.componentcore.internal.ComponentResource in project webtools.servertools by eclipse.
the class ModuleTraverser method traverseWebComponentLocalEntries.
private static void traverseWebComponentLocalEntries(WorkbenchComponent comp, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException {
IProject warProject = StructureEdit.getContainingProject(comp);
if (warProject == null || !warProject.hasNature(JavaCore.NATURE_ID)) {
return;
}
IJavaProject project = JavaCore.create(warProject);
List res = comp.getResources();
for (Iterator itorRes = res.iterator(); itorRes.hasNext(); ) {
ComponentResource childComp = (ComponentResource) itorRes.next();
IClasspathEntry cpe = getClasspathEntry(project, childComp.getSourcePath());
if (cpe == null)
continue;
visitor.visitWebResource(childComp.getRuntimePath(), getOSPath(warProject, project, cpe.getOutputLocation()));
}
// Include tagged classpath entries
Map classpathDeps = getComponentClasspathDependencies(project, true);
for (Iterator iterator = classpathDeps.keySet().iterator(); iterator.hasNext(); ) {
IClasspathEntry entry = (IClasspathEntry) iterator.next();
IClasspathAttribute attrib = (IClasspathAttribute) classpathDeps.get(entry);
boolean isClassFolder = isClassFolderEntry(entry);
String rtFolder = attrib.getValue();
if (rtFolder == null) {
if (isClassFolder) {
rtFolder = "/WEB-INF/classes";
} else {
rtFolder = "/WEB-INF/lib";
}
}
IPath entryPath = entry.getPath();
IResource entryRes = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
if (entryRes != null) {
entryPath = entryRes.getLocation();
}
// TODO Determine if different handling is needed for some use cases
if (isClassFolder) {
visitor.visitWebResource(new Path(rtFolder), getOSPath(warProject, project, entry.getPath()));
} else {
visitor.visitArchiveComponent(new Path(rtFolder), entryPath);
}
}
}
use of org.eclipse.wst.common.componentcore.internal.ComponentResource in project mdw-designer by CenturyLinkCloud.
the class ProjectConfigurator method removeDeploymentAssemblyResourceMappings.
public boolean removeDeploymentAssemblyResourceMappings(IFolder folder) {
StructureEdit moduleCore = null;
try {
moduleCore = StructureEdit.getStructureEditForWrite(project.getSourceProject());
if (moduleCore != null && moduleCore.getComponent() != null && moduleCore.getComponent().getResources() != null) {
ComponentResource toRemove = null;
for (Object o : moduleCore.getComponent().getResources()) {
ComponentResource resource = (ComponentResource) o;
if (("/" + folder.getProjectRelativePath()).equals(resource.getSourcePath().toString()))
toRemove = resource;
}
if (toRemove != null)
moduleCore.getComponent().getResources().remove(toRemove);
}
} finally {
if (moduleCore != null) {
moduleCore.saveIfNecessary(new NullProgressMonitor());
moduleCore.dispose();
}
}
return true;
}
use of org.eclipse.wst.common.componentcore.internal.ComponentResource in project webtools.servertools by eclipse.
the class ModuleTraverser method traverseDependentEntries.
private static void traverseDependentEntries(IModuleVisitor visitor, IPath runtimeFolder, WorkbenchComponent component, IProgressMonitor monitor) throws CoreException {
IProject dependentProject = StructureEdit.getContainingProject(component);
if (!dependentProject.hasNature(JavaCore.NATURE_ID))
return;
IJavaProject project = JavaCore.create(dependentProject);
visitor.visitDependentJavaProject(project);
// assume it is the same as URI
String name = component.getName();
// go thru all entries
List res = component.getResources();
for (Iterator itorRes = res.iterator(); itorRes.hasNext(); ) {
ComponentResource childComp = (ComponentResource) itorRes.next();
IPath rtPath = childComp.getRuntimePath();
IPath srcPath = childComp.getSourcePath();
IClasspathEntry cpe = getClasspathEntry(project, srcPath);
if (cpe != null) {
visitor.visitDependentComponent(runtimeFolder.append(rtPath).append(name + ".jar"), getOSPath(dependentProject, project, cpe.getOutputLocation()));
}
// Handle META-INF/resources
String path = rtPath.toString();
IFolder resFolder = null;
String targetPath = "";
if ("/".equals(path)) {
resFolder = dependentProject.getFolder(srcPath.append("META-INF/resources"));
} else if ("/META-INF".equals(path)) {
resFolder = dependentProject.getFolder(srcPath.append("resources"));
} else if ("/META-INF/resources".equals(path)) {
resFolder = dependentProject.getFolder(srcPath);
} else if (path.startsWith("/META-INF/resources/")) {
resFolder = dependentProject.getFolder(srcPath);
targetPath = path.substring("/META-INF/resources".length());
}
if (resFolder != null && resFolder.exists()) {
visitor.visitDependentContentResource(new Path(targetPath), resFolder.getLocation());
}
}
// Include tagged classpath entries
Map classpathDeps = getComponentClasspathDependencies(project, false);
for (Iterator iterator = classpathDeps.keySet().iterator(); iterator.hasNext(); ) {
IClasspathEntry entry = (IClasspathEntry) iterator.next();
boolean isClassFolder = isClassFolderEntry(entry);
String rtFolder = null;
if (isClassFolder) {
rtFolder = "/";
} else {
rtFolder = "/WEB-INF/lib";
}
IPath entryPath = entry.getPath();
IResource entryRes = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
if (entryRes != null) {
entryPath = entryRes.getLocation();
}
// TODO Determine if different handling is needed for some use cases
if (isClassFolder) {
visitor.visitDependentComponent(runtimeFolder.append(rtFolder).append(name + ".jar"), getOSPath(dependentProject, project, entry.getPath()));
} else {
visitor.visitArchiveComponent(new Path(rtFolder), entryPath);
}
}
}
use of org.eclipse.wst.common.componentcore.internal.ComponentResource in project liferay-ide by liferay.
the class ModuleTraverser method traverseDependentEntries.
private static void traverseDependentEntries(IModuleVisitor visitor, IPath runtimeFolder, WorkbenchComponent component, IProgressMonitor monitor) throws CoreException {
IProject dependentProject = StructureEdit.getContainingProject(component);
if (!dependentProject.hasNature(JavaCore.NATURE_ID))
return;
IJavaProject project = JavaCore.create(dependentProject);
visitor.visitDependentJavaProject(project);
// assume it is the same as URI
String name = component.getName();
// go thru all entries
List res = component.getResources();
for (Iterator itorRes = res.iterator(); itorRes.hasNext(); ) {
ComponentResource childComp = (ComponentResource) itorRes.next();
IPath rtPath = childComp.getRuntimePath();
IPath srcPath = childComp.getSourcePath();
IClasspathEntry cpe = getClasspathEntry(project, srcPath);
if (cpe != null) {
visitor.visitDependentComponent(runtimeFolder.append(rtPath).append(name + ".jar"), getOSPath(// $NON-NLS-1$
dependentProject, project, cpe.getOutputLocation()));
}
// Handle META-INF/resources
String path = rtPath.toString();
IFolder resFolder = null;
String targetPath = StringPool.EMPTY;
if ("/".equals(path)) {
// $NON-NLS-1$
// $NON-NLS-1$
resFolder = dependentProject.getFolder(srcPath.append("META-INF/resources"));
} else if ("/META-INF".equals(path)) {
// $NON-NLS-1$
// $NON-NLS-1$
resFolder = dependentProject.getFolder(srcPath.append("resources"));
} else if ("/META-INF/resources".equals(path)) {
// $NON-NLS-1$
resFolder = dependentProject.getFolder(srcPath);
} else if (path.startsWith("/META-INF/resources/")) {
// $NON-NLS-1$
resFolder = dependentProject.getFolder(srcPath);
// $NON-NLS-1$
targetPath = path.substring("/META-INF/resources".length());
}
if (resFolder != null && resFolder.exists()) {
visitor.visitDependentContentResource(new Path(targetPath), resFolder.getLocation());
}
}
// Include tagged classpath entries
Map classpathDeps = getComponentClasspathDependencies(project, false);
for (Iterator iterator = classpathDeps.keySet().iterator(); iterator.hasNext(); ) {
IClasspathEntry entry = (IClasspathEntry) iterator.next();
boolean isClassFolder = isClassFolderEntry(entry);
String rtFolder = null;
if (isClassFolder) {
// $NON-NLS-1$
rtFolder = "/";
} else {
// $NON-NLS-1$
rtFolder = "/WEB-INF/lib";
}
IPath entryPath = entry.getPath();
IResource entryRes = ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath);
if (entryRes != null) {
entryPath = entryRes.getLocation();
}
// TODO Determine if different handling is needed for some use cases
if (isClassFolder) {
visitor.visitDependentComponent(runtimeFolder.append(rtFolder).append(name + ".jar"), getOSPath(// $NON-NLS-1$
dependentProject, project, entry.getPath()));
} else {
visitor.visitArchiveComponent(new Path(rtFolder), entryPath);
}
}
}
Aggregations