[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Space.java,1.29,1.30 Project.java,1.5
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2006-05-08 23:55:24
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5200/src/net/sourceforge/bprocessor/model Modified Files: Space.java Project.java Persistence.java Log Message: Persistens saves the entity id's to xml so that the id's matches the old ones... Have made a change to all the add(entity) methods so that is the given object already have an assigned id it will use that and set the id counter to that value... Added a id to the world space otherwise the conversion from and to xml chokes... Index: Persistence.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Persistence.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Persistence.java 5 Apr 2006 09:35:58 -0000 1.1 --- Persistence.java 7 May 2006 09:33:36 -0000 1.2 *************** *** 118,121 **** --- 118,122 ---- boolean container = (empty != 0); Space space = new Space(name, type, container); + space.setId(new Long(xml.getProgid())); space.setDescription(xml.getDescription()); mapper.put(new Long(xml.getId()), space); *************** *** 175,178 **** --- 176,180 ---- private static Surface internalizeSurface(SurfaceType xml, Map mapper, Collection xmls) { Surface surface = new Surface(); + surface.setId(new Long(xml.getProgid())); mapper.put(new Long(xml.getId()), surface); xmls.add(xml); *************** *** 189,192 **** --- 191,195 ---- private static Edge internalizeEdge(EdgeType xml, Map mapper, Collection xmls) { Edge edge = new Edge(); + edge.setId(new Long(xml.getProgid())); mapper.put(new Long(xml.getId()), edge); xmls.add(xml); *************** *** 204,207 **** --- 207,211 ---- private static Vertex internalizeVertex(VertexType xml, Map mapper, Collection xmls) { Vertex vertex = new Vertex(); + vertex.setId(new Long(xml.getProgid())); mapper.put(new Long(xml.getId()), vertex); xmls.add(xml); *************** *** 385,388 **** --- 389,393 ---- SpaceType xml = new SpaceImpl(); xml.setId(counter++); + xml.setProgid(space.getId().longValue()); xml.setName(space.getName()); xml.setType(space.getType()); *************** *** 430,433 **** --- 435,439 ---- SurfaceType xml = new SurfaceImpl(); xml.setId(counter++); + xml.setProgid(surface.getId().longValue()); map.put(surface, xml); return xml; *************** *** 443,446 **** --- 449,453 ---- EdgeType xml = new EdgeImpl(); xml.setId(counter++); + xml.setProgid(edge.getId().longValue()); map.put(edge, xml); xml.setConstructor(edge.getConstructor()); *************** *** 457,460 **** --- 464,468 ---- VertexType xml = new VertexImpl(); xml.setId(counter++); + xml.setProgid(vertex.getId().longValue()); map.put(vertex, xml); xml.setX(vertex.getX()); Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Space.java 3 May 2006 10:12:34 -0000 1.29 --- Space.java 7 May 2006 09:33:36 -0000 1.30 *************** *** 249,254 **** public void add(Vertex vertex) { if (container) { ! Long id = new Long(nextVertexId++); ! vertex.setId(id); vertices.put(id, vertex); vertex.setOwner(this); --- 249,260 ---- public void add(Vertex vertex) { if (container) { ! Long id; ! if (vertex.getId() != null) { ! id = vertex.getId(); ! nextVertexId = Math.max(nextVertexId, id.longValue() + 1); ! } else { ! id = new Long(nextVertexId++); ! vertex.setId(id); ! } vertices.put(id, vertex); vertex.setOwner(this); *************** *** 321,326 **** public void add(Edge edge) { if (container) { ! Long id = new Long(nextEdgeId++); ! edge.setId(id); edges.put(id, edge); edge.setOwner(this); --- 327,338 ---- public void add(Edge edge) { if (container) { ! Long id; ! if (edge.getId() != null) { ! id = edge.getId(); ! nextEdgeId = Math.max(nextEdgeId, id.longValue() + 1); ! } else { ! id = new Long(nextEdgeId++); ! edge.setId(id); ! } edges.put(id, edge); edge.setOwner(this); *************** *** 501,506 **** public void add(Surface surface) { if (container) { ! Long id = new Long(nextSurfaceId++); ! surface.setId(id); surfaces.put(id, surface); surface.setOwner(this); --- 513,524 ---- public void add(Surface surface) { if (container) { ! Long id; ! if (surface.getId() != null) { ! id = surface.getId(); ! nextSurfaceId = Math.max(nextSurfaceId, id.longValue() + 1); ! } else { ! id = new Long(nextSurfaceId++); ! surface.setId(id); ! } surfaces.put(id, surface); surface.setOwner(this); *************** *** 703,708 **** public void add(Space element) { if (container) { ! Long id = new Long(nextElementId++); ! element.setId(id); elements.put(id, element); } else { --- 721,732 ---- public void add(Space element) { if (container) { ! Long id; ! if (element.getId() != null) { ! id = element.getId(); ! nextElementId = Math.max(nextElementId, id.longValue() + 1); ! } else { ! id = new Long(nextElementId++); ! element.setId(id); ! } elements.put(id, element); } else { Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** Project.java 21 Apr 2006 15:23:06 -0000 1.55 --- Project.java 7 May 2006 09:33:36 -0000 1.56 *************** *** 96,99 **** --- 96,100 ---- observers = new LinkedList(); world = new Space("World", Space.FUNCTIONAL, true); + world.setId(new Long(0)); constraints = new LinkedList(); } *************** *** 659,669 **** } currentState = (Bmodel) undoStack.pop(); ! clear(); ! Persistence.internalize(currentState); } } /** ! * Redo */ public void redo() { --- 660,669 ---- } currentState = (Bmodel) undoStack.pop(); ! setState(currentState); } } /** ! * Redo the state to currentState */ public void redo() { *************** *** 673,682 **** } currentState = (Bmodel) redoStack.pop(); ! clear(); ! Persistence.internalize(currentState); } } /** * Reset undo/redo history */ --- 673,697 ---- } currentState = (Bmodel) redoStack.pop(); ! setState(currentState); } } /** + * Set the state of the program to the given state + * @param state the state to use + */ + public void setState(Bmodel state) { + clear(); + Persistence.internalize(state); + } + + /** + * Reset the state to currentState + */ + public void resetState() { + setState(currentState); + } + + /** * Reset undo/redo history */ |