2 * $RCSfile: JSElementList.java,v $
5 * CH-1700 Fribourg, Switzerland
8 *========================================================================
9 * Modifications history
10 *========================================================================
11 * $Log: not supported by cvs2svn $
12 * Revision 1.2 2004/02/27 18:28:10 cell
13 * Make model elements platform objects so they are automatically adapted
15 * Revision 1.1 2004/02/26 02:25:42 agfitzp
16 * renamed packages to match xml & css
18 * Revision 1.1 2004/02/05 03:10:08 agfitzp
21 * Revision 1.1.2.1 2003/12/12 21:37:24 agfitzp
22 * Experimental work for Classes view
24 * Revision 1.1 2003/05/30 20:53:08 agfitzp
25 * 0.0.2 : Outlining is now done as the user types. Some other bug fixes.
27 * Revision 1.1 2003/05/28 15:17:11 agfitzp
28 * net.sourceforge.phpeclipse.js.core 0.0.1 code base
30 *========================================================================
33 package net.sourceforge.phpeclipse.js.core.model;
35 import java.util.ArrayList;
36 import java.util.Iterator;
37 import java.util.List;
39 import org.eclipse.core.runtime.IAdaptable;
40 import org.eclipse.core.runtime.PlatformObject;
47 public class JSElementList extends PlatformObject
49 protected List children = new ArrayList();
52 * Creates a new adaptable list with the given children.
54 public JSElementList()
59 * Creates a new adaptable list with the given children.
62 public JSElementList(JSElement[] newChildren)
64 for (int i = 0; i < newChildren.length; i++)
66 children.add(newChildren[i]);
71 * Creates a new adaptable list with the given children.
74 public JSElementList(List newChildren)
76 for (int i = 0; i < newChildren.size(); i++)
78 children.add(newChildren.get(i));
83 * Adds all the adaptable objects in the given enumeration to this list. Returns this list.
88 public JSElementList add(Iterator iterator)
90 while (iterator.hasNext())
92 add((JSElement) iterator.next());
99 * Adds the given adaptable object to this list. Returns this list.
104 public JSElementList add(JSElement anElement)
106 children.add(anElement);
112 * Returns the elements in this list.
115 public Object[] getChildren()
117 return children.toArray();
127 public Object[] getChildren(Object o)
129 return children.toArray();
139 public String getLabel(Object object)
141 return object == null ? "" : object.toString();
151 public Object getParent(Object object)
157 * Removes the given adaptable object from this list.
160 public void remove(JSElement anElement)
162 children.remove(anElement);
166 * Returns the number of items in the list
171 return children.size();
174 public JSElement findEquivilent(JSElement anElement)
176 for(int i = 0; i < size();i++)
178 JSElement aCandidate = (JSElement) children.get(i);
179 if(anElement.equals(aCandidate))
189 public JSElement get(int index)
195 return (JSElement) children.get(index);
201 public IAdaptable asAdaptable() {
202 // TODO Auto-generated method stub