cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2003, 2004 IBM Corporation and others. |
| 3 | * All rights reserved. This program and the accompanying materials |
| 4 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 | * which accompanies this distribution, and is available at |
| 6 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 | * |
| 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 10 | *******************************************************************************/ |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 11 | package org.eclipse.wst.common.componentcore.internal.resources; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 12 | |
| 13 | import java.util.Arrays; |
| 14 | |
cbridgha | 2550120 | 2005-03-30 23:45:41 +0000 | [diff] [blame] | 15 | import org.eclipse.core.resources.IContainer; |
| 16 | import org.eclipse.core.resources.IFolder; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 17 | import org.eclipse.core.resources.IProject; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 18 | import org.eclipse.core.resources.IResource; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 19 | import org.eclipse.core.runtime.CoreException; |
| 20 | import org.eclipse.core.runtime.IPath; |
| 21 | import org.eclipse.core.runtime.IProgressMonitor; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 22 | import org.eclipse.core.runtime.jobs.ISchedulingRule; |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 23 | import org.eclipse.wst.common.componentcore.ComponentCore; |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 24 | import org.eclipse.wst.common.componentcore.internal.ComponentResource; |
vbhadrir | 58634cb | 2005-04-25 20:28:18 +0000 | [diff] [blame] | 25 | import org.eclipse.wst.common.componentcore.internal.StructureEdit; |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 26 | import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; |
cbridgha | b75aee9 | 2005-05-18 03:02:33 +0000 | [diff] [blame] | 27 | import org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeNode; |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 28 | import org.eclipse.wst.common.componentcore.internal.impl.ResourceTreeRoot; |
cbridgha | 4bfee8b | 2005-04-25 20:00:22 +0000 | [diff] [blame] | 29 | import org.eclipse.wst.common.componentcore.resources.ComponentHandle; |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 30 | import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; |
| 31 | import org.eclipse.wst.common.componentcore.resources.IVirtualContainer; |
| 32 | import org.eclipse.wst.common.componentcore.resources.IVirtualResource; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 33 | |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 34 | public abstract class VirtualResource implements IVirtualResource { |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 35 | |
cbridgha | 2550120 | 2005-03-30 23:45:41 +0000 | [diff] [blame] | 36 | protected static final IResource[] NO_RESOURCES = null; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 37 | private ComponentHandle componentHandle; |
| 38 | private IPath runtimePath; |
| 39 | private int hashCode; |
| 40 | private String toString; |
cbridgha | 1686f44 | 2005-03-29 20:48:41 +0000 | [diff] [blame] | 41 | private static final String EMPTY_STRING = ""; //$NON-NLS-1$ |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 42 | private IVirtualComponent component; |
cbridgha | 4da5ee7 | 2005-04-14 14:27:50 +0000 | [diff] [blame] | 43 | private String resourceType; |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 44 | |
| 45 | |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 46 | protected VirtualResource(ComponentHandle aComponentHandle, IPath aRuntimePath) { |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 47 | componentHandle = aComponentHandle; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 48 | runtimePath = aRuntimePath; |
| 49 | } |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 50 | |
| 51 | |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 52 | protected VirtualResource(IProject aProject, String aComponentName, IPath aRuntimePath) { |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 53 | this(ComponentHandle.create(aProject, aComponentName), aRuntimePath); |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 54 | } |
| 55 | |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 56 | public void delete(int updateFlags, IProgressMonitor monitor) throws CoreException { |
| 57 | |
| 58 | if ((updateFlags & IVirtualResource.IGNORE_UNDERLYING_RESOURCE) == 0) { |
| 59 | doDeleteRealResources(updateFlags, monitor); |
| 60 | } |
| 61 | |
| 62 | doDeleteMetaModel(updateFlags, monitor); |
| 63 | } |
| 64 | |
| 65 | protected void doDeleteMetaModel(int updateFlags, IProgressMonitor monitor) { |
| 66 | StructureEdit moduleCore = null; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 67 | try { |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 68 | moduleCore = StructureEdit.getStructureEditForWrite(getComponentHandle().getProject()); |
| 69 | WorkbenchComponent component = moduleCore.findComponentByName(getComponentHandle().getName()); |
cbridgha | fbd0abb | 2005-04-14 04:44:09 +0000 | [diff] [blame] | 70 | ComponentResource[] resources = component.findResourcesByRuntimePath(getRuntimePath()); |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 71 | component.getResources().removeAll(Arrays.asList(resources)); |
| 72 | } finally { |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 73 | if (moduleCore != null) { |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 74 | moduleCore.saveIfNecessary(monitor); |
| 75 | moduleCore.dispose(); |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | |
| 81 | protected abstract void doDeleteRealResources(int updateFlags, IProgressMonitor monitor) throws CoreException; |
| 82 | |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 83 | public boolean exists() { |
cbridgha | 338cd8f | 2005-04-19 20:03:12 +0000 | [diff] [blame] | 84 | IResource resource = getUnderlyingResource(); |
| 85 | return resource != null && resource.exists(); |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 86 | } |
| 87 | |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 88 | public String getFileExtension() { |
cbridgha | 1686f44 | 2005-03-29 20:48:41 +0000 | [diff] [blame] | 89 | String name = getName(); |
| 90 | int dot = name.lastIndexOf('.'); |
| 91 | if (dot == -1) |
| 92 | return null; |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 93 | if (dot == name.length() - 1) |
| 94 | return EMPTY_STRING; |
| 95 | return name.substring(dot + 1); |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 96 | } |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 97 | |
cbridgha | 10e8223 | 2005-03-28 14:33:24 +0000 | [diff] [blame] | 98 | public IPath getWorkspaceRelativePath() { |
cbridgha | 1686f44 | 2005-03-29 20:48:41 +0000 | [diff] [blame] | 99 | return getProject().getFullPath().append(getProjectRelativePath()); |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 100 | } |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 101 | |
cbridgha | 1686f44 | 2005-03-29 20:48:41 +0000 | [diff] [blame] | 102 | public IPath getRuntimePath() { |
| 103 | return runtimePath; |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 104 | } |
| 105 | |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 106 | public IPath getProjectRelativePath() { |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 107 | StructureEdit moduleCore = null; |
cbridgha | 17f4e1d | 2005-03-28 19:41:04 +0000 | [diff] [blame] | 108 | try { |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 109 | moduleCore = StructureEdit.getStructureEditForRead(getProject()); |
| 110 | WorkbenchComponent component = moduleCore.findComponentByName(getComponentHandle().getName()); |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 111 | if (component != null) { |
cbridgha | fe83b0c | 2005-04-19 19:54:55 +0000 | [diff] [blame] | 112 | ResourceTreeRoot root = ResourceTreeRoot.getDeployResourceTreeRoot(component); |
cbridgha | 4c640c5 | 2005-04-25 16:03:19 +0000 | [diff] [blame] | 113 | // still need some sort of loop here to search subpieces of the runtime path. |
| 114 | ComponentResource[] componentResources = null; |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 115 | |
cbridgha | d953dc7 | 2005-04-26 21:38:47 +0000 | [diff] [blame] | 116 | IPath estimatedPath = null; |
cbridgha | 4c640c5 | 2005-04-25 16:03:19 +0000 | [diff] [blame] | 117 | IPath searchPath = null; |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 118 | do { |
| 119 | searchPath = (searchPath == null) ? getRuntimePath() : searchPath.removeLastSegments(1); |
cbridgha | b75aee9 | 2005-05-18 03:02:33 +0000 | [diff] [blame] | 120 | componentResources = root.findModuleResources(searchPath, ResourceTreeNode.CREATE_NONE); |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 121 | estimatedPath = findBestMatch(componentResources); |
| 122 | } while (estimatedPath == null && canSearchContinue(componentResources, searchPath)); |
cbridgha | 4c640c5 | 2005-04-25 16:03:19 +0000 | [diff] [blame] | 123 | return estimatedPath; |
cbridgha | fe83b0c | 2005-04-19 19:54:55 +0000 | [diff] [blame] | 124 | } |
cbridgha | 17f4e1d | 2005-03-28 19:41:04 +0000 | [diff] [blame] | 125 | } finally { |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 126 | if (moduleCore != null) { |
cbridgha | 17f4e1d | 2005-03-28 19:41:04 +0000 | [diff] [blame] | 127 | moduleCore.dispose(); |
| 128 | } |
| 129 | } |
| 130 | return getRuntimePath(); |
cbridgha | d953dc7 | 2005-04-26 21:38:47 +0000 | [diff] [blame] | 131 | } |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 132 | |
cbridgha | d953dc7 | 2005-04-26 21:38:47 +0000 | [diff] [blame] | 133 | private boolean canSearchContinue(ComponentResource[] componentResources, IPath searchPath) { |
cbridgha | 07e7c5f | 2005-04-27 14:57:46 +0000 | [diff] [blame] | 134 | return (searchPath.segmentCount() > 0); |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 135 | } |
| 136 | |
cbridgha | d953dc7 | 2005-04-26 21:38:47 +0000 | [diff] [blame] | 137 | private IPath findBestMatch(ComponentResource[] theComponentResources) { |
| 138 | |
| 139 | int currentMatchLength = 0; |
cbridgha | 07e7c5f | 2005-04-27 14:57:46 +0000 | [diff] [blame] | 140 | int bestMatchLength = -1; |
cbridgha | d953dc7 | 2005-04-26 21:38:47 +0000 | [diff] [blame] | 141 | IPath estimatedPath = null; |
| 142 | IPath currentPath = null; |
| 143 | final IPath runtimePath = getRuntimePath(); |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 144 | for (int i = 0; i < theComponentResources.length; i++) { |
cbridgha | d953dc7 | 2005-04-26 21:38:47 +0000 | [diff] [blame] | 145 | currentPath = theComponentResources[i].getRuntimePath(); |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 146 | |
| 147 | if (currentPath.isPrefixOf(runtimePath)) { |
| 148 | if (currentPath.segmentCount() == runtimePath.segmentCount()) |
cbridgha | d953dc7 | 2005-04-26 21:38:47 +0000 | [diff] [blame] | 149 | return theComponentResources[i].getSourcePath(); |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 150 | |
| 151 | currentMatchLength = currentPath.matchingFirstSegments(runtimePath); |
| 152 | if (currentMatchLength == currentPath.segmentCount() && currentMatchLength > bestMatchLength) { |
cbridgha | d953dc7 | 2005-04-26 21:38:47 +0000 | [diff] [blame] | 153 | bestMatchLength = currentMatchLength; |
| 154 | IPath sourcePath = theComponentResources[i].getSourcePath(); |
| 155 | IPath subpath = runtimePath.removeFirstSegments(currentMatchLength); |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 156 | estimatedPath = sourcePath.append(subpath); |
| 157 | } |
cbridgha | d953dc7 | 2005-04-26 21:38:47 +0000 | [diff] [blame] | 158 | } |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 159 | } |
cbridgha | d953dc7 | 2005-04-26 21:38:47 +0000 | [diff] [blame] | 160 | return estimatedPath; |
| 161 | } |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 162 | |
cbridgha | 1686f44 | 2005-03-29 20:48:41 +0000 | [diff] [blame] | 163 | public String getName() { |
| 164 | return getRuntimePath().lastSegment(); |
| 165 | } |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 166 | |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 167 | public IVirtualComponent getComponent() { |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 168 | if (component == null) |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 169 | component = ComponentCore.createComponent(getProject(), getComponentHandle().getName()); |
| 170 | return component; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 171 | } |
vbhadrir | 35da0ba | 2005-06-27 20:02:56 +0000 | [diff] [blame^] | 172 | |
| 173 | //returns null if the folder is already the root folder |
cbridgha | 1686f44 | 2005-03-29 20:48:41 +0000 | [diff] [blame] | 174 | public IVirtualContainer getParent() { |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 175 | if (getRuntimePath().segmentCount() > 1) |
cbridgha | 1686f44 | 2005-03-29 20:48:41 +0000 | [diff] [blame] | 176 | return new VirtualFolder(getComponentHandle(), getRuntimePath().removeLastSegments(1)); |
vbhadrir | 35da0ba | 2005-06-27 20:02:56 +0000 | [diff] [blame^] | 177 | return null; |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 178 | } |
cbridgha | 1686f44 | 2005-03-29 20:48:41 +0000 | [diff] [blame] | 179 | |
| 180 | public IProject getProject() { |
| 181 | return getComponentHandle().getProject(); |
| 182 | } |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 183 | |
| 184 | public boolean isAccessible() { |
| 185 | throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$ |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 186 | // return false; |
| 187 | } |
| 188 | |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 189 | public Object getAdapter(Class adapter) { |
| 190 | throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$ |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 191 | // return null; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | public boolean contains(ISchedulingRule rule) { |
| 195 | throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$ |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 196 | // return false; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | public boolean isConflicting(ISchedulingRule rule) { |
| 200 | throw new UnsupportedOperationException("Method not supported"); //$NON-NLS-1$ |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 201 | // return false; |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 202 | } |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 203 | |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 204 | public String toString() { |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 205 | if (toString == null) |
| 206 | toString = "[" + getComponentHandle() + ":" + getRuntimePath() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 207 | return toString; |
| 208 | } |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 209 | |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 210 | public int hashCode() { |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 211 | if (hashCode == 0) |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 212 | hashCode = toString().hashCode(); |
| 213 | return hashCode; |
| 214 | } |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 215 | |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 216 | public boolean equals(Object anOther) { |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 217 | return hashCode() == ((anOther != null && anOther instanceof VirtualResource) ? anOther.hashCode() : 0); |
cbridgha | 4da5ee7 | 2005-04-14 14:27:50 +0000 | [diff] [blame] | 218 | } |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 219 | |
| 220 | public void setResourceType(String aResourceType) { |
| 221 | resourceType = aResourceType; |
| 222 | StructureEdit moduleCore = null; |
| 223 | try { |
| 224 | moduleCore = StructureEdit.getStructureEditForRead(getProject()); |
| 225 | WorkbenchComponent component = moduleCore.findComponentByName(getComponentHandle().getName()); |
| 226 | ComponentResource[] resources = component.findResourcesByRuntimePath(getRuntimePath()); |
| 227 | for (int i = 0; i < resources.length; i++) { |
| 228 | resources[i].setResourceType(aResourceType); |
| 229 | } |
| 230 | } finally { |
| 231 | if (moduleCore != null) { |
| 232 | moduleCore.dispose(); |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | // TODO Fetch the resource type from the model. |
cbridgha | 4da5ee7 | 2005-04-14 14:27:50 +0000 | [diff] [blame] | 238 | public String getResourceType() { |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 239 | if (null == resourceType) { |
| 240 | StructureEdit moduleCore = null; |
| 241 | try { |
| 242 | moduleCore = StructureEdit.getStructureEditForRead(getProject()); |
| 243 | WorkbenchComponent component = moduleCore.findComponentByName(getComponentHandle().getName()); |
| 244 | ComponentResource[] resources = component.findResourcesByRuntimePath(getRuntimePath()); |
| 245 | for (int i = 0; i < resources.length; i++) { |
| 246 | resourceType = resources[i].getResourceType(); |
| 247 | return resourceType; |
| 248 | } |
| 249 | } finally { |
| 250 | if (moduleCore != null) { |
| 251 | moduleCore.dispose(); |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | resourceType = ""; |
cbridgha | 4da5ee7 | 2005-04-14 14:27:50 +0000 | [diff] [blame] | 256 | return resourceType; |
| 257 | } |
cbridgha | 17f4e1d | 2005-03-28 19:41:04 +0000 | [diff] [blame] | 258 | |
cbridgha | 523a94a | 2005-05-20 16:40:44 +0000 | [diff] [blame] | 259 | public ComponentHandle getComponentHandle() { |
cbridgha | 17f4e1d | 2005-03-28 19:41:04 +0000 | [diff] [blame] | 260 | return componentHandle; |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 261 | } |
| 262 | |
cbridgha | 2550120 | 2005-03-30 23:45:41 +0000 | [diff] [blame] | 263 | protected void createResource(IContainer resource, int updateFlags, IProgressMonitor monitor) throws CoreException { |
cbridgha | 1686f44 | 2005-03-29 20:48:41 +0000 | [diff] [blame] | 264 | |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 265 | if (resource.exists()) |
vbhadrir | d384118 | 2005-06-07 17:57:08 +0000 | [diff] [blame] | 266 | return; |
cbridgha | 2550120 | 2005-03-30 23:45:41 +0000 | [diff] [blame] | 267 | if (!resource.getParent().exists()) |
| 268 | createResource(resource.getParent(), updateFlags, monitor); |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 269 | if (!resource.exists() && resource.getType() == IResource.FOLDER) { |
cbridgha | 2550120 | 2005-03-30 23:45:41 +0000 | [diff] [blame] | 270 | ((IFolder) resource).create(updateFlags, true, monitor); |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 271 | } |
cbridgha | 2550120 | 2005-03-30 23:45:41 +0000 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | protected boolean isPotentalMatch(IPath aRuntimePath) { |
cbridgha | 1686f44 | 2005-03-29 20:48:41 +0000 | [diff] [blame] | 275 | return aRuntimePath.isPrefixOf(getRuntimePath()); |
| 276 | } |
cbridgha | af88ca6 | 2005-06-24 19:00:16 +0000 | [diff] [blame] | 277 | |
cbridgha | 6887f4d | 2005-03-23 15:10:33 +0000 | [diff] [blame] | 278 | } |