Thread: [Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/treeview GenericTreeView.java, 1.81, 1.8
Status: Pre-Alpha
Brought to you by:
henryml
|
[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/treeview
GenericTreeView.java, 1.81, 1.82
From: Michael L. <he...@us...> - 2007-03-09 10:48:35
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11522/src/net/sourceforge/bprocessor/gui/treeview Modified Files: GenericTreeView.java Log Message: Removed some insertChildren implementations and added a nodeFor method instead so that the insertChildren method in ContainerNode is general (depends on nodeFor to create nodes of correct type). Index: GenericTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** GenericTreeView.java 9 Mar 2007 10:03:48 -0000 1.81 --- GenericTreeView.java 9 Mar 2007 10:48:34 -0000 1.82 *************** *** 15,20 **** import java.net.URL; import java.util.Collection; - import java.util.Collections; - import java.util.Comparator; import java.util.Enumeration; import java.util.HashSet; --- 15,18 ---- *************** *** 508,512 **** int i = 0; for (Object current : entities) { ! this.add(new EntityNode(current)); ins[i] = this.getChildCount() - 1; i++; --- 506,510 ---- int i = 0; for (Object current : entities) { ! this.add(nodeFor(current)); ins[i] = this.getChildCount() - 1; i++; *************** *** 890,920 **** } ! /** ! * Insert the given object into the node ! * @param elem the elements ! */ ! public void insertChildren(Collection elem) { ! final Comparator num = ! new Comparator() { ! public int compare(Object s1, Object s2) { ! return ((Surface) s1).getId().compareTo(((Surface) s2).getId()); ! } ! }; ! LinkedList sort = new LinkedList(elem); ! Collections.sort(sort, num); ! //insert ! int[] ins = new int[sort.size()]; ! int i = 0; ! Iterator iter = sort.iterator(); ! while (iter.hasNext()) { ! Surface s = (Surface)iter.next(); ! this.add(new SurfaceNode(s)); ! ins[i] = this.getChildCount() - 1; ! i++; ! } ! model.nodesWereInserted(this, ins); } - /** * Return icon --- 888,896 ---- } ! /** {@inheritDoc} */ ! public EntityNode nodeFor(Object entity) { ! return new SurfaceNode((Surface) entity); } /** * Return icon *************** *** 945,972 **** } ! /** ! * Insert the given object into the node ! * @param elem the elements ! */ ! public void insertChildren(Collection elem) { ! final Comparator num = ! new Comparator() { ! public int compare(Object s1, Object s2) { ! return ((Space) s1).getId().compareTo(((Space) s2).getId()); ! } ! }; ! LinkedList sort = new LinkedList(elem); ! Collections.sort(sort, num); ! ! int[] ins = new int[sort.size()]; ! int i = 0; ! Iterator iter = sort.iterator(); ! while (iter.hasNext()) { ! Space s = (Space)iter.next(); ! this.add(new SpaceNode(s)); ! ins[i] = this.getChildCount() - 1; ! i++; ! } ! model.nodesWereInserted(this, ins); } --- 921,927 ---- } ! /** {@inheritDoc} */ ! public EntityNode nodeFor(Object entity) { ! return new SpaceNode((Space) entity); } *************** *** 1034,1060 **** } ! /** ! * Insert the given object into the node ! * @param elem the elements ! */ ! public void insertChildren(Collection elem) { ! final Comparator num = ! new Comparator() { ! public int compare(Object s1, Object s2) { ! return ((Constructor) s1).getId().compareTo(((Constructor) s2).getId()); ! } ! }; ! LinkedList sort = new LinkedList(elem); ! Collections.sort(sort, num); ! int[] ins = new int[sort.size()]; ! int i = 0; ! Iterator iter = sort.iterator(); ! while (iter.hasNext()) { ! Constructor s = (Constructor)iter.next(); ! this.add(new ConstructorNode(s)); ! ins[i] = this.getChildCount() - 1; ! i++; ! } ! model.nodesWereInserted(this, ins); } } --- 989,995 ---- } ! /** {@inheritDoc} */ ! public EntityNode nodeFor(Object entity) { ! return new ConstructorNode((Constructor) entity); } } *************** *** 1074,1094 **** } ! /** ! * Insert collection of Entity in this node ! * @param entities collection of Entity ! */ ! public void insertChildren(Collection entities) { ! LinkedList sorted = new LinkedList(entities); ! Entity.sort(sorted); ! int[] ins = new int[sorted.size()]; ! int i = 0; ! Iterator iter = sorted.iterator(); ! while (iter.hasNext()) { ! Edge s = (Edge)iter.next(); ! this.add(new EdgeNode(s)); ! ins[i] = this.getChildCount() - 1; ! i++; ! } ! model.nodesWereInserted(this, ins); } --- 1009,1015 ---- } ! /** {@inheritDoc} */ ! public EntityNode nodeFor(Object entity) { ! return new EdgeNode((Edge) entity); } *************** *** 1132,1159 **** } ! /** ! * Insert the given objects into the node ! * @param elem the elements ! */ ! public void insertChildren(Collection elem) { ! final Comparator num = ! new Comparator() { ! public int compare(Object s1, Object s2) { ! return ((Space) s1).getId().compareTo(((Space) s2).getId()); ! } ! }; ! LinkedList sort = new LinkedList(elem); ! Collections.sort(sort, num); ! ! int[] ins = new int[sort.size()]; ! int i = 0; ! Iterator iter = sort.iterator(); ! while (iter.hasNext()) { ! Space s = (Space)iter.next(); ! this.add(new SpaceNode(s)); ! ins[i] = this.getChildCount() - 1; ! i++; ! } ! model.nodesWereInserted(this, ins); } } --- 1053,1059 ---- } ! /** {@inheritDoc} */ ! public EntityNode nodeFor(Object entity) { ! return new SpaceNode((Space) entity); } } *************** *** 1211,1239 **** } ! ! /** ! * Insert the given object into the node ! * @param elem the elements ! */ ! public void insertChildren(Collection elem) { ! final Comparator num = ! new Comparator() { ! public int compare(Object s1, Object s2) { ! return ((Vertex) s1).getId().compareTo(((Vertex) s2).getId()); ! } ! }; ! LinkedList sort = new LinkedList(elem); ! Collections.sort(sort, num); ! ! int[] ins = new int[sort.size()]; ! int i = 0; ! Iterator iter = sort.iterator(); ! while (iter.hasNext()) { ! Vertex s = (Vertex)iter.next(); ! this.add(new VertexNode(s)); ! ins[i] = this.getChildCount() - 1; ! i++; ! } ! model.nodesWereInserted(this, ins); } } --- 1111,1117 ---- } ! /** {@inheritDoc} */ ! public EntityNode nodeFor(Object entity) { ! return new VertexNode((Vertex) entity); } } |