Search in sources :

Example 6 with ComponentResource

use of org.eclipse.wst.common.componentcore.internal.ComponentResource in project mdw-designer by CenturyLinkCloud.

the class ProjectConfigurator method addDeploymentAssemblyResourceMappings.

@SuppressWarnings("unchecked")
public boolean addDeploymentAssemblyResourceMappings(IFolder folder) {
    StructureEdit moduleCore = null;
    try {
        moduleCore = StructureEdit.getStructureEditForWrite(project.getSourceProject());
        if (moduleCore != null) {
            ComponentResource found = null;
            for (Object o : moduleCore.getComponent().getResources()) {
                ComponentResource resource = (ComponentResource) o;
                if (("/" + folder.getProjectRelativePath()).equals(resource.getSourcePath().toString()))
                    found = resource;
            }
            if (found == null) {
                ComponentResource componentResource = moduleCore.createWorkbenchModuleResource(folder);
                componentResource.setRuntimePath(new Path("/"));
                moduleCore.getComponent().getResources().add(componentResource);
            }
        }
    } finally {
        if (moduleCore != null) {
            moduleCore.saveIfNecessary(new NullProgressMonitor());
            moduleCore.dispose();
        }
    }
    return true;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ComponentResource(org.eclipse.wst.common.componentcore.internal.ComponentResource) StructureEdit(org.eclipse.wst.common.componentcore.internal.StructureEdit)

Aggregations

ComponentResource (org.eclipse.wst.common.componentcore.internal.ComponentResource)6 IPath (org.eclipse.core.runtime.IPath)5 Path (org.eclipse.core.runtime.Path)5 HashMap (java.util.HashMap)4 Iterator (java.util.Iterator)4 LinkedHashMap (java.util.LinkedHashMap)4 List (java.util.List)4 Map (java.util.Map)4 IProject (org.eclipse.core.resources.IProject)4 IResource (org.eclipse.core.resources.IResource)4 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)4 IJavaProject (org.eclipse.jdt.core.IJavaProject)4 IFolder (org.eclipse.core.resources.IFolder)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 IClasspathAttribute (org.eclipse.jdt.core.IClasspathAttribute)2 StructureEdit (org.eclipse.wst.common.componentcore.internal.StructureEdit)2