[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/treeview GenericTreeView.java, 1.68, 1.6
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2007-01-29 15:47:21
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8404/src/net/sourceforge/bprocessor/gui/treeview Modified Files: GenericTreeView.java Log Message: Made changes to the tree to get better update and correct space - element - part structures Index: GenericTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** GenericTreeView.java 2 Jan 2007 17:47:50 -0000 1.68 --- GenericTreeView.java 29 Jan 2007 15:47:20 -0000 1.69 *************** *** 493,497 **** * @return the menu */ ! public JPopupMenu menu() { JPopupMenu pm = null; Object object = this.getUserObject(); --- 493,497 ---- * @return the menu */ ! public JPopupMenu menu() { JPopupMenu pm = null; Object object = this.getUserObject(); *************** *** 520,530 **** public SpaceNode(Space space) { super(space); Set surfaces = space.getEnvelope(); ! add(new SurfaceContainer("Surfaces", surfaces)); ! add(new ElementContainer("Elements", space.getElements())); add(new GeometryContainer("Geometry", space)); ! if (space.isContainer()) { ! ContainerNode cn = new ConstructorContainer("Constructors", space.getConstructors()); ! add(cn); ContainerNode tc = new TransformationContainer("Transformations", space.getTransformations().stack()); --- 520,548 ---- public SpaceNode(Space space) { super(space); + if (space.isInstance()) { + // Instances + makeInstanceContent(space); + } else if (space.isContainer()) { + // Containers both unions and soforth + makeContainerContent(space); + } else { + // NON-container spaces + Set surfaces = space.getEnvelope(); + add(new SurfaceContainer("Surfaces", surfaces)); + } + } + + /** + * Make the tree content for the space that is a container + * @param space the space + */ + private void makeContainerContent(Space space) { Set surfaces = space.getEnvelope(); ! add(new SurfaceContainer("Envelope", surfaces)); ! add(new ElementContainer(space.getElements())); add(new GeometryContainer("Geometry", space)); ! ContainerNode cn = new ConstructorContainer("Constructors", space.getConstructors()); ! add(cn); ! if (space.isUnion()) { ContainerNode tc = new TransformationContainer("Transformations", space.getTransformations().stack()); *************** *** 536,540 **** } } ! /** * Update the node with the given object --- 554,573 ---- } } ! ! /** ! * Generate the tree content for a space that is a instance ! * @param space The space ! */ ! private void makeInstanceContent(Space space) { ! Set surfaces = space.getEnvelope(); ! add(new SurfaceContainer("Envelope", surfaces)); ! SpaceNode proto = new SpaceNode(space.getProto()); ! add(proto); ! ContainerNode tc = ! new TransformationContainer("Transformations", space.getTransformations().stack()); ! tc.update(space.getTransformations().stack()); ! add(tc); ! } ! /** * Update the node with the given object *************** *** 544,572 **** if (o instanceof Space) { Space s = (Space)o; ! userObject = s; ! if (updated == s) { ! model.nodeChanged(this); ! } ! ((GenericNode)getChildAt(0)).update(s.getEnvelope()); ! ((GenericNode)getChildAt(1)).update(s.getElements()); ! ((GenericNode)getChildAt(2)).update(s); ! if (s.isContainer()) { ! ((GenericNode)getChildAt(3)).update(s.getConstructors()); ! ((GenericNode)getChildAt(4)).update(s.getTransformations().stack()); ! if (s.getModellor() != null) { ! if (getChildCount() == 6) { ! ((GenericNode)getChildAt(5)).update(s.getModellor()); } else { ! add(new ModellorNode(s.getModellor())); ! model.nodesWereInserted(this, new int[]{5}); } } else { ! if (getChildCount() == 6) { ! TreeNode node = getChildAt(5); ! remove(5); ! model.nodesWereRemoved(this, new int[]{5}, new Object[]{node}); ! } } } } } --- 577,635 ---- if (o instanceof Space) { Space s = (Space)o; ! if (s.isInstance()) { ! if (this.getChildCount() == 3) { ! ((GenericNode)getChildAt(0)).update(s.getEnvelope()); ! ((GenericNode)getChildAt(1)).update(s.getProto()); ! ((GenericNode)getChildAt(2)).update(s.getTransformations().stack()); ! } else { ! removeAllChildren(); ! makeInstanceContent(s); ! model.nodeStructureChanged(this); ! } ! } else if (s.isContainer()) { ! if (((Space)userObject).isContainer()) { ! //the old object were a container as well ! ((GenericNode)getChildAt(0)).update(s.getEnvelope()); ! ((GenericNode)getChildAt(1)).update(s.getElements()); ! ((GenericNode)getChildAt(2)).update(s); ! ((GenericNode)getChildAt(3)).update(s.getConstructors()); ! int placement = 4; ! if (s.isUnion()) { ! placement++; ! ((GenericNode)getChildAt(4)).update(s.getTransformations().stack()); ! } ! if (s.getModellor() != null) { ! if (getChildCount() == placement + 1) { ! ((GenericNode)getChildAt(placement)).update(s.getModellor()); ! } else { ! add(new ModellorNode(s.getModellor())); ! model.nodesWereInserted(this, new int[]{5}); ! } } else { ! if (getChildCount() == placement + 1) { ! TreeNode node = getChildAt(placement); ! remove(placement); ! model.nodesWereRemoved(this, new int[]{placement}, new Object[]{node}); ! } } } else { ! removeAllChildren(); ! makeContainerContent(s); ! model.nodeStructureChanged(this); ! } ! } else { ! if (this.getChildCount() == 1) { ! ((GenericNode)getChildAt(0)).update(s.getEnvelope()); ! } else { ! removeAllChildren(); ! add(new SurfaceContainer("Surfaces", s.getEnvelope())); ! model.nodeStructureChanged(this); } } + // Update the user object + userObject = s; + if (updated == s) { + model.nodeChanged(this); + } } } *************** *** 824,832 **** /** * Constructor - * @param name The name * @param elements The elements */ ! public ElementContainer(String name, Collection elements) { ! super(name, elements); insertChildren(elements); } --- 887,900 ---- /** * Constructor * @param elements The elements */ ! public ElementContainer(Collection elements) { ! super("", elements); ! Iterator iter = elements.iterator(); ! setUserObject("Unknown"); ! if (iter.hasNext()) { ! Space s = (Space)iter.next(); ! setUserObject(s.getLevelString()); ! } insertChildren(elements); } |