KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > poa > gui > pm > StatePanel


1 package org.jacorb.poa.gui.pm;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2004 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22  
23 /**
24  * @author Reimo Tiedemann, FU Berlin
25  * @version 1.0, 05/03/99, RT
26  */

27 public class StatePanel extends java.awt.Panel JavaDoc implements java.awt.event.ItemListener JavaDoc {
28     private StatePanelController controller = null;
29     private java.awt.Choice JavaDoc ivjStateChoice = null;
30     private java.awt.Label JavaDoc ivjStateLabel = null;
31     private java.awt.Checkbox JavaDoc ivjWaitCheckbox = null;
32     private java.awt.Panel JavaDoc ivjChoicePanel = null;
33     private java.awt.BorderLayout JavaDoc ivjStatePanelBorderLayout = null;
34     private java.awt.Checkbox JavaDoc ivjEtherializeCheckbox = null;
35 /**
36  * Constructor
37  */

38 /* WARNING: THIS METHOD WILL BE REGENERATED. */
39 public StatePanel() {
40     super();
41     initialize();
42 }
43 /**
44  * StatePanel constructor comment.
45  * @param layout java.awt.LayoutManager
46  */

47 public StatePanel(java.awt.LayoutManager JavaDoc layout) {
48     super(layout);
49 }
50 java.awt.Checkbox JavaDoc _getEtherializeCheckbox() {
51     return getEtherializeCheckbox();
52 }
53 java.awt.Choice JavaDoc _getStateChoice() {
54     return getStateChoice();
55 }
56 java.awt.Checkbox JavaDoc _getWaitCheckbox() {
57     return getWaitCheckbox();
58 }
59 void _init(StatePanelController _controller) {
60     controller = _controller;
61 }
62 private void _stateItemChanged(String JavaDoc item, boolean wait, boolean etherialize) {
63     if (controller != null) {
64         controller._stateItemChanged(item, wait, etherialize);
65     }
66 }
67 /**
68  * connEtoC1: (StateChoice.item.itemStateChanged(java.awt.event.ItemEvent) --> StatePanel._stateItemChanged(Ljava.lang.String;ZZ)V)
69  * @param arg1 java.awt.event.ItemEvent
70  */

71 /* WARNING: THIS METHOD WILL BE REGENERATED. */
72 private void connEtoC1(java.awt.event.ItemEvent JavaDoc arg1) {
73     try {
74         // user code begin {1}
75
// user code end
76
this._stateItemChanged(getStateChoice().getSelectedItem(), getWaitCheckbox().getState(), getEtherializeCheckbox().getState());
77         // user code begin {2}
78
// user code end
79
} catch (java.lang.Throwable JavaDoc ivjExc) {
80         // user code begin {3}
81
// user code end
82
handleException(ivjExc);
83     }
84 }
85 /**
86  * Return the ChoicePanel property value.
87  * @return java.awt.Panel
88  */

89 /* WARNING: THIS METHOD WILL BE REGENERATED. */
90 private java.awt.Panel JavaDoc getChoicePanel() {
91     java.awt.GridBagConstraints JavaDoc constraintsStateChoice = new java.awt.GridBagConstraints JavaDoc();
92     java.awt.GridBagConstraints JavaDoc constraintsWaitCheckbox = new java.awt.GridBagConstraints JavaDoc();
93     java.awt.GridBagConstraints JavaDoc constraintsEtherializeCheckbox = new java.awt.GridBagConstraints JavaDoc();
94     if (ivjChoicePanel == null) {
95         try {
96             ivjChoicePanel = new java.awt.Panel JavaDoc();
97             ivjChoicePanel.setName("ChoicePanel");
98             ivjChoicePanel.setLayout(new java.awt.GridBagLayout JavaDoc());
99
100             constraintsStateChoice.gridx = 0; constraintsStateChoice.gridy = 0;
101             constraintsStateChoice.gridwidth = 1; constraintsStateChoice.gridheight = 1;
102             constraintsStateChoice.fill = java.awt.GridBagConstraints.HORIZONTAL;
103             constraintsStateChoice.anchor = java.awt.GridBagConstraints.WEST;
104             constraintsStateChoice.weightx = 1.0;
105             constraintsStateChoice.weighty = 0.0;
106             constraintsStateChoice.insets = new java.awt.Insets JavaDoc(0, 10, 0, 0);
107             getChoicePanel().add(getStateChoice(), constraintsStateChoice);
108
109             constraintsWaitCheckbox.gridx = 0; constraintsWaitCheckbox.gridy = 1;
110             constraintsWaitCheckbox.gridwidth = 1; constraintsWaitCheckbox.gridheight = 1;
111             constraintsWaitCheckbox.fill = java.awt.GridBagConstraints.HORIZONTAL;
112             constraintsWaitCheckbox.anchor = java.awt.GridBagConstraints.WEST;
113             constraintsWaitCheckbox.weightx = 0.0;
114             constraintsWaitCheckbox.weighty = 0.0;
115             constraintsWaitCheckbox.insets = new java.awt.Insets JavaDoc(5, 10, 0, 0);
116             getChoicePanel().add(getWaitCheckbox(), constraintsWaitCheckbox);
117
118             constraintsEtherializeCheckbox.gridx = 0; constraintsEtherializeCheckbox.gridy = 2;
119             constraintsEtherializeCheckbox.gridwidth = 1; constraintsEtherializeCheckbox.gridheight = 1;
120             constraintsEtherializeCheckbox.fill = java.awt.GridBagConstraints.HORIZONTAL;
121             constraintsEtherializeCheckbox.anchor = java.awt.GridBagConstraints.WEST;
122             constraintsEtherializeCheckbox.weightx = 1.0;
123             constraintsEtherializeCheckbox.weighty = 0.0;
124             constraintsEtherializeCheckbox.insets = new java.awt.Insets JavaDoc(0, 10, 0, 0);
125             getChoicePanel().add(getEtherializeCheckbox(), constraintsEtherializeCheckbox);
126             // user code begin {1}
127
// user code end
128
} catch (java.lang.Throwable JavaDoc ivjExc) {
129             // user code begin {2}
130
// user code end
131
handleException(ivjExc);
132         }
133     };
134     return ivjChoicePanel;
135 }
136 /**
137  * Return the EhterializeCheckbox property value.
138  * @return java.awt.Checkbox
139  */

140 /* WARNING: THIS METHOD WILL BE REGENERATED. */
141 private java.awt.Checkbox JavaDoc getEtherializeCheckbox() {
142     if (ivjEtherializeCheckbox == null) {
143         try {
144             ivjEtherializeCheckbox = new java.awt.Checkbox JavaDoc();
145             ivjEtherializeCheckbox.setName("EtherializeCheckbox");
146             ivjEtherializeCheckbox.setFont(new java.awt.Font JavaDoc("dialog", 2, 10));
147             ivjEtherializeCheckbox.setLabel("etherialize_objects");
148             // user code begin {1}
149
// user code end
150
} catch (java.lang.Throwable JavaDoc ivjExc) {
151             // user code begin {2}
152
// user code end
153
handleException(ivjExc);
154         }
155     };
156     return ivjEtherializeCheckbox;
157 }
158 /**
159  * Return the StateChoice property value.
160  * @return java.awt.Choice
161  */

162 /* WARNING: THIS METHOD WILL BE REGENERATED. */
163 private java.awt.Choice JavaDoc getStateChoice() {
164     if (ivjStateChoice == null) {
165         try {
166             ivjStateChoice = new java.awt.Choice JavaDoc();
167             ivjStateChoice.setName("StateChoice");
168             ivjStateChoice.setBackground(java.awt.SystemColor.window);
169             // user code begin {1}
170
// user code end
171
} catch (java.lang.Throwable JavaDoc ivjExc) {
172             // user code begin {2}
173
// user code end
174
handleException(ivjExc);
175         }
176     };
177     return ivjStateChoice;
178 }
179 /**
180  * Return the StateLabel property value.
181  * @return java.awt.Label
182  */

183 /* WARNING: THIS METHOD WILL BE REGENERATED. */
184 private java.awt.Label JavaDoc getStateLabel() {
185     if (ivjStateLabel == null) {
186         try {
187             ivjStateLabel = new java.awt.Label JavaDoc();
188             ivjStateLabel.setName("StateLabel");
189             ivjStateLabel.setText(" State:");
190             ivjStateLabel.setForeground(java.awt.Color.black);
191             // user code begin {1}
192
// user code end
193
} catch (java.lang.Throwable JavaDoc ivjExc) {
194             // user code begin {2}
195
// user code end
196
handleException(ivjExc);
197         }
198     };
199     return ivjStateLabel;
200 }
201 /**
202  * Return the StatePanelBorderLayout property value.
203  * @return java.awt.BorderLayout
204  */

205 /* WARNING: THIS METHOD WILL BE REGENERATED. */
206 private java.awt.BorderLayout JavaDoc getStatePanelBorderLayout() {
207     java.awt.BorderLayout JavaDoc ivjStatePanelBorderLayout = null;
208     try {
209         /* Create part */
210         ivjStatePanelBorderLayout = new java.awt.BorderLayout JavaDoc();
211         ivjStatePanelBorderLayout.setVgap(0);
212     } catch (java.lang.Throwable JavaDoc ivjExc) {
213         handleException(ivjExc);
214     };
215     return ivjStatePanelBorderLayout;
216 }
217 /**
218  * Return the WaitCheckbox property value.
219  * @return java.awt.Checkbox
220  */

221 /* WARNING: THIS METHOD WILL BE REGENERATED. */
222 private java.awt.Checkbox JavaDoc getWaitCheckbox() {
223     if (ivjWaitCheckbox == null) {
224         try {
225             ivjWaitCheckbox = new java.awt.Checkbox JavaDoc();
226             ivjWaitCheckbox.setName("WaitCheckbox");
227             ivjWaitCheckbox.setFont(new java.awt.Font JavaDoc("dialog", 2, 10));
228             ivjWaitCheckbox.setLabel("wait_for_completion");
229             // user code begin {1}
230
// user code end
231
} catch (java.lang.Throwable JavaDoc ivjExc) {
232             // user code begin {2}
233
// user code end
234
handleException(ivjExc);
235         }
236     };
237     return ivjWaitCheckbox;
238 }
239 /**
240  * Called whenever the part throws an exception.
241  * @param exception java.lang.Throwable
242  */

243 private void handleException(Throwable JavaDoc exception) {
244
245     /* Uncomment the following lines to print uncaught exceptions to stdout */
246     // System.out.println("--------- UNCAUGHT EXCEPTION ---------");
247
// exception.printStackTrace(System.out);
248
}
249 /**
250  * Initializes connections
251  */

252 /* WARNING: THIS METHOD WILL BE REGENERATED. */
253 private void initConnections() {
254     // user code begin {1}
255
// user code end
256
getStateChoice().addItemListener(this);
257 }
258 /**
259  * Initialize the class.
260  */

261 /* WARNING: THIS METHOD WILL BE REGENERATED. */
262 private void initialize() {
263     // user code begin {1}
264
// user code end
265
setName("StatePanel");
266     setLayout(getStatePanelBorderLayout());
267     setBackground(java.awt.SystemColor.control);
268     setSize(125, 90);
269     add(getStateLabel(), "North");
270     add(getChoicePanel(), "Center");
271     initConnections();
272     // user code begin {2}
273
// user code end
274
}
275 /**
276  * Method to handle events for the ItemListener interface.
277  * @param e java.awt.event.ItemEvent
278  */

279 /* WARNING: THIS METHOD WILL BE REGENERATED. */
280 public void itemStateChanged(java.awt.event.ItemEvent JavaDoc e) {
281     // user code begin {1}
282
// user code end
283
if ((e.getSource() == getStateChoice()) ) {
284         connEtoC1(e);
285     }
286     // user code begin {2}
287
// user code end
288
}
289 /**
290  * main entrypoint - starts the part when it is run as an application
291  * @param args java.lang.String[]
292  */

293 public static void main(java.lang.String JavaDoc[] args) {
294     try {
295         java.awt.Frame JavaDoc frame;
296         try {
297             Class JavaDoc aFrameClass = Class.forName("com.ibm.uvm.abt.edit.TestFrame");
298             frame = (java.awt.Frame JavaDoc)aFrameClass.newInstance();
299         } catch (java.lang.Throwable JavaDoc ivjExc) {
300             frame = new java.awt.Frame JavaDoc();
301         }
302         StatePanel aStatePanel;
303         aStatePanel = new StatePanel();
304         frame.add("Center", aStatePanel);
305         frame.setSize(aStatePanel.getSize());
306         frame.setVisible(true);
307     } catch (Throwable JavaDoc exception) {
308         System.err.println("Exception occurred in main() of java.awt.Panel");
309         exception.printStackTrace(System.out);
310     }
311 }
312
313 }
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
Popular Tags