cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
jlanuti | fed82ab | 2005-12-01 22:03:10 +0000 | [diff] [blame] | 2 | * Copyright (c) 2003, 2005 IBM Corporation and others. |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 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 |
jlanuti | fed82ab | 2005-12-01 22:03:10 +0000 | [diff] [blame] | 7 | * |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
jlanuti | fed82ab | 2005-12-01 22:03:10 +0000 | [diff] [blame] | 10 | *******************************************************************************/ |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 11 | package org.eclipse.wst.common.componentcore.resources; |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 12 | |
| 13 | import org.eclipse.core.runtime.CoreException; |
| 14 | import org.eclipse.core.runtime.IPath; |
cbridgha | 2550120 | 2005-03-30 23:45:41 +0000 | [diff] [blame] | 15 | import org.eclipse.core.runtime.IProgressMonitor; |
cbridgha | 2550120 | 2005-03-30 23:45:41 +0000 | [diff] [blame] | 16 | /** |
cbridgha | ce903d1 | 2005-03-31 22:04:23 +0000 | [diff] [blame] | 17 | * Represents a component as defined by the WTP Modules file. A |
| 18 | * virtual container represents the root of the component. |
| 19 | * <p> |
| 20 | * Virtual containers can provide handles to virtual files and |
| 21 | * virtual folders that it contains. |
| 22 | * </p> |
| 23 | * <p> |
| 24 | * To acquire a handle to a component, use the following snippet:<br> |
| 25 | * <code>ModuleCore.createContainer(containingProject, componentName)</code> |
| 26 | * which will create a handle to a virtual container contained by |
| 27 | * <i>containingProject</i> with the name <i>componentName</i>. If the |
| 28 | * a component of the given name exists, then |
cbridgha | 44a17d7 | 2005-04-04 07:05:01 +0000 | [diff] [blame] | 29 | * {@link org.eclipse.wst.common.componentcore.resources.IVirtualResource#exists()} |
cbridgha | ce903d1 | 2005-03-31 22:04:23 +0000 | [diff] [blame] | 30 | * will return true. Otherwise, use {@link #create(int, IProgressMonitor)} to |
| 31 | * create the relevant model elements. If a client needs to add a |
| 32 | * mapping from a folder in the same project to root, use |
| 33 | * {@link #createLink(IPath, int, IProgressMonitor)} with a |
| 34 | * project-relative path. |
cbridgha | 2550120 | 2005-03-30 23:45:41 +0000 | [diff] [blame] | 35 | * <p> |
| 36 | * This interface is not intended to be implemented by clients. |
| 37 | * </p> |
jeffliu | 3723bef | 2005-07-06 13:41:48 +0000 | [diff] [blame] | 38 | * @plannedfor 1.0 |
cbridgha | 2550120 | 2005-03-30 23:45:41 +0000 | [diff] [blame] | 39 | */ |
cbridgha | ce903d1 | 2005-03-31 22:04:23 +0000 | [diff] [blame] | 40 | public interface IVirtualContainer extends IVirtualResource { |
| 41 | |
| 42 | |
| 43 | /** |
| 44 | * Create the underlying model elements if they do not already exist. Resources |
| 45 | * may be created as a result of this method if the mapped path does not exist. |
| 46 | * |
| 47 | * @param updateFlags Any of IVirtualResource or IResource update flags. If a |
| 48 | * resource must be created, the updateFlags will be supplied to the |
| 49 | * resource creation operation. |
| 50 | * @param aMonitor |
| 51 | * @throws CoreException |
| 52 | */ |
| 53 | public void create(int updateFlags, IProgressMonitor aMonitor) throws CoreException; |
| 54 | |
cbridgha | 21789da | 2005-03-30 18:50:37 +0000 | [diff] [blame] | 55 | |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 56 | /** |
cbridgha | ce903d1 | 2005-03-31 22:04:23 +0000 | [diff] [blame] | 57 | * Returns whether a virtual resource of some type with the given path |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 58 | * exists relative to this resource. |
| 59 | * The supplied path may be absolute or relative; in either case, it is |
| 60 | * interpreted as relative to this resource. Trailing separators are ignored. |
| 61 | * If the path is empty this container is checked for existence. |
| 62 | * |
| 63 | * @param path the path of the resource |
| 64 | * @return <code>true</code> if a resource of some type with the given path |
| 65 | * exists relative to this resource, and <code>false</code> otherwise |
| 66 | * @see IVirtualResource#exists() |
| 67 | */ |
| 68 | public boolean exists(IPath path); |
| 69 | |
| 70 | /** |
cbridgha | ce903d1 | 2005-03-31 22:04:23 +0000 | [diff] [blame] | 71 | * Finds and returns the member virtual resource (folder or file) |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 72 | * with the given name in this container, or <code>null</code> if no such |
| 73 | * resource exists. |
| 74 | * |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 75 | * |
| 76 | * @param name the string name of the member resource |
| 77 | * @return the member resource, or <code>null</code> if no such |
| 78 | * resource exists |
| 79 | */ |
| 80 | public IVirtualResource findMember(String name); |
| 81 | |
| 82 | /** |
cbridgha | ce903d1 | 2005-03-31 22:04:23 +0000 | [diff] [blame] | 83 | * Finds and returns the member resource (folder, or file) |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 84 | * with the given name in this container, or <code>null</code> if |
| 85 | * there is no such resource. |
| 86 | * <p> |
| 87 | * If the <code>includePhantoms</code> argument is <code>false</code>, |
| 88 | * only a member resource with the given name that exists will be returned. |
| 89 | * If the <code>includePhantoms</code> argument is <code>true</code>, |
| 90 | * the method also returns a resource if the workspace is keeping track of a |
| 91 | * phantom with that name. |
cbridgha | ce903d1 | 2005-03-31 22:04:23 +0000 | [diff] [blame] | 92 | * </p> |
| 93 | * <p> |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 94 | * Note that no attempt is made to exclude team-private member resources |
| 95 | * as with <code>members</code>. |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 96 | * </p> |
| 97 | * |
| 98 | * @param name the string name of the member resource |
| 99 | * @param includePhantoms <code>true</code> if phantom resources are |
| 100 | * of interest; <code>false</code> if phantom resources are not of |
| 101 | * interest |
| 102 | * @return the member resource, or <code>null</code> if no such |
| 103 | * resource exists |
| 104 | * @see #members() |
| 105 | * @see IVirtualResource#isPhantom() |
| 106 | */ |
cbridgha | ce903d1 | 2005-03-31 22:04:23 +0000 | [diff] [blame] | 107 | public IVirtualResource findMember(String name, int searchFlags); |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 108 | |
| 109 | /** |
| 110 | * Finds and returns the member resource identified by the given path in |
| 111 | * this container, or <code>null</code> if no such resource exists. |
| 112 | * The supplied path may be absolute or relative; in either case, it is |
| 113 | * interpreted as relative to this resource. Trailing separators and the path's |
cbridgha | ce903d1 | 2005-03-31 22:04:23 +0000 | [diff] [blame] | 114 | * device are ignored. If the path is empty this container is returned. |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 115 | * |
| 116 | * @param path the path of the desired resource |
| 117 | * @return the member resource, or <code>null</code> if no such |
| 118 | * resource exists |
| 119 | */ |
| 120 | public IVirtualResource findMember(IPath path); |
| 121 | |
| 122 | /** |
| 123 | * Finds and returns the member resource identified by the given path in |
| 124 | * this container, or <code>null</code> if there is no such resource. |
| 125 | * The supplied path may be absolute or relative; in either case, it is |
| 126 | * interpreted as relative to this resource. Trailing separators and the path's |
| 127 | * device are ignored. |
cbridgha | ce903d1 | 2005-03-31 22:04:23 +0000 | [diff] [blame] | 128 | * If the path is empty this container is returned. |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 129 | * |
| 130 | * @param path the path of the desired resource |
| 131 | * @param includePhantoms <code>true</code> if phantom resources are |
| 132 | * of interest; <code>false</code> if phantom resources are not of |
| 133 | * interest |
| 134 | * @return the member resource, or <code>null</code> if no such |
| 135 | * resource exists |
| 136 | * @see #members(boolean) |
| 137 | * @see IVirtualResource#isPhantom() |
| 138 | */ |
cbridgha | ce903d1 | 2005-03-31 22:04:23 +0000 | [diff] [blame] | 139 | public IVirtualResource findMember(IPath path, int searchFlags); |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 140 | |
| 141 | /** |
| 142 | * Returns a handle to the file identified by the given path in this |
| 143 | * container. |
| 144 | * <p> |
| 145 | * This is a resource handle operation; neither the resource nor |
| 146 | * the result need exist in the workspace. |
| 147 | * The validation check on the resource name/path is not done |
| 148 | * when the resource handle is constructed; rather, it is done |
| 149 | * automatically as the resource is created. |
| 150 | * <p> |
| 151 | * The supplied path may be absolute or relative; in either case, it is |
| 152 | * interpreted as relative to this resource and is appended |
| 153 | * to this container's full path to form the full path of the resultant resource. |
| 154 | * A trailing separator is ignored. The path of the resulting resource must |
| 155 | * have at least two segments. |
| 156 | * </p> |
| 157 | * |
| 158 | * @param path the path of the member file |
| 159 | * @return the (handle of the) member file |
| 160 | * @see #getFolder(IPath) |
| 161 | */ |
| 162 | public IVirtualFile getFile(IPath path); |
| 163 | |
| 164 | /** |
| 165 | * Returns a handle to the folder identified by the given path in this |
| 166 | * container. |
| 167 | * <p> |
| 168 | * This is a resource handle operation; neither the resource nor |
| 169 | * the result need exist in the workspace. |
| 170 | * The validation check on the resource name/path is not done |
| 171 | * when the resource handle is constructed; rather, it is done |
| 172 | * automatically as the resource is created. |
| 173 | * <p> |
| 174 | * The supplied path may be absolute or relative; in either case, it is |
| 175 | * interpreted as relative to this resource and is appended |
| 176 | * to this container's full path to form the full path of the resultant resource. |
| 177 | * A trailing separator is ignored. The path of the resulting resource must |
| 178 | * have at least two segments. |
| 179 | * </p> |
| 180 | * |
| 181 | * @param path the path of the member folder |
| 182 | * @return the (handle of the) member folder |
| 183 | * @see #getFile(IPath) |
| 184 | */ |
cbridgha | 2550120 | 2005-03-30 23:45:41 +0000 | [diff] [blame] | 185 | public IVirtualFolder getFolder(IPath path); |
cbridgha | 21789da | 2005-03-30 18:50:37 +0000 | [diff] [blame] | 186 | |
| 187 | /** |
| 188 | * Returns a handle to the file with the given name in this folder. |
| 189 | * <p> |
| 190 | * This is a resource handle operation; neither the resource nor |
| 191 | * the result need exist in the workspace. |
| 192 | * The validation check on the resource name/path is not done |
| 193 | * when the resource handle is constructed; rather, it is done |
| 194 | * automatically as the resource is created. |
| 195 | * </p> |
| 196 | * |
| 197 | * @param name the string name of the member file |
| 198 | * @return the (handle of the) member file |
| 199 | * @see #getFolder(String) |
| 200 | */ |
| 201 | public IVirtualFile getFile(String name); |
| 202 | |
| 203 | /** |
| 204 | * Returns a handle to the folder with the given name in this folder. |
| 205 | * <p> |
| 206 | * This is a resource handle operation; neither the container |
| 207 | * nor the result need exist in the workspace. |
| 208 | * The validation check on the resource name/path is not done |
| 209 | * when the resource handle is constructed; rather, it is done |
| 210 | * automatically as the resource is created. |
| 211 | * </p> |
| 212 | * |
| 213 | * @param name the string name of the member folder |
| 214 | * @return the (handle of the) member folder |
| 215 | * @see #getFile(String) |
| 216 | */ |
| 217 | public IVirtualFolder getFolder(String name); |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 218 | |
| 219 | /** |
| 220 | * Returns a list of existing member resources (projects, folders and files) |
| 221 | * in this resource, in no particular order. |
| 222 | * <p> |
| 223 | * This is a convenience method, fully equivalent to <code>members(IVirtualResource.NONE)</code>. |
| 224 | * Team-private member resources are <b>not</b> included in the result. |
| 225 | * </p><p> |
| 226 | * Note that the members of a project or folder are the files and folders |
| 227 | * immediately contained within it. The members of the workspace root |
| 228 | * are the projects in the workspace. |
| 229 | * </p> |
| 230 | * |
| 231 | * @return an array of members of this resource |
| 232 | * @exception CoreException if this request fails. Reasons include: |
| 233 | * <ul> |
| 234 | * <li> This resource does not exist.</li> |
| 235 | * <li> This resource is a project that is not open.</li> |
| 236 | * </ul> |
| 237 | * @see #findMember(IPath) |
| 238 | * @see IVirtualResource#isAccessible() |
| 239 | */ |
| 240 | public IVirtualResource[] members() throws CoreException; |
| 241 | |
| 242 | /** |
| 243 | * Returns a list of all member resources (projects, folders and files) |
| 244 | * in this resource, in no particular order. |
| 245 | * <p> |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 246 | * If the <code>INCLUDE_PHANTOMS</code> flag is not specified in the member |
| 247 | * flags (recommended), only member resources that exist will be returned. |
| 248 | * If the <code>INCLUDE_PHANTOMS</code> flag is specified, |
| 249 | * the result will also include any phantom member resources the |
| 250 | * workspace is keeping track of. |
| 251 | * </p><p> |
| 252 | * If the <code>INCLUDE_TEAM_PRIVATE_MEMBERS</code> flag is specified |
| 253 | * in the member flags, team private members will be included along with |
| 254 | * the others. If the <code>INCLUDE_TEAM_PRIVATE_MEMBERS</code> flag |
| 255 | * is not specified (recommended), the result will omit any team private |
| 256 | * member resources. |
| 257 | * </p> |
| 258 | * <p> |
| 259 | * If the <code>EXCLUDE_DERIVED</code> flag is not specified, derived |
| 260 | * resources are included. If the <code>EXCLUDE_DERIVED</code> flag is |
| 261 | * specified in the member flags, derived resources are not included. |
| 262 | * </p> |
| 263 | * |
| 264 | * @param memberFlags bit-wise or of member flag constants |
| 265 | * (<code>INCLUDE_PHANTOMS</code>, <code>INCLUDE_TEAM_PRIVATE_MEMBERS</code> |
| 266 | * and <code>EXCLUDE_DERIVED</code>) indicating which members are of interest |
| 267 | * @return an array of members of this resource |
| 268 | * @exception CoreException if this request fails. Reasons include: |
| 269 | * <ul> |
| 270 | * <li> This resource does not exist.</li> |
| 271 | * <li> the <code>INCLUDE_PHANTOMS</code> flag is not specified and |
| 272 | * this resource does not exist.</li> |
| 273 | * <li> the <code>INCLUDE_PHANTOMS</code> flag is not specified and |
| 274 | * this resource is a project that is not open.</li> |
| 275 | * </ul> |
| 276 | * @see IVirtualResource#exists() |
jeffliu | 3723bef | 2005-07-06 13:41:48 +0000 | [diff] [blame] | 277 | * @plannedfor 2.0 |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 278 | */ |
| 279 | public IVirtualResource[] members(int memberFlags) throws CoreException; |
vbhadrir | e796edc | 2005-06-17 15:32:30 +0000 | [diff] [blame] | 280 | |
| 281 | public IVirtualResource[] getResources(String aResourceType); |
cbridgha | 1c6a6ba | 2005-03-24 16:24:53 +0000 | [diff] [blame] | 282 | } |
| 283 | |