Thread: [Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/treeview GenericTreeView.java,1.27,1.28 S
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Nikolaj B. <nbr...@us...> - 2006-05-17 12:04:00
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv578/src/net/sourceforge/bprocessor/gui/treeview Modified Files: GenericTreeView.java SpaceTreeView.java SurfaceTreeView.java Log Message: Fixed the sorting. Index: SurfaceTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/SurfaceTreeView.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SurfaceTreeView.java 15 May 2006 12:11:58 -0000 1.5 --- SurfaceTreeView.java 17 May 2006 12:03:42 -0000 1.6 *************** *** 8,17 **** package net.sourceforge.bprocessor.gui.treeview; - import java.util.Collections; - import java.util.Comparator; - import java.util.LinkedList; - import net.sourceforge.bprocessor.model.Project; - import net.sourceforge.bprocessor.model.Surface; /** --- 8,12 ---- *************** *** 31,44 **** */ public void update() { - final Comparator alpha = - new Comparator() { - public int compare(Object s1, Object s2) { - return ((Surface) s1).getName().compareToIgnoreCase(((Surface) s2).getName()); - } - }; root.removeAllChildren(); ! LinkedList surfaces = new LinkedList(Project.getInstance().getSurfaces()); ! Collections.sort(surfaces, alpha); ! root.add(new SurfaceContainer("Surfaces", surfaces)); model.nodeStructureChanged(root); } --- 26,31 ---- */ public void update() { root.removeAllChildren(); ! root.add(new SurfaceContainer("Surfaces", Project.getInstance().getSurfaces())); model.nodeStructureChanged(root); } Index: GenericTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** GenericTreeView.java 15 May 2006 12:12:15 -0000 1.27 --- GenericTreeView.java 17 May 2006 12:03:42 -0000 1.28 *************** *** 15,20 **** --- 15,23 ---- import java.net.URL; import java.util.Collection; + import java.util.Collections; + import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; + import java.util.LinkedList; import java.util.Set; *************** *** 613,617 **** public SpaceContainer(String name, Collection spaces) { super(name); ! Iterator iter = spaces.iterator(); while (iter.hasNext()) { Space current = (Space) iter.next(); --- 616,638 ---- public SpaceContainer(String name, Collection spaces) { super(name); ! final Comparator alpha = ! new Comparator() { ! public int compare(Object s1, Object s2) { ! return ((Space) s1).getName().compareToIgnoreCase(((Space) s2).getName()); ! } ! }; ! ! final Comparator num = ! new Comparator() { ! public int compare(Object s1, Object s2) { ! return ((Space) s1).getId().compareTo(((Space) s2).getId()); ! } ! }; ! ! LinkedList sort = new LinkedList(spaces); ! Collections.sort(sort, num); ! Collections.sort(sort, alpha); ! ! Iterator iter = sort.iterator(); while (iter.hasNext()) { Space current = (Space) iter.next(); *************** *** 646,650 **** public SurfaceContainer(String name, Collection surfaces) { super(name); ! Iterator iter = surfaces.iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); --- 667,679 ---- public SurfaceContainer(String name, Collection surfaces) { super(name); ! final Comparator num = ! new Comparator() { ! public int compare(Object s1, Object s2) { ! return ((Surface) s1).getId().compareTo(((Surface) s2).getId()); ! } ! }; ! LinkedList sort = new LinkedList(surfaces); ! Collections.sort(sort, num); ! Iterator iter = sort.iterator(); while (iter.hasNext()) { Surface current = (Surface) iter.next(); Index: SpaceTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/SpaceTreeView.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SpaceTreeView.java 16 May 2006 15:42:14 -0000 1.9 --- SpaceTreeView.java 17 May 2006 12:03:42 -0000 1.10 *************** *** 9,16 **** import java.util.ArrayList; - import java.util.Collections; - import java.util.Comparator; import java.util.Enumeration; - import java.util.LinkedList; import javax.swing.tree.DefaultMutableTreeNode; --- 9,13 ---- *************** *** 18,22 **** import net.sourceforge.bprocessor.model.Project; - import net.sourceforge.bprocessor.model.Space; /** --- 15,18 ---- *************** *** 41,62 **** */ public void update() { - final Comparator alpha = - new Comparator() { - public int compare(Object s1, Object s2) { - return ((Space) s1).getName().compareToIgnoreCase(((Space) s2).getName()); - } - }; - LinkedList construction = new LinkedList(Project.getInstance().getConstructionSpaces()); - Collections.sort(construction, alpha); - LinkedList functional = new LinkedList(Project.getInstance().getFunctionalSpaces()); - Collections.sort(functional, alpha); - LinkedList constraints = new LinkedList(Project.getInstance().getConstraints()); - //Collections.sort(constraints, alpha); Enumeration e = getExpandedDescendants(new TreePath(root)); Object[] paths = findPaths(e); root.removeAllChildren(); ! root.add(new SpaceContainer("Functional", functional)); ! root.add(new SpaceContainer("Construction", construction)); ! root.add(new ConstraintContainer("Constraints", constraints)); root.add(new GeometryContainer("Geometry", Project.getInstance().world())); model.nodeStructureChanged(root); --- 37,46 ---- */ public void update() { Enumeration e = getExpandedDescendants(new TreePath(root)); Object[] paths = findPaths(e); root.removeAllChildren(); ! root.add(new SpaceContainer("Functional", Project.getInstance().getConstructionSpaces())); ! root.add(new SpaceContainer("Construction", Project.getInstance().getFunctionalSpaces())); ! root.add(new ConstraintContainer("Constraints", Project.getInstance().getConstraints())); root.add(new GeometryContainer("Geometry", Project.getInstance().world())); model.nodeStructureChanged(root); |