Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 199229 | Differences between
and this patch

Collapse All | Expand All

(-)modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualResource.java (-11 / +17 lines)
Lines 243-265 Link Here
243
	public void setResourceType(String aResourceType) {
243
	public void setResourceType(String aResourceType) {
244
		resourceType = aResourceType; 
244
		resourceType = aResourceType; 
245
		WorkbenchComponent aComponent = getReadOnlyComponent();
245
		WorkbenchComponent aComponent = getReadOnlyComponent();
246
		ComponentResource[] resources = aComponent.findResourcesByRuntimePath(getRuntimePath());
246
		if (aComponent != null)	{
247
		for (int i = 0; i < resources.length; i++) {
247
			ComponentResource[] resources = aComponent.findResourcesByRuntimePath(getRuntimePath());
248
			resources[i].setResourceType(aResourceType);
248
			for (int i = 0; i < resources.length; i++) {
249
				resources[i].setResourceType(aResourceType);
250
			}
249
		}
251
		}
250
		 
251
	}
252
	}
252
253
253
	// TODO Fetch the resource type from the model.
254
	// TODO Fetch the resource type from the model.
254
	public String getResourceType() {
255
	public String getResourceType() {
255
		if (null == resourceType) { 
256
		if (null == resourceType) { 
256
			WorkbenchComponent aComponent = getReadOnlyComponent();
257
			WorkbenchComponent aComponent = getReadOnlyComponent();
257
			ComponentResource[] resources = aComponent.findResourcesByRuntimePath(getRuntimePath());
258
			if (aComponent != null)
258
			for (int i = 0; i < resources.length; i++) {
259
			{
259
				resourceType = resources[i].getResourceType();
260
				ComponentResource[] resources = aComponent
260
				return resourceType;
261
					.findResourcesByRuntimePath(getRuntimePath());
262
				if (resources.length > 0) {
263
					resourceType = resources[0].getResourceType();
264
					return resourceType;
265
				}
261
			}
266
			}
262
			 
263
		}
267
		}
264
		resourceType = ""; //$NON-NLS-1$
268
		resourceType = ""; //$NON-NLS-1$
265
		return resourceType;
269
		return resourceType;
Lines 314-321 Link Here
314
		WorkbenchComponent component = null;
318
		WorkbenchComponent component = null;
315
		try {
319
		try {
316
			moduleCore = StructureEdit.getStructureEditForRead(getProject());
320
			moduleCore = StructureEdit.getStructureEditForRead(getProject());
317
			component = moduleCore.getComponent();
321
			if (moduleCore != null) {
318
			mapping.mark(getProject(), component);
322
				component = moduleCore.getComponent();
323
				mapping.mark(getProject(), component);
324
			}	
319
		} finally {
325
		} finally {
320
			if (moduleCore != null) { 
326
			if (moduleCore != null) { 
321
				moduleCore.dispose();
327
				moduleCore.dispose();
(-)modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualContainer.java (-19 / +27 lines)
Lines 26-31 Link Here
26
import org.eclipse.core.runtime.IPath;
26
import org.eclipse.core.runtime.IPath;
27
import org.eclipse.core.runtime.IProgressMonitor;
27
import org.eclipse.core.runtime.IProgressMonitor;
28
import org.eclipse.core.runtime.Path;
28
import org.eclipse.core.runtime.Path;
29
import org.eclipse.jem.util.logger.proxy.Logger;
29
import org.eclipse.wst.common.componentcore.ComponentCore;
30
import org.eclipse.wst.common.componentcore.ComponentCore;
30
import org.eclipse.wst.common.componentcore.internal.ComponentResource;
31
import org.eclipse.wst.common.componentcore.internal.ComponentResource;
31
import org.eclipse.wst.common.componentcore.internal.StructureEdit;
32
import org.eclipse.wst.common.componentcore.internal.StructureEdit;
Lines 77-105 Link Here
77
		try {
78
		try {
78
79
79
			structureEdit = StructureEdit.getStructureEditForRead(getProject());
80
			structureEdit = StructureEdit.getStructureEditForRead(getProject());
80
			WorkbenchComponent component = structureEdit.getComponent();
81
			if (structureEdit != null)  // bug 199229
81
			if (null != component) {
82
				{
82
				ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(component);
83
				WorkbenchComponent component = structureEdit.getComponent();
83
				ComponentResource[] resources = root.findModuleResources(getRuntimePath().append(aPath), ResourceTreeNode.CREATE_NONE);
84
				if (null != component) 
84
85
					{
85
				for (int i = 0; i < resources.length; i++) {
86
					ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(component);
86
				// return the resources corresponding to the root, not any of the children if its a folder
87
					ComponentResource[] resources = root.findModuleResources(getRuntimePath().append(aPath), ResourceTreeNode.CREATE_NONE);
87
					if (resources[i].getRuntimePath().equals(getRuntimePath().append(aPath))) {
88
	
88
						IResource platformResource = getProject().findMember(resources[i].getSourcePath());
89
					for (int i = 0; i < resources.length; i++) 
89
						if (platformResource == null)
90
						{
90
							platformResource = ResourcesPlugin.getWorkspace().getRoot().findMember(resources[i].getSourcePath());
91
						// return the resources corresponding to the root, not any of the children if its a folder
91
						if (platformResource != null) {
92
						if (resources[i].getRuntimePath().equals(getRuntimePath().append(aPath))) {
92
							switch (platformResource.getType()) {
93
							IResource platformResource = getProject().findMember(resources[i].getSourcePath());
93
								case IResource.FOLDER :
94
							if (platformResource == null)
94
								case IResource.PROJECT :
95
								platformResource = ResourcesPlugin.getWorkspace().getRoot().findMember(resources[i].getSourcePath());
95
									return ComponentCore.createFolder(getProject(), getRuntimePath().append(aPath));
96
							if (platformResource != null) 
96
								case IResource.FILE :
97
								{
97
									return new VirtualFile(getProject(), getRuntimePath().append(aPath));
98
								switch (platformResource.getType()) 
99
									{
100
									case IResource.FOLDER :
101
									case IResource.PROJECT :
102
										return ComponentCore.createFolder(getProject(), getRuntimePath().append(aPath));
103
									case IResource.FILE :
104
										return new VirtualFile(getProject(), getRuntimePath().append(aPath));
105
									}
106
								}
98
							}
107
							}
99
						}
108
						}
100
					}
109
					}
101
				}
110
				}
102
			}
103
		} finally {
111
		} finally {
104
			if (structureEdit != null)
112
			if (structureEdit != null)
105
				structureEdit.dispose();
113
				structureEdit.dispose();

Return to bug 199229