1 package com.quantum.view.bookmark;
3 import java.sql.SQLException;
4 import java.util.HashMap;
5 import java.util.Iterator;
8 import com.quantum.model.Bookmark;
9 import com.quantum.model.NotConnectedException;
10 import com.quantum.model.Schema;
11 import com.quantum.model.SchemaHolder;
16 public class SchemaNode extends TreeNode implements SchemaHolder {
18 private Schema schema;
22 public SchemaNode(TreeNode parent, Schema schema) {
28 * @see com.quantum.view.bookmark.TreeNode#getChildren()
30 public Object[] getChildren() {
31 Bookmark bookmark = getBookmark();
32 if (!bookmark.isConnected()) {
33 return BookmarkListNode.EMPTY_ARRAY;
35 if (this.children.isEmpty()) {
39 return (TreeNode[]) this.children.toArray(new TreeNode[this.children.size()]);
42 protected void initializeChildren() {
43 boolean firstTimeInitialization = this.children.isEmpty();
44 boolean changed = false;
45 Map temp = new HashMap();
46 for (Iterator i = this.children.iterator(); i.hasNext();) {
47 GroupNode element = (GroupNode) i.next();
48 temp.put(element.getType(), element);
50 this.children.clear();
52 Bookmark bookmark = getBookmark();
54 String[] types = bookmark.getDatabase().getEntityTypes();
55 for (int i = 0, length = (types == null) ? 0 : types.length;
58 GroupNode node = (GroupNode) temp.remove(types[i]);
60 this.children.add(new GroupNode(this, this.schema, types[i]));
63 this.children.add(node);
66 for (Iterator i = temp.values().iterator(); i.hasNext();) {
67 ((GroupNode) i.next()).dispose();
70 if (!firstTimeInitialization && changed) {
71 firePropertyChange("children", null, null);
73 } catch (NotConnectedException e) {
74 } catch (SQLException e) {
79 * @see com.quantum.view.bookmark.TreeNode#hasChildren()
81 public boolean hasChildren() {
82 return getBookmark().isConnected();
86 * @see com.quantum.view.bookmark.TreeNode#getName()
88 public String getName() {
89 return this.schema.getDisplayName();
93 * @see com.quantum.view.bookmark.TreeNode#getImageName()
95 protected String getImageName() {
96 return this.schema.exists()
98 : "missingschema.gif";
102 * @see com.quantum.model.SchemaHolder#getSchema()
104 public Schema getSchema() {