1 | @Override | | 1 | @Override |
2 | public void setEnclosingFig(Fig encloser) { | | 2 | public void setEnclosingFig(Fig encloser) { |
3 | if (getOwner() != null) { | | 3 | |
4 | Object nod = getOwner(); | | 4 | if (getOwner() != null) { |
5 | if (encloser != null) { | | 5 | Object comp = getOwner(); |
6 | Object comp = encloser.getOwner(); | | 6 | if (encloser != null) { |
7 | if (Model.getFacade().isAComponentInstance(comp)) { | | 7 | Object nodeOrComp = encloser.getOwner(); |
8 | if (Model.getFacade().getComponentInstance(nod) != comp) { | | 8 | if (Model.getFacade().isANodeInstance(nodeOrComp)) { |
9 | Model.getCommonBehaviorHelper() | | 9 | if (Model.getFacade() |
10 | .setComponentInstance(nod, comp); | | 10 | .getNodeInstance(comp) != nodeOrComp) { |
11 | super.setEnclosingFig(encloser); | | 11 | Model.getCommonBehaviorHelper() |
12 | } | | 12 | .setNodeInstance(comp, nodeOrComp); |
13 | } else if (Model.getFacade().isANode(comp)) { | | 13 | super.setEnclosingFig(encloser); |
14 | super.setEnclosingFig(encloser); | | 14 | } |
15 | } | | 15 | } else if (Model.getFacade().isAComponentInstance(nodeOrComp)) { |
16 | } else if (encloser == null) { | | 16 | if (Model.getFacade() |
17 | if (isVisible() | | 17 | .getComponentInstance(comp) != nodeOrComp) { |
18 | // If we are not visible most likely | | 18 | Model.getCommonBehaviorHelper() |
19 | // we're being deleted. | | 19 | .setComponentInstance(comp, nodeOrComp); |
20 | // TODO: This indicates a more fundamental problem that | | 20 | super.setEnclosingFig(encloser); |
21 | // should be investigated - tfm - 20061230 | | 21 | } |
22 | && Model.getFacade().getComponentInstance(nod) != null) { | | 22 | } else if (Model.getFacade().isANode(nodeOrComp)) { |
23 | Model.getCommonBehaviorHelper() | | 23 | super.setEnclosingFig(encloser); |
24 | .setComponentInstance(nod, null); | | 24 | } |
25 | super.setEnclosingFig(encloser); | | 25 | |
26 | } | | 26 | if (getLayer() != null) { |
27 | } | | 27 | // elementOrdering(figures); |
28 | } | | 28 | List contents = new ArrayList(getLayer().getContents()); |
29 | | | 29 | Iterator it = contents.iterator(); |
30 | if (getLayer() != null) { | | 30 | while (it.hasNext()) { |
31 | // elementOrdering(figures); | | 31 | Object o = it.next(); |
32 | Collection contents = new ArrayList(getLayer().getContents()); | | 32 | if (o instanceof FigEdgeModelElement) { |
33 | for (Object o : contents) { | | 33 | FigEdgeModelElement figedge = |
34 | if (o instanceof FigEdgeModelElement) { | | 34 | (FigEdgeModelElement) o; |
35 | FigEdgeModelElement figedge = (FigEdgeModelElement) o; | | 35 | figedge.getLayer().bringToFront(figedge); |
36 | figedge.getLayer().bringToFront(figedge); | | 36 | } |
37 | } | | 37 | } |
38 | } | | 38 | } |
39 | } | | 39 | } else if (isVisible() |
40 | } | | 40 | // If we are not visible most likely we're being deleted. |
| | | 41 | // TODO: This indicates a more fundamental problem that |
| | | 42 | // should be investigated - tfm - 20061230 |
| | | 43 | && encloser == null && getEnclosingFig() != null) { |
| | | 44 | if (Model.getFacade().getNodeInstance(comp) != null) { |
| | | 45 | Model.getCommonBehaviorHelper() |
| | | 46 | .setNodeInstance(comp, null); |
| | | 47 | } |
| | | 48 | if (Model.getFacade().getComponentInstance(comp) != null) { |
| | | 49 | Model.getCommonBehaviorHelper() |
| | | 50 | .setComponentInstance(comp, null); |
| | | 51 | } |
| | | 52 | super.setEnclosingFig(encloser); |
| | | 53 | } |
| | | 54 | } |
| | | 55 | } |