newest quantum CVS sources
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / view / bookmark / QueryListNode.java
1 package com.quantum.view.bookmark;
2
3 import java.beans.PropertyChangeEvent;
4 import java.beans.PropertyChangeListener;
5
6 import com.quantum.Messages;
7
8 /**
9  * @author BC
10  */
11 public class QueryListNode extends TreeNode implements PropertyChangeListener {
12
13     /**
14      * @param parent
15      */
16     public QueryListNode(TreeNode parent) {
17         super(parent);
18         getBookmark().addPropertyChangeListener(this);
19     }
20
21     /**
22      * @see com.quantum.view.bookmark.TreeNode#getChildren()
23      */
24     public Object[] getChildren() {
25         initializeChildren();
26         return (TreeNode[]) this.children.toArray(new TreeNode[this.children.size()]);
27     }
28
29     protected void initializeChildren() {
30         this.children.clear();
31         String[] queries = getBookmark().getQueries();
32         for (int i = 0, length = (queries == null) ? 0 : queries.length;
33             i < length;
34             i++) {
35             this.children.add(new QueryNode(this, queries[i]));
36         }
37     }
38
39     /**
40      * @see com.quantum.view.bookmark.TreeNode#hasChildren()
41      */
42     public boolean hasChildren() {
43         return getBookmark().getQueries().length > 0;
44     }
45
46     /**
47      * @see com.quantum.view.bookmark.TreeNode#getName()
48      */
49     public String getName() {
50         return Messages.getString(getClass().getName() + ".labelName");
51     }
52
53     /**
54      * @see com.quantum.view.bookmark.TreeNode#getImageName()
55      */
56     protected String getImageName() {
57         return "group.gif";
58     }
59
60     /**
61      * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
62      */
63     public void propertyChange(PropertyChangeEvent event) {
64         if ("queries".equals(event.getPropertyName())) {
65             firePropertyChange("queries", null, null);
66         }
67     }
68     /**
69      * @see com.quantum.view.bookmark.TreeNode#dispose()
70      */
71     protected void dispose() {
72         getBookmark().removePropertyChangeListener(this);
73         super.dispose();
74     }
75
76 }