1 18 package org.eclipse.jdt.core; 19 20 import org.eclipse.core.runtime.*; 21 import org.eclipse.jdt.internal.core.JavaModelStatus; 22 23 44 public abstract class ClasspathContainerInitializer { 45 46 55 public static final int ATTRIBUTE_NOT_SUPPORTED = 1; 56 57 66 public static final int ATTRIBUTE_READ_ONLY = 2; 67 68 71 public ClasspathContainerInitializer() { 72 } 74 75 132 public abstract void initialize(IPath containerPath, IJavaProject project) throws CoreException; 133 134 144 public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) { 145 146 return false; 148 } 149 150 172 173 public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException { 174 175 } 177 178 189 public String getDescription(IPath containerPath, IJavaProject project) { 190 191 return containerPath.makeRelative().toString(); 193 } 194 195 211 public IClasspathContainer getFailureContainer(final IPath containerPath, IJavaProject project) { 212 final String description = getDescription(containerPath, project); 213 return 214 new IClasspathContainer() { 215 public IClasspathEntry[] getClasspathEntries() { 216 return new IClasspathEntry[0]; 217 } 218 public String getDescription() { 219 return description; 220 } 221 public int getKind() { 222 return 0; 223 } 224 public IPath getPath() { 225 return containerPath; 226 } 227 public String toString() { 228 return getDescription(); 229 } 230 }; 231 } 232 233 246 public Object getComparisonID(IPath containerPath, IJavaProject project) { 247 248 if (containerPath == null) { 251 return null; 252 } else { 253 return containerPath.segment(0); 254 } 255 } 256 257 285 public IStatus getAccessRulesStatus(IPath containerPath, IJavaProject project) { 286 287 if (canUpdateClasspathContainer(containerPath, project)) { 288 return Status.OK_STATUS; 289 } 290 return new JavaModelStatus(ATTRIBUTE_READ_ONLY); 291 } 292 293 323 public IStatus getAttributeStatus(IPath containerPath, IJavaProject project, String attributeKey) { 324 325 if (canUpdateClasspathContainer(containerPath, project)) { 326 return Status.OK_STATUS; 327 } 328 return new JavaModelStatus(ATTRIBUTE_READ_ONLY); 329 } 330 331 359 public IStatus getSourceAttachmentStatus(IPath containerPath, IJavaProject project) { 360 361 if (canUpdateClasspathContainer(containerPath, project)) { 362 return Status.OK_STATUS; 363 } 364 return new JavaModelStatus(ATTRIBUTE_READ_ONLY); 365 } 366 } 367 368 | Popular Tags |