1 package com.quantum.view.bookmark;
3 import java.beans.PropertyChangeEvent;
4 import java.beans.PropertyChangeListener;
5 import java.util.ArrayList;
6 import java.util.Collections;
7 import java.util.Hashtable;
11 import com.quantum.Messages;
12 import com.quantum.model.Bookmark;
13 import com.quantum.model.Entity;
16 * <p>A "quick list" is a set of favourite entities that a user may want
17 * to work with without having to sift through the (somtimes lengthy) longer
22 public class QuickListNode extends TreeNode implements PropertyChangeListener {
24 private Map children = new Hashtable();
29 public QuickListNode(BookmarkNode parent) {
32 Bookmark bookmark = getBookmark();
33 bookmark.addPropertyChangeListener(this);
37 * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
39 public void propertyChange(PropertyChangeEvent event) {
40 if ("quickList".equals(event.getPropertyName())) {
42 firePropertyChange("quickList", null, null);
47 * @see com.quantum.view.bookmark.TreeNode#hasChildren()
49 public boolean hasChildren() {
50 return getBookmark().hasQuickList();
53 * @see com.quantum.view.bookmark.TreeNode#getImageName()
55 protected String getImageName() {
60 * @see com.quantum.view.bookmark.TreeNode#getChildren()
62 public Object[] getChildren() {
63 Bookmark bookmark = getBookmark();
64 if (children.isEmpty() && bookmark.hasQuickList()) {
67 List list = new ArrayList(this.children.values());
68 Collections.sort(list);
70 return (TreeNode[]) list.toArray(new TreeNode[list.size()]);
74 * @see com.quantum.view.bookmark.TreeNode#getName()
76 public String getName() {
77 return Messages.getString(QuickListNode.class.getName() + ".labelName");
80 protected synchronized void initializeChildren() {
81 this.children.clear();
82 Entity[] entities = getBookmark().getQuickListEntries();
83 for (int i = 0, length = (entities == null) ? 0 : entities.length;
87 this.children.put(entities[i].getQualifiedName(),
88 new EntityNode(this, entities[i], true));
92 * @see com.quantum.view.bookmark.TreeNode#isInitialized()
94 protected boolean isInitialized() {