Пример #1
0
 private EntityCategory getCategoryNode(Object node) {
   int typeIdx = d_domain.getCategories().indexOf(node);
   if (typeIdx >= 0) {
     return d_domain.getCategories().get(typeIdx);
   }
   return null;
 }
Пример #2
0
 public Object getChild(Object parent, int childIndex) {
   if (d_root.equals(parent) && childIndex >= 0 && childIndex < d_domain.getCategories().size()) {
     return d_domain.getCategories().get(childIndex);
   } else {
     for (EntityCategory cat : d_domain.getCategories()) {
       if (isCategoryRequest(cat, parent, childIndex)) {
         return d_domain.getCategoryContents(cat).get(childIndex);
       }
     }
   }
   return null;
 }
Пример #3
0
  public DomainTreeModel(Domain domain) {
    d_domain = domain;

    for (EntityCategory c : d_domain.getCategories()) {
      d_domain.getCategoryContents(c).addListDataListener(new CategoryListener(c));
    }

    d_listeners = new ArrayList<TreeModelListener>();
  }
Пример #4
0
 public TreePath getPathTo(Object node) {
   if (d_root.equals(node)) {
     return new TreePath(new Object[] {d_root});
   } else if (d_domain.getCategories().contains(node)) {
     return new TreePath(new Object[] {d_root, node});
   } else if (isLeaf(node)) {
     return new TreePath(new Object[] {d_root, d_domain.getCategory(((Entity) node)), node});
   }
   return null;
 }
Пример #5
0
 public int getIndexOfChild(Object parent, Object child) {
   if (parent.equals(d_root)) {
     return d_domain.getCategories().indexOf(child);
   } else {
     ObservableList<? extends Entity> contents =
         d_domain.getCategoryContents(getCategoryNode(parent));
     if (contents != null) {
       return contents.indexOf(child);
     }
   }
   return -1;
 }
Пример #6
0
 public int getChildCount(Object parent) {
   if (d_root.equals(parent)) {
     return d_domain.getCategories().size();
   } else {
     ObservableList<? extends Entity> contents =
         d_domain.getCategoryContents(getCategoryNode(parent));
     if (contents != null) {
       return contents.size();
     }
   }
   return 0;
 }