1 11 package org.eclipse.update.internal.ui.model; 12 13 import java.util.ArrayList ; 14 15 public class BookmarkFolder extends NamedModelObject { 16 17 private static final long serialVersionUID = 1L; 18 protected ArrayList children= new ArrayList (); 19 public BookmarkFolder() { 20 } 21 22 public BookmarkFolder(String name) { 23 super(name); 24 } 25 26 public Object [] getChildren(Object 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 [] {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 |