1) Added missing strings for italic, underline and strike through.
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.sql / src / net / sourceforge / phpdt / sql / view / bookmark / BookmarkNode.java
1 package net.sourceforge.phpdt.sql.view.bookmark;
2
3 import java.util.Vector;
4
5 import org.eclipse.core.runtime.CoreException;
6
7 import net.sourceforge.phpdt.sql.bookmarks.Bookmark;
8 import net.sourceforge.phpdt.sql.sql.metadata.ObjectMetaData;
9
10 public class BookmarkNode extends Bookmark implements TreeNode {
11     private Vector children = new Vector();
12     public ObjectMetaData getMetaData() {
13         return null;    //no metadata implementation for now
14     }
15     public BookmarkNode() {
16     }
17
18     public BookmarkNode(Bookmark bookmark) {
19         super(bookmark);
20     }
21
22         public Object[] getChildren() {
23                 return children.toArray();
24         }
25
26         public Object getParent() {
27                 return Root.ROOT;
28         }
29
30         public boolean hasChildren() {
31                 if (children != null && children.size() > 0) {
32                         return true;
33                 }
34                 return false;
35         }
36
37         public void setChildren(Vector children) {
38                 for (int i = 0; i <  children.size(); i++) {
39                         Object obj = children.elementAt(i);
40                         isValid(obj);
41                 }
42                 this.children = children;
43         }
44         
45         public void isValid(Object child) {
46                 boolean valid = false;
47                 if (child instanceof TableNode ||
48                     child instanceof ViewNode ||
49                     child instanceof SequenceNode ||
50                     child instanceof GroupNode) {
51                         valid = true;
52                 }
53                 if (!valid) {
54                         throw new RuntimeException("Invalid BookmarkNode child: " + child.getClass().getName()); //$NON-NLS-1$
55                 }
56         }
57         
58         public void dispose() throws CoreException {
59                 if (isConnected()) {
60             disconnect();
61         } 
62         }
63
64         /**
65          * Finds a child of the BookmarkNode with the said name 
66          * @param name
67          * @return the TreeNode found. null if none
68          */
69         public TreeNode find(String name){
70                 for (int i = 0; i <  children.size(); i++) {
71                         Object obj = children.elementAt(i);
72                         if (obj instanceof TreeNode){
73                                 TreeNode node = (TreeNode) obj;
74                                 if (name.equals(node.getName())) return node;                   
75                         }
76                 }
77                 return null;
78         }
79
80 }