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