Skip to content

Commit 0ec951b

Browse files
committed
#13 Fixing child deletion
1 parent 93c104c commit 0ec951b

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

src/ca/mcgill/cs/stg/jetuml/framework/GraphModificationListener.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ public GraphModificationListener(UndoManager pUndo)
4747
public void nodeAdded(Graph pGraph, Node pNode)
4848
{
4949
AddDeleteNodeCommand ac = new AddDeleteNodeCommand(pGraph, pNode, true);
50-
if(pNode.getParent() != null)
51-
{
52-
aUndoManager.startTracking();
53-
childAttached(pGraph, pNode.getParent().getChildren().indexOf(pNode), pNode.getParent(), pNode);
54-
aUndoManager.add(ac);
55-
aUndoManager.endTracking();
56-
return;
57-
}
50+
// if(pNode.getParent() != null)
51+
// {
52+
// aUndoManager.startTracking();
53+
// childAttached(pGraph, pNode.getParent().getChildren().indexOf(pNode), pNode.getParent(), pNode);
54+
// aUndoManager.add(ac);
55+
// aUndoManager.endTracking();
56+
// return;
57+
// }
5858
aUndoManager.add(ac);
5959
}
6060

@@ -66,14 +66,14 @@ public void nodeAdded(Graph pGraph, Node pNode)
6666
public void nodeRemoved(Graph pGraph, Node pNode)
6767
{
6868
AddDeleteNodeCommand dc = new AddDeleteNodeCommand(pGraph, pNode, false);
69-
if(pNode.getParent() != null)
70-
{
71-
aUndoManager.startTracking();
72-
childDetached(pGraph, pNode.getParent().getChildren().indexOf(pNode), pNode.getParent(), pNode);
73-
aUndoManager.add(dc);
74-
aUndoManager.endTracking();
75-
return;
76-
}
69+
// if(pNode.getParent() != null)
70+
// {
71+
// aUndoManager.startTracking();
72+
// childDetached(pGraph, pNode.getParent().getChildren().indexOf(pNode), pNode.getParent(), pNode);
73+
// aUndoManager.add(dc);
74+
// aUndoManager.endTracking();
75+
// return;
76+
// }
7777
aUndoManager.add(dc);
7878
}
7979

src/ca/mcgill/cs/stg/jetuml/graph/Graph.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public abstract class Graph
4646
private transient ArrayList<Edge> aEdgesToBeRemoved;
4747
private transient boolean aNeedsLayout;
4848
private transient Rectangle2D aMinBounds;
49-
private GraphModificationListener aModListener;
49+
protected GraphModificationListener aModListener;
5050

5151
/**
5252
* Constructs a graph with no nodes or edges.
@@ -126,8 +126,6 @@ public boolean add(Node pNode, Point2D pPoint)
126126
boolean accepted = false;
127127
/* A variable commented out during testing. @JoelChev */
128128
//boolean insideANode = false;
129-
aModListener.startCompoundListening();
130-
aModListener.nodeAdded(this, pNode);
131129
for(int i = aNodes.size() - 1; i >= 0 && !accepted; i--)
132130
{
133131
Node parent = aNodes.get(i);
@@ -144,7 +142,7 @@ public boolean add(Node pNode, Point2D pPoint)
144142
// System.out.println("FALSE!");
145143
// return false;
146144
// }
147-
aModListener.endCompoundListening();
145+
aModListener.nodeAdded(this, pNode);
148146
aNodes.add(pNode);
149147
aNeedsLayout = true;
150148
return true;
@@ -239,7 +237,6 @@ public void removeNode(Node pNode)
239237
}
240238
aModListener.startCompoundListening();
241239
aNodesToBeRemoved.add(pNode);
242-
aModListener.nodeRemoved(this, pNode);
243240
// notify nodes of removals
244241
for(int i = 0; i < aNodes.size(); i++)
245242
{
@@ -263,6 +260,7 @@ public void removeNode(Node pNode)
263260
{
264261
removeNode(childNode);
265262
}
263+
aModListener.nodeRemoved(this, pNode);
266264
aModListener.endCompoundListening();
267265
aNeedsLayout = true;
268266
}

0 commit comments

Comments
 (0)