KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > ui > model > BookmarkFolder


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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 package org.eclipse.update.internal.ui.model;
12
13 import java.util.ArrayList JavaDoc;
14
15 public class BookmarkFolder extends NamedModelObject {
16
17     private static final long serialVersionUID = 1L;
18     protected ArrayList JavaDoc children= new ArrayList JavaDoc();
19     public BookmarkFolder() {
20     }
21     
22     public BookmarkFolder(String JavaDoc name) {
23         super(name);
24     }
25     
26     public Object JavaDoc[] getChildren(Object JavaDoc parent) {
27         return children.toArray();
28     }
29     
30     public boolean hasChildren() {
31         return children.size()>0;
32     }
33     
34     public void addChild(NamedModelObject object) {
35         internalAdd(object);
36         notifyObjectsAdded(this, new Object JavaDoc[] {object});
37     }
38
39     public void addChildren(NamedModelObject [] objects) {
40         for (int i=0; i<objects.length; i++) {
41             internalAdd(objects[i]);
42         }
43         notifyObjectsAdded(this, objects);
44     }
45     
46     protected void internalAdd(NamedModelObject child) {
47         children.add(child);
48         child.setModel(getModel());
49         child.setParent(this);
50     }
51     
52     public void removeChildren(NamedModelObject [] objects) {
53         for (int i=0; i<objects.length; i++) {
54             children.remove(objects[i]);
55             objects[i].setParent(null);
56         }
57         notifyObjectsRemoved(this, objects);
58     }
59 }
60
Popular Tags