[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/treeview DBKTreeView.java, 1.2, 1.3 Gene
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2007-05-08 11:26:12
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16922/src/net/sourceforge/bprocessor/gui/treeview Modified Files: DBKTreeView.java GenericTreeView.java Log Message: refactored DBKtree containers out of genericTreeView to make sorting of nodes based on entitys only be on entitys and get rid of casting in the wild... made some cahanges so that the DBKtree are in deed updated on changes as well. There are still a error when adding own classifacations several times, but I think the error are in persistence not in the tree Index: GenericTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** GenericTreeView.java 7 May 2007 15:40:09 -0000 1.97 --- GenericTreeView.java 8 May 2007 11:08:18 -0000 1.98 *************** *** 410,414 **** * @param label The label for the container node */ ! public ContainerNode(Object label, Collection object) { super(label); this.content = object; --- 410,414 ---- * @param label The label for the container node */ ! public ContainerNode(Object label, Collection< ? extends Entity> object) { super(label); this.content = object; *************** *** 472,478 **** if (object instanceof Collection) { content = (Collection) object; ! Set<Entity> elements = new HashSet(); elements.addAll(content); ! Set<GenericNode> children = new HashSet(); Enumeration enumeration = this.children(); while (enumeration.hasMoreElements()) { --- 472,478 ---- if (object instanceof Collection) { content = (Collection) object; ! Set<Entity> elements = new HashSet<Entity>(); elements.addAll(content); ! Set<GenericNode> children = new HashSet<GenericNode>(); Enumeration enumeration = this.children(); while (enumeration.hasMoreElements()) { *************** *** 502,507 **** * @param sort boolean that is true if the entities should be sorted */ ! public void insertChildren(Collection entities, boolean sort) { ! LinkedList sorted = new LinkedList(entities); if (sort) { Entity.sort(sorted); --- 502,507 ---- * @param sort boolean that is true if the entities should be sorted */ ! public void insertChildren(Collection<? extends Entity> entities, boolean sort) { ! LinkedList<Entity> sorted = new LinkedList<Entity>(entities); if (sort) { Entity.sort(sorted); *************** *** 509,513 **** int[] ins = new int[sorted.size()]; int i = 0; ! for (Object current : sorted) { this.add(nodeFor(current)); ins[i] = this.getChildCount() - 1; --- 509,513 ---- int[] ins = new int[sorted.size()]; int i = 0; ! for (Entity current : sorted) { this.add(nodeFor(current)); ins[i] = this.getChildCount() - 1; *************** *** 960,992 **** /** - * ClassificationContainer - */ - public class ClassificationContainer extends ContainerNode { - /** - * Constructor for ClassificationContainer - * @param name The name - * @param clas The classification - */ - public ClassificationContainer(String name, Classification clas) { - super(name, clas.getChildren()); - insertChildren(clas.getChildren(), false); - } - - /** {@inheritDoc} */ - public EntityNode nodeFor(Object entity) { - return new ClassificationNode((Classification) entity); - } - /** - * Return icon - * @return Icon - */ - public ImageIcon icon() { - return surfacegroupicon; - } - } - - - - /** * Geometry Container */ --- 960,963 ---- *************** *** 1021,1058 **** /** - * DBK Container - */ - public class DBKContainer extends ContainerNode { - /** - * Constructor - * @param name The name - * @param project The project - */ - public DBKContainer(String name, Project project) { - super(name, null); - add(new ClassificationContainer("Construction", project.getConstructionClas())); - add(new ClassificationContainer("Functional", project.getFunctionalClas())); - } - - /** - * Update the node with the given object - * @param o The object - */ - public void update(Object o) { - if (o instanceof Project) { - Project c = (Project) o; - /* - ((ClassificationContainer)this.getChildAt(0)). - update(c.getConstructionClas().getChildren()); - ((ClassificationContainer)this.getChildAt(1)). - update(c.getFunctionalClas().getChildren()); - */ - } else { - log.warn("Expected a Classification but found a " + o.getClass().getName()); - } - } - } - - /** * Constructor Container */ --- 992,995 ---- *************** *** 1369,1373 **** if (target instanceof Geometric) { select.add((Geometric)target); ! } else if (paths.length == 1 && target instanceof Parametric) { AttributeView.instance().display(target); } else { --- 1306,1310 ---- if (target instanceof Geometric) { select.add((Geometric)target); ! } else if (target instanceof Parametric) { AttributeView.instance().display(target); } else { Index: DBKTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/DBKTreeView.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DBKTreeView.java 30 Mar 2007 11:23:25 -0000 1.2 --- DBKTreeView.java 8 May 2007 11:08:18 -0000 1.3 *************** *** 8,11 **** --- 8,14 ---- package net.sourceforge.bprocessor.gui.treeview; + import javax.swing.ImageIcon; + + import net.sourceforge.bprocessor.model.Classification; import net.sourceforge.bprocessor.model.Project; *************** *** 26,33 **** super(); root.removeAllChildren(); ! root.add(new ClassificationContainer("Construction", ! Project.getInstance().getConstructionClas())); ! root.add(new ClassificationContainer("Functional", ! Project.getInstance().getFunctionalClas())); model.nodeStructureChanged(root); } --- 29,34 ---- super(); root.removeAllChildren(); ! root.add(new ClassificationContainer(Project.getInstance().getConstructionClas())); ! root.add(new ClassificationContainer(Project.getInstance().getFunctionalClas())); model.nodeStructureChanged(root); } *************** *** 37,42 **** */ public void update() { ! if (root.getChildCount() == 1) { ! ((GenericNode)root.getChildAt(0)).update(Project.getInstance()); } } --- 38,99 ---- */ public void update() { ! if (root.getChildCount() == 2) { ! ((GenericNode)root.getChildAt(0)).update(Project.getInstance().getConstructionClas()); ! ((GenericNode)root.getChildAt(1)).update(Project.getInstance().getFunctionalClas()); ! } ! } ! ! ! /** ! * ClassificationContainer ! */ ! public class ClassificationContainer extends GenericNode { ! /** ! * Constructor for ClassificationContainer ! * @param clas The classification ! */ ! public ClassificationContainer(Classification clas) { ! super(clas); ! for (Classification cl : clas.getChildren()) { ! this.add(new ClassificationContainer(cl)); ! } ! } ! ! /** {@inheritDoc} */ ! public EntityNode nodeFor(Object entity) { ! return new ClassificationNode((Classification) entity); ! } ! /** ! * Return icon ! * @return Icon ! */ ! public ImageIcon icon() { ! return surfacegroupicon; ! } ! ! /** ! * @param c the object to update with ! */ ! public void update(Object c) { ! if (c != null && c instanceof Classification) { ! Classification clas = (Classification)c; ! if (!this.toString().equals(clas.getName())) { ! this.userObject = clas; ! model.nodeChanged(this); ! } ! if (this.getChildCount() != clas.getChildren().size()) { ! this.removeAllChildren(); ! for (Classification cl : clas.getChildren()) { ! this.add(new ClassificationContainer(cl)); ! } ! model.nodeStructureChanged(this); ! } else { ! int index = 0; ! for (Classification cl : clas.getChildren()) { ! ((ClassificationContainer)(this.getChildAt(index))).update(cl); ! index++; ! } ! } ! } } } |