KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Iterator JavaDoc;
15
16 public class ClasspathGroup extends AbstractClasspathEntry {
17     private String JavaDoc name;
18     
19     private boolean canBeRemoved= true;
20     
21     public ClasspathGroup(String JavaDoc name, IClasspathEntry parent, boolean canBeRemoved) {
22         this.parent= parent;
23         this.name= name;
24         this.canBeRemoved= canBeRemoved;
25     }
26         
27     public void addEntry(IClasspathEntry entry, Object JavaDoc beforeEntry) {
28         if (!childEntries.contains(entry)) {
29             int index = -1;
30             if (beforeEntry != null) {
31                 index = childEntries.indexOf(beforeEntry);
32             }
33             if (index >= 0) {
34                 childEntries.add(index, entry);
35             } else {
36                 childEntries.add(entry);
37             }
38         }
39     }
40     
41     public void removeEntry(IClasspathEntry entry) {
42         childEntries.remove(entry);
43     }
44     
45     public boolean contains(IClasspathEntry entry) {
46         return childEntries.contains(entry);
47     }
48     
49     public String JavaDoc toString() {
50         return name;
51     }
52
53     public void removeAll() {
54         Iterator JavaDoc iter= childEntries.iterator();
55         while (iter.hasNext()) {
56             Object JavaDoc entry = iter.next();
57             if (entry instanceof ClasspathGroup) {
58                 ((ClasspathGroup)entry).removeAll();
59             }
60         }
61         childEntries.clear();
62     }
63     
64     public boolean canBeRemoved() {
65         return canBeRemoved;
66     }
67
68     /* (non-Javadoc)
69      * @see org.eclipse.jdt.internal.debug.ui.classpath.IClasspathEntry#isEditable()
70      */

71     public boolean isEditable() {
72         return false;
73     }
74 }
75
Popular Tags