KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > julia > control > content > BasicSuperControllerMixin


1 /***
2  * Julia: France Telecom's implementation of the Fractal API
3  * Copyright (C) 2001-2002 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: Eric.Bruneton@rd.francetelecom.com
20  *
21  * Author: Eric Bruneton
22  */

23
24 package org.objectweb.fractal.julia.control.content;
25
26 import org.objectweb.fractal.api.Component;
27
28 /**
29  * Provides a basic implementation of the {@link SuperControllerNotifier}
30  * interface.
31  * <br>
32  * <br>
33  * <b>Requirements</b>
34  * <ul>
35  * <li>none.</li>
36  * </ul>
37  */

38
39 public abstract class BasicSuperControllerMixin
40   implements SuperControllerNotifier
41 {
42
43   // -------------------------------------------------------------------------
44
// Private constructor
45
// -------------------------------------------------------------------------
46

47   private BasicSuperControllerMixin () {
48   }
49
50   // -------------------------------------------------------------------------
51
// Fields and methods added and overriden by the mixin class
52
// -------------------------------------------------------------------------
53

54   /**
55    * The parents of the component to which this controller object belongs.
56    */

57
58   public Component[] fcParents;
59
60   public Component[] getFcSuperComponents () {
61     if (fcParents == null) {
62       return new Component[0];
63     } else {
64       return fcParents;
65     }
66   }
67
68   public void addedToFc (final Component parent) {
69     int length = fcParents == null ? 1 : fcParents.length + 1;
70     Component[] parents = new Component[length];
71     if (fcParents != null) {
72       System.arraycopy(fcParents, 0, parents, 1, fcParents.length);
73     }
74     parents[0] = parent;
75     fcParents = parents;
76   }
77
78   public void removedFromFc (final Component parent) {
79     int length = fcParents.length - 1;
80     if (length == 0) {
81       fcParents = null;
82     } else {
83       Component[] parents = new Component[length];
84       int i = 0;
85       for (int j = 0; j < fcParents.length; ++j) {
86         if (!fcParents[j].equals(parent)) {
87           parents[i++] = fcParents[j];
88         }
89       }
90       fcParents = parents;
91     }
92   }
93 }
94
Popular Tags