1 11 12 package org.eclipse.jdt.internal.debug.ui.classpath; 13 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.core.runtime.IAdaptable; 17 import org.eclipse.core.runtime.IPath; 18 import org.eclipse.debug.core.ILaunchConfiguration; 19 import org.eclipse.jdt.core.IJavaProject; 20 import org.eclipse.jdt.launching.IRuntimeClasspathEntry; 21 import org.eclipse.jdt.launching.IRuntimeClasspathEntry2; 22 23 public class ClasspathEntry extends AbstractClasspathEntry implements IRuntimeClasspathEntry, IAdaptable { 24 25 private IRuntimeClasspathEntry entry= null; 26 27 30 public IJavaProject getJavaProject() { 31 return entry.getJavaProject(); 32 } 33 public ClasspathEntry(IRuntimeClasspathEntry entry, IClasspathEntry parent) { 34 this.parent= parent; 35 this.entry= entry; 36 } 37 38 41 public boolean equals(Object obj) { 42 if (obj instanceof ClasspathEntry) { 43 ClasspathEntry other= (ClasspathEntry)obj; 44 if (entry != null) { 45 return entry.equals(other.entry); 46 } 47 } else if (obj instanceof IRuntimeClasspathEntry) { 48 return entry.equals(obj); 49 } 50 return false; 51 52 } 53 54 57 public int hashCode() { 58 return entry.hashCode(); 59 } 60 61 64 public String toString() { 65 return entry.getPath().toOSString(); 66 } 67 68 71 public int getType() { 72 return entry.getType(); 73 } 74 75 78 public String getMemento() throws CoreException { 79 return entry.getMemento(); 80 } 81 82 85 public IPath getPath() { 86 return entry.getPath(); 87 } 88 89 92 public IResource getResource() { 93 return entry.getResource(); 94 } 95 96 99 public IPath getSourceAttachmentPath() { 100 return entry.getSourceAttachmentPath(); 101 } 102 103 106 public void setSourceAttachmentPath(IPath path) { 107 entry.setSourceAttachmentPath(path); 108 } 109 110 113 public IPath getSourceAttachmentRootPath() { 114 return entry.getSourceAttachmentRootPath(); 115 } 116 117 120 public void setSourceAttachmentRootPath(IPath path) { 121 entry.setSourceAttachmentRootPath(path); 122 123 } 124 125 128 public int getClasspathProperty() { 129 return entry.getClasspathProperty(); 130 } 131 132 135 public void setClasspathProperty(int location) { 136 entry.setClasspathProperty(location); 137 138 } 139 140 143 public String getLocation() { 144 return entry.getLocation(); 145 } 146 147 150 public String getSourceAttachmentLocation() { 151 return entry.getSourceAttachmentLocation(); 152 } 153 154 157 public String getSourceAttachmentRootLocation() { 158 return entry.getSourceAttachmentRootLocation(); 159 } 160 161 164 public String getVariableName() { 165 return entry.getVariableName(); 166 } 167 168 171 public org.eclipse.jdt.core.IClasspathEntry getClasspathEntry() { 172 return entry.getClasspathEntry(); 173 } 174 175 public IRuntimeClasspathEntry getDelegate() { 176 return entry; 177 } 178 179 public boolean hasChildren() { 180 IRuntimeClasspathEntry rpe = getDelegate(); 181 return rpe instanceof IRuntimeClasspathEntry2 && 182 ((IRuntimeClasspathEntry2)rpe).isComposite(); 183 } 184 185 public IClasspathEntry[] getChildren(ILaunchConfiguration configuration) { 186 IRuntimeClasspathEntry rpe = getDelegate(); 187 if (rpe instanceof IRuntimeClasspathEntry2) { 188 IRuntimeClasspathEntry2 r2 = (IRuntimeClasspathEntry2) rpe; 189 try { 190 IRuntimeClasspathEntry[] entries = r2.getRuntimeClasspathEntries(configuration); 191 IClasspathEntry[] cps = new IClasspathEntry[entries.length]; 192 for (int i = 0; i < entries.length; i++) { 193 IRuntimeClasspathEntry childEntry = entries[i]; 194 cps[i] = new ClasspathEntry(childEntry, this); 195 } 196 return cps; 197 } catch (CoreException e) { 198 } 199 } 200 return null; 201 } 202 203 206 public boolean isEditable() { 207 return getParent() instanceof ClasspathGroup; 208 } 209 210 213 public Object getAdapter(Class adapter) { 214 if (getDelegate() instanceof IAdaptable) { 215 return ((IAdaptable)getDelegate()).getAdapter(adapter); 216 } 217 return null; 218 } 219 } 220 | Popular Tags |