use of org.eclipse.wst.common.componentcore.internal.StructureEdit in project liferay-ide by liferay.
the class LiferayMavenProjectConfigurator method configureDeployedName.
protected void configureDeployedName(IProject project, String deployedFileName) {
// We need to remove the file extension from deployedFileName
int extSeparatorPos = deployedFileName.lastIndexOf('.');
String deployedName = extSeparatorPos > -1 ? deployedFileName.substring(0, extSeparatorPos) : deployedFileName;
// From jerr's patch in MNGECLIPSE-965
IVirtualComponent projectComponent = ComponentCore.createComponent(project);
if ((projectComponent != null) && !deployedName.equals(projectComponent.getDeployedName())) {
// MNGECLIPSE-2331 :
// Seems
// projectComponent.getDeployedName()
// can be null
StructureEdit moduleCore = null;
try {
moduleCore = StructureEdit.getStructureEditForWrite(project);
if (moduleCore != null) {
WorkbenchComponent component = moduleCore.getComponent();
if (component != null) {
component.setName(deployedName);
moduleCore.saveIfNecessary(null);
}
}
} finally {
if (moduleCore != null) {
moduleCore.dispose();
}
}
}
}
use of org.eclipse.wst.common.componentcore.internal.StructureEdit in project webtools.servertools by eclipse.
the class ModuleTraverser method traverseWebComponent.
private static void traverseWebComponent(IVirtualComponent component, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException {
visitor.visitWebComponent(component);
IProject proj = component.getProject();
StructureEdit warStruct = StructureEdit.getStructureEditForRead(proj);
try {
WorkbenchComponent comp = warStruct.getComponent();
if (comp == null) {
Trace.trace(Trace.SEVERE, "Error getting WorkbenchComponent from war project. IProject=\"" + proj + "\" StructureEdit=\"" + warStruct + "\" WorkbenchComponent=\"" + comp + "\"");
return;
}
traverseWebComponentLocalEntries(comp, visitor, monitor);
// traverse referenced components
List children = comp.getReferencedComponents();
for (Iterator itor = children.iterator(); itor.hasNext(); ) {
ReferencedComponent childRef = (ReferencedComponent) itor.next();
IPath rtFolder = childRef.getRuntimePath();
URI refHandle = childRef.getHandle();
if (PlatformURLModuleConnection.CLASSPATH.equals(refHandle.segment(ModuleURIUtil.ModuleURI.SUB_PROTOCOL_INDX))) {
IPath refPath = getResolvedPathForArchiveComponent(refHandle);
// If an archive component, add to list
if (refPath != null) {
if (!refPath.isAbsolute()) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(refPath);
IPath refPath2 = file.getLocation();
if (refPath2 != null) {
visitor.visitArchiveComponent(rtFolder, refPath2);
} else {
Trace.trace(Trace.WARNING, NLS.bind("Could not get the location of a referenced component. It may not exist. Project={0}, Parent Component={1}, Referenced Component Path={2}", new Object[] { proj.getName(), comp.getName(), refPath }));
}
} else {
visitor.visitArchiveComponent(rtFolder, refPath);
}
} else {
// TODO Determine if any use case would arrive here.
}
} else {
try {
WorkbenchComponent childCom = warStruct.findComponentByURI(refHandle);
if (childCom == null) {
continue;
}
traverseDependentEntries(visitor, rtFolder, childCom, monitor);
} catch (UnresolveableURIException e) {
TomcatPlugin.log(e);
}
}
}
} finally {
warStruct.dispose();
}
visitor.endVisitWebComponent(component);
}
use of org.eclipse.wst.common.componentcore.internal.StructureEdit 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.StructureEdit in project liferay-ide by liferay.
the class ModuleTraverser method traverseWebComponent.
private static void traverseWebComponent(IVirtualComponent component, IModuleVisitor visitor, IProgressMonitor monitor) throws CoreException {
visitor.visitWebComponent(component);
IProject proj = component.getProject();
StructureEdit warStruct = StructureEdit.getStructureEditForRead(proj);
try {
WorkbenchComponent comp = warStruct.getComponent();
if (comp == null) {
// + "\" WorkbenchComponent=\"" + comp + "\""); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
traverseWebComponentLocalEntries(comp, visitor, monitor);
// traverse referenced components
List children = comp.getReferencedComponents();
for (Iterator itor = children.iterator(); itor.hasNext(); ) {
ReferencedComponent childRef = (ReferencedComponent) itor.next();
IPath rtFolder = childRef.getRuntimePath();
URI refHandle = childRef.getHandle();
if (PlatformURLModuleConnection.CLASSPATH.equals(refHandle.segment(ModuleURIUtil.ModuleURI.SUB_PROTOCOL_INDX))) {
IPath refPath = getResolvedPathForArchiveComponent(refHandle);
// If an archive component, add to list
if (refPath != null) {
if (!refPath.isAbsolute()) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(refPath);
IPath refPath2 = file.getLocation();
if (refPath2 != null) {
visitor.visitArchiveComponent(rtFolder, refPath2);
} else {
// Trace.trace(Trace.WARNING, NLS.bind(
// "Could not get the location of a referenced component. It may not exist. Project={0}, Parent Component={1}, Referenced Component Path={2}", //$NON-NLS-1$
// new Object[] { proj.getName(), comp.getName(), refPath}));
}
} else {
visitor.visitArchiveComponent(rtFolder, refPath);
}
} else {
// TODO Determine if any use case would arrive here.
}
} else {
try {
WorkbenchComponent childCom = warStruct.findComponentByURI(refHandle);
if (childCom == null) {
continue;
}
traverseDependentEntries(visitor, rtFolder, childCom, monitor);
} catch (UnresolveableURIException e) {
LiferayServerCore.logError(e);
}
}
}
} finally {
warStruct.dispose();
}
visitor.endVisitWebComponent(component);
}
use of org.eclipse.wst.common.componentcore.internal.StructureEdit 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;
}
Aggregations