KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > classpath > ClasspathEntry


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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
10  *******************************************************************************/

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     /* (non-Javadoc)
28      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getJavaProject()
29      */

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     /* (non-Javadoc)
39      * @see java.lang.Object#equals(java.lang.Object)
40      */

41     public boolean equals(Object JavaDoc 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     /* (non-Javadoc)
55      * @see java.lang.Object#hashCode()
56      */

57     public int hashCode() {
58         return entry.hashCode();
59     }
60
61     /* (non-Javadoc)
62      * @see java.lang.Object#toString()
63      */

64     public String JavaDoc toString() {
65         return entry.getPath().toOSString();
66     }
67
68     /* (non-Javadoc)
69      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
70      */

71     public int getType() {
72         return entry.getType();
73     }
74
75     /* (non-Javadoc)
76      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getMemento()
77      */

78     public String JavaDoc getMemento() throws CoreException {
79         return entry.getMemento();
80     }
81
82     /* (non-Javadoc)
83      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getPath()
84      */

85     public IPath getPath() {
86         return entry.getPath();
87     }
88
89     /* (non-Javadoc)
90      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getResource()
91      */

92     public IResource getResource() {
93         return entry.getResource();
94     }
95
96     /* (non-Javadoc)
97      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getSourceAttachmentPath()
98      */

99     public IPath getSourceAttachmentPath() {
100         return entry.getSourceAttachmentPath();
101     }
102
103     /* (non-Javadoc)
104      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#setSourceAttachmentPath(org.eclipse.core.runtime.IPath)
105      */

106     public void setSourceAttachmentPath(IPath path) {
107         entry.setSourceAttachmentPath(path);
108     }
109
110     /* (non-Javadoc)
111      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getSourceAttachmentRootPath()
112      */

113     public IPath getSourceAttachmentRootPath() {
114         return entry.getSourceAttachmentRootPath();
115     }
116
117     /* (non-Javadoc)
118      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#setSourceAttachmentRootPath(org.eclipse.core.runtime.IPath)
119      */

120     public void setSourceAttachmentRootPath(IPath path) {
121         entry.setSourceAttachmentRootPath(path);
122         
123     }
124
125     /* (non-Javadoc)
126      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getClasspathProperty()
127      */

128     public int getClasspathProperty() {
129         return entry.getClasspathProperty();
130     }
131
132     /* (non-Javadoc)
133      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#setClasspathProperty(int)
134      */

135     public void setClasspathProperty(int location) {
136         entry.setClasspathProperty(location);
137         
138     }
139
140     /* (non-Javadoc)
141      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getLocation()
142      */

143     public String JavaDoc getLocation() {
144         return entry.getLocation();
145     }
146
147     /* (non-Javadoc)
148      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getSourceAttachmentLocation()
149      */

150     public String JavaDoc getSourceAttachmentLocation() {
151         return entry.getSourceAttachmentLocation();
152     }
153
154     /* (non-Javadoc)
155      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getSourceAttachmentRootLocation()
156      */

157     public String JavaDoc getSourceAttachmentRootLocation() {
158         return entry.getSourceAttachmentRootLocation();
159     }
160
161     /* (non-Javadoc)
162      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getVariableName()
163      */

164     public String JavaDoc getVariableName() {
165         return entry.getVariableName();
166     }
167
168     /* (non-Javadoc)
169      * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getClasspathEntry()
170      */

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     /* (non-Javadoc)
204      * @see org.eclipse.jdt.internal.debug.ui.classpath.IClasspathEntry#isEditable()
205      */

206     public boolean isEditable() {
207         return getParent() instanceof ClasspathGroup;
208     }
209
210     /* (non-Javadoc)
211      * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
212      */

213     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
214         if (getDelegate() instanceof IAdaptable) {
215             return ((IAdaptable)getDelegate()).getAdapter(adapter);
216         }
217         return null;
218     }
219 }
220
Popular Tags