*** empty log message ***
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualComponent.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualComponent.java
index 09d550f..b9da459 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualComponent.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualComponent.java
@@ -7,7 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- *******************************************************************************/
+ *******************************************************************************/
package org.eclipse.wst.common.componentcore.internal.resources;
import java.util.ArrayList;
@@ -44,40 +44,40 @@
public VirtualComponent(ComponentHandle aComponentHandle, IPath aRuntimePath) {
super(aComponentHandle, aRuntimePath);
}
-
+
public IVirtualComponent getComponent() {
return this;
}
-
+
public String getName() {
return getComponentHandle().getName();
}
-
- public boolean exists() {
+
+ public boolean exists() {
StructureEdit core = null;
try {
if (getProject() != null && getName() != null) {
core = StructureEdit.getStructureEditForRead(getProject());
- WorkbenchComponent component = core.findComponentByName(getName());
+ WorkbenchComponent component = core.findComponentByName(getName());
return component != null;
}
} finally {
- if(core != null)
+ if (core != null)
core.dispose();
}
return false;
}
-
- public String getComponentTypeId() {
+
+ public String getComponentTypeId() {
StructureEdit core = null;
try {
core = StructureEdit.getStructureEditForRead(getProject());
- WorkbenchComponent component = core.findComponentByName(getName());
+ WorkbenchComponent component = core.findComponentByName(getName());
ComponentType cType = component.getComponentType();
- return cType != null ? cType.getComponentTypeId() : "";
+ return cType != null ? cType.getComponentTypeId() : "";
} finally {
- if(core != null)
+ if (core != null)
core.dispose();
}
}
@@ -87,15 +87,15 @@
StructureEdit core = null;
try {
core = StructureEdit.getStructureEditForWrite(getProject());
- WorkbenchComponent component = core.findComponentByName(getName());
+ WorkbenchComponent component = core.findComponentByName(getName());
ComponentType cType = component.getComponentType();
- if(cType != null) {
+ if (cType != null) {
cType = ComponentcorePackage.eINSTANCE.getComponentcoreFactory().createComponentType();
component.setComponentType(cType);
}
cType.setComponentTypeId(aComponentTypeId);
} finally {
- if(core != null) {
+ if (core != null) {
core.saveIfNecessary(null);
core.dispose();
}
@@ -103,25 +103,25 @@
}
public Properties getMetaProperties() {
- StructureEdit core = null;
- try {
- core = StructureEdit.getStructureEditForRead(getProject());
- WorkbenchComponent component = core.findComponentByName(getName());
- ComponentType cType = component.getComponentType();
- Properties props = new Properties();
- if(cType != null) {
- List propList = cType.getProperties();
- if(propList != null) {
- for (int i = 0; i < propList.size(); i++) {
- props.setProperty(((Property)propList.get(i)).getName(), ((Property)propList.get(i)).getValue());
- }
- }
- }
- return props;
- } finally {
- if(core != null)
- core.dispose();
- }
+ StructureEdit core = null;
+ try {
+ core = StructureEdit.getStructureEditForRead(getProject());
+ WorkbenchComponent component = core.findComponentByName(getName());
+ ComponentType cType = component.getComponentType();
+ Properties props = new Properties();
+ if (cType != null) {
+ List propList = cType.getProperties();
+ if (propList != null) {
+ for (int i = 0; i < propList.size(); i++) {
+ props.setProperty(((Property) propList.get(i)).getName(), ((Property) propList.get(i)).getValue());
+ }
+ }
+ }
+ return props;
+ } finally {
+ if (core != null)
+ core.dispose();
+ }
}
public IPath[] getMetaResources() {
@@ -133,7 +133,7 @@
// TODO Auto-generated method stub
}
-
+
public IVirtualResource[] getResources(String aResourceType) {
StructureEdit core = null;
try {
@@ -141,100 +141,102 @@
WorkbenchComponent component = core.findComponentByName(getName());
List currentResources = component.getResources();
List foundResources = new ArrayList();
-
- for (Iterator iter = currentResources.iterator(); iter.hasNext();) {
- ComponentResource resource = (ComponentResource) iter.next();
- if(aResourceType == null || aResourceType.equals(resource.getResourceType())) {
- IVirtualResource vres = createVirtualResource(resource);
- if(vres != null)
- foundResources.add(vres);
+
+ if (aResourceType != null) {
+ for (Iterator iter = currentResources.iterator(); iter.hasNext();) {
+ ComponentResource resource = (ComponentResource) iter.next();
+ if (aResourceType.equals(resource.getResourceType())) {
+ IVirtualResource vres = createVirtualResource(resource);
+ if (vres != null)
+ foundResources.add(vres);
+ }
}
-
}
return (IVirtualResource[]) foundResources.toArray(new IVirtualResource[foundResources.size()]);
} finally {
- if(core != null)
+ if (core != null)
core.dispose();
}
}
private IVirtualResource createVirtualResource(ComponentResource aComponentResource) {
IResource resource = StructureEdit.getEclipseResource(aComponentResource);
- switch(resource.getType()) {
- case IResource.FILE:
+ switch (resource.getType()) {
+ case IResource.FILE :
return ComponentCore.createFile(getProject(), getName(), aComponentResource.getRuntimePath());
- case IResource.FOLDER:
+ case IResource.FOLDER :
return ComponentCore.createFolder(getProject(), getName(), aComponentResource.getRuntimePath());
}
return null;
}
- public IVirtualReference[] getReferences() {
+ public IVirtualReference[] getReferences() {
StructureEdit core = null;
try {
core = StructureEdit.getStructureEditForRead(getProject());
WorkbenchComponent component = core.findComponentByName(getName());
List referencedComponents = component.getReferencedComponents();
ReferencedComponent referencedComponent = null;
-
+
List references = new ArrayList();
IVirtualComponent targetComponent = null;
IProject targetProject = null;
String targetComponentName = null;
for (Iterator iter = referencedComponents.iterator(); iter.hasNext();) {
referencedComponent = (ReferencedComponent) iter.next();
- try {
+ try {
targetProject = StructureEdit.getContainingProject(referencedComponent.getHandle());
- } catch(UnresolveableURIException uurie) { }
+ } catch (UnresolveableURIException uurie) {
+ }
// if the project cannot be resolved, assume it's local
- if(targetProject == null)
+ if (targetProject == null)
targetProject = getProject();
-
+
try {
targetComponentName = StructureEdit.getDeployedName(referencedComponent.getHandle());
- targetComponent = ComponentCore.createComponent(targetProject, targetComponentName);
+ targetComponent = ComponentCore.createComponent(targetProject, targetComponentName);
references.add(new VirtualReference(this, targetComponent, referencedComponent.getRuntimePath(), referencedComponent.getDependencyType().getValue()));
-
- } catch (UnresolveableURIException e) {
+
+ } catch (UnresolveableURIException e) {
}
-
+
}
-
+
return (IVirtualReference[]) references.toArray(new IVirtualReference[references.size()]);
} finally {
- if(core != null)
+ if (core != null)
core.dispose();
- }
+ }
}
- public void setReferences(IVirtualReference[] references) {
+ public void setReferences(IVirtualReference[] references) {
StructureEdit core = null;
try {
core = StructureEdit.getStructureEditForWrite(getProject());
WorkbenchComponent component = core.findComponentByName(getName());
List referencedComponents = component.getReferencedComponents();
ReferencedComponent referencedComponent = null;
-
+
component.getReferencedComponents().clear();
ComponentcoreFactory factory = ComponentcorePackage.eINSTANCE.getComponentcoreFactory();
- for (int i=0; i<references.length; i++) {
- referencedComponent = factory.createReferencedComponent();
+ for (int i = 0; i < references.length; i++) {
+ referencedComponent = factory.createReferencedComponent();
referencedComponent.setDependencyType(DependencyType.get(references[i].getDependencyType()));
referencedComponent.setRuntimePath(references[i].getRuntimePath());
referencedComponent.setHandle(ModuleURIUtil.fullyQualifyURI(references[i].getReferencedComponent().getProject(), references[i].getReferencedComponent().getName()));
component.getReferencedComponents().add(referencedComponent);
}
-
+
} finally {
- if(core != null) {
+ if (core != null) {
core.saveIfNecessary(null);
core.dispose();
}
- }
+ }
}
-
- public boolean equals(Object anOther) {
- if(anOther instanceof IVirtualComponent) {
+
+ public boolean equals(Object anOther) {
+ if (anOther instanceof IVirtualComponent) {
IVirtualComponent otherComponent = (IVirtualComponent) anOther;
return getProject().equals(otherComponent.getProject()) && getName().equals(otherComponent.getName());
}
@@ -251,18 +253,18 @@
return null;
}
- public String getVersion(){
+ public String getVersion() {
StructureEdit core = null;
try {
core = StructureEdit.getStructureEditForRead(getProject());
- WorkbenchComponent component = core.findComponentByName(getName());
+ WorkbenchComponent component = core.findComponentByName(getName());
ComponentType compType = component.getComponentType();
- if( compType != null)
+ if (compType != null)
return compType.getVersion();
} finally {
- if(core != null)
+ if (core != null)
core.dispose();
-}
+ }
return "";
}
}