01: package org.osbl.client.wings.form;
02:
03: import org.osbl.persistence.model.TreeNodeEntity;
04: import org.osbl.persistence.model.TreeEntity;
05: import org.osbl.persistence.logic.DefaultTreeLogic;
06: import org.osbl.persistence.logic.TreeLogic;
07:
08: import javax.swing.tree.DefaultTreeModel;
09: import java.util.*;
10:
11: public abstract class GenericObjectTreeModel extends DefaultTreeModel {
12: public static final Comparator<? super TreeNodeEntity> PATH_LENGTH_COMPARATOR = new Comparator<TreeNodeEntity>() {
13: public int compare(TreeNodeEntity g1, TreeNodeEntity g2) {
14: return g1.getPath().compareTo(g2.getPath());
15: }
16: };
17:
18: protected Map<Class, Class<? extends GenericObjectTreeNode>> map = new HashMap<Class, Class<? extends GenericObjectTreeNode>>();
19:
20: public GenericObjectTreeModel(javax.swing.tree.TreeNode treeNode) {
21: super (treeNode);
22: }
23:
24: public GenericObjectTreeNode getRoot() {
25: return (GenericObjectTreeNode) super .getRoot();
26: }
27:
28: public Class<? extends GenericObjectTreeNode> nodeTypeFor(
29: Class childType) {
30: return map.get(childType);
31: }
32:
33: public abstract TreeLogic getTreeLogic();
34: }
|