KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > swing > ContainerImpl


1 // skeleton class automatically generated
2

3 package org.objectweb.fractal.swing;
4
5 import org.objectweb.fractal.api.control.BindingController;
6
7 import java.util.HashMap JavaDoc;
8 import java.util.Map JavaDoc;
9 import java.awt.Component JavaDoc;
10
11 import javax.swing.JComponent JavaDoc;
12
13 public class ContainerImpl
14   extends java.awt.Container JavaDoc
15   implements ContainerItf, ContainerAttributes, BindingController
16 {
17
18   // fields manually added
19
public final static String JavaDoc LEFT_COMPONENT_BINDING = "left-component";
20   public final static String JavaDoc TOP_COMPONENT_BINDING = "top-component";
21   public final static String JavaDoc RIGHT_COMPONENT_BINDING = "right-component";
22   public final static String JavaDoc BOTTOM_COMPONENT_BINDING = "bottom-component";
23   public final static String JavaDoc CENTER_COMPONENT_BINDING = "center-component";
24   public final static String JavaDoc COMPONENTS_BINDING = "components";
25   public final static String JavaDoc LAYOUT_BINDING = "layout";
26   private JComponent JavaDoc left, top, right, bottom, center;
27   private Map JavaDoc components = new HashMap JavaDoc();
28   private java.awt.LayoutManager JavaDoc layout;
29
30   public ContainerImpl () {
31     super();
32   }
33
34   public String JavaDoc[] listFc () {
35     int s = components.size();
36     String JavaDoc[] result = (String JavaDoc[])components.keySet().toArray(new String JavaDoc[s + 6]);
37     result[s] = LEFT_COMPONENT_BINDING;
38     result[s+1] = TOP_COMPONENT_BINDING;
39     result[s+2] = RIGHT_COMPONENT_BINDING;
40     result[s+3] = BOTTOM_COMPONENT_BINDING;
41     result[s+4] = CENTER_COMPONENT_BINDING;
42     result[s+5] = LAYOUT_BINDING;
43     return result;
44   }
45
46   public Object JavaDoc lookupFc (String JavaDoc clientItfName) {
47     // put your own code here
48
if (clientItfName.equals(LEFT_COMPONENT_BINDING)) {
49       return left;
50     } if (clientItfName.equals(TOP_COMPONENT_BINDING)) {
51       return top;
52     } if (clientItfName.equals(RIGHT_COMPONENT_BINDING)) {
53       return right;
54     } if (clientItfName.equals(BOTTOM_COMPONENT_BINDING)) {
55       return bottom;
56     } if (clientItfName.equals(CENTER_COMPONENT_BINDING)) {
57       return center;
58     } else if (clientItfName.startsWith(COMPONENTS_BINDING)) {
59       return components.get(clientItfName);
60     } else if (clientItfName.equals(LAYOUT_BINDING)) {
61       return layout;
62     }
63     return null;
64   }
65
66   public void bindFc (String JavaDoc clientItfName, Object JavaDoc serverItf) {
67     // put your own code here
68
if (clientItfName.equals(LEFT_COMPONENT_BINDING)) {
69       left = (JComponent JavaDoc)serverItf;
70       super.add(left, "West");
71       validate();
72       repaint();
73     } if (clientItfName.equals(TOP_COMPONENT_BINDING)) {
74       top = (JComponent JavaDoc)serverItf;
75       super.add(top, "North");
76       validate();
77       repaint();
78     } if (clientItfName.equals(RIGHT_COMPONENT_BINDING)) {
79       right = (JComponent JavaDoc)serverItf;
80       super.add(right, "East");
81       validate();
82       repaint();
83     } if (clientItfName.equals(BOTTOM_COMPONENT_BINDING)) {
84       bottom = (JComponent JavaDoc)serverItf;
85       super.add(bottom, "South");
86       validate();
87       repaint();
88     } if (clientItfName.equals(CENTER_COMPONENT_BINDING)) {
89       center = (JComponent JavaDoc)serverItf;
90       super.add(center, "Center");
91       validate();
92       repaint();
93     } else if (clientItfName.startsWith(COMPONENTS_BINDING)) {
94       components.put(clientItfName, serverItf);
95       super.add((java.awt.Component JavaDoc)serverItf);
96       validate();
97       repaint();
98     } else if (clientItfName.equals(LAYOUT_BINDING)) {
99       layout = (java.awt.LayoutManager JavaDoc)serverItf;
100       super.setLayout(layout);
101       validate();
102       repaint();
103     }
104   }
105
106   public void unbindFc (String JavaDoc clientItfName) {
107     // put your own code here
108
if (clientItfName.equals(LEFT_COMPONENT_BINDING)) {
109       super.remove(left);
110       validate();
111       repaint();
112       left = null;
113     } if (clientItfName.equals(TOP_COMPONENT_BINDING)) {
114       super.remove(top);
115       validate();
116       repaint();
117       top = null;
118     } if (clientItfName.equals(RIGHT_COMPONENT_BINDING)) {
119       super.remove(right);
120       validate();
121       repaint();
122       right = null;
123     } if (clientItfName.equals(BOTTOM_COMPONENT_BINDING)) {
124       super.remove(bottom);
125       validate();
126       repaint();
127       bottom = null;
128     } if (clientItfName.equals(CENTER_COMPONENT_BINDING)) {
129       super.remove(center);
130       validate();
131       repaint();
132       center = null;
133     } else if (clientItfName.startsWith(COMPONENTS_BINDING)) {
134       Component JavaDoc c = (Component JavaDoc)components.get(clientItfName);
135       super.remove(c);
136       validate();
137       repaint();
138     } else if (clientItfName.equals(LAYOUT_BINDING)) {
139       layout = null;
140     }
141   }
142
143 }
144
Popular Tags