KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > base > tool > ConnectorConfigurationPanel


1 /*
2  * Created on Jul 19, 2005
3  *
4  * TODO To change the template for this generated file go to
5  * Window - Preferences - Java - Code Style - Code Templates
6  */

7 package org.enhydra.base.tool;
8
9 import java.awt.event.ActionEvent JavaDoc;
10 import java.awt.event.ActionListener JavaDoc;
11
12 import javax.swing.JPanel JavaDoc;
13
14 import javax.swing.AbstractAction JavaDoc;
15 import javax.swing.JCheckBox JavaDoc;
16 import javax.swing.JLabel JavaDoc;
17 import javax.swing.JOptionPane JavaDoc;
18 import javax.swing.JTextField JavaDoc;
19
20 /**
21  * @author slobodan
22  *
23  * TODO To change the template for this generated type comment go to Window -
24  * Preferences - Java - Code Style - Code Templates
25  */

26 public class ConnectorConfigurationPanel extends JPanel JavaDoc {
27
28     private JCheckBox JavaDoc httpConnector = null;
29
30     private JLabel JavaDoc httpConnectorLabel = null;
31
32     private JTextField JavaDoc httpConnectorText = null;
33
34     private JCheckBox JavaDoc sslHTTPConnector = null;
35
36     private JLabel JavaDoc sslHTTPConnectorLabel = null;
37
38     private JTextField JavaDoc sslHTTPConnectorText = null;
39
40     private JCheckBox JavaDoc ajpConnector = null;
41
42     private JLabel JavaDoc ajpConnectorLabel = null;
43
44     private JTextField JavaDoc ajpConnectorText = null;
45
46     private JCheckBox JavaDoc directorConnector = null;
47
48     private JLabel JavaDoc directorConnectorLabel = null;
49
50     private JTextField JavaDoc directorConnectorText = null;
51
52     private JLabel JavaDoc head = null;
53     /**
54      * This is the default constructor
55      */

56     public ConnectorConfigurationPanel() {
57         super();
58         initialize();
59     }
60
61     /**
62      * This method initializes this
63      *
64      * @return void
65      */

66     private void initialize() {
67         head = new JLabel JavaDoc();
68         httpConnectorLabel = new JLabel JavaDoc();
69         sslHTTPConnectorLabel = new JLabel JavaDoc();
70         ajpConnectorLabel = new JLabel JavaDoc();
71         directorConnectorLabel = new JLabel JavaDoc();
72         this.setPreferredSize(new java.awt.Dimension JavaDoc(300, 150));
73         this.setSize(300, 150);
74         httpConnectorLabel.setText("Port:");
75         httpConnectorLabel.setPreferredSize(new java.awt.Dimension JavaDoc(30, 16));
76         httpConnectorLabel.setName("httpConnectorLabel");
77         sslHTTPConnectorLabel.setText("Port:");
78         sslHTTPConnectorLabel.setPreferredSize(new java.awt.Dimension JavaDoc(30, 16));
79         sslHTTPConnectorLabel.setName("sslHTTPConnectorLabel");
80         ajpConnectorLabel.setText("Port:");
81         ajpConnectorLabel.setPreferredSize(new java.awt.Dimension JavaDoc(30, 16));
82         ajpConnectorLabel.setName("ajpConnectorLabel");
83         directorConnectorLabel.setText("Port:");
84         directorConnectorLabel.setPreferredSize(new java.awt.Dimension JavaDoc(30, 16));
85         directorConnectorLabel.setName("directorConnectorLabel");
86         head.setText("");
87         head.setName("head");
88         head.setPreferredSize(new java.awt.Dimension JavaDoc(300,10));
89         this.add(head, null);
90         this.add(getHttpConnector(), null);
91         this.add(httpConnectorLabel, null);
92         this.add(getHttpConnectorText(), null);
93         this.add(getSslHTTPConnector(), null);
94         this.add(sslHTTPConnectorLabel, null);
95         this.add(getSslHTTPConnectorText(), null);
96         this.add(getAjpConnector(), null);
97         this.add(ajpConnectorLabel, null);
98         this.add(getAjpConnectorText(), null);
99         this.add(getDirectorConnector(), null);
100         this.add(directorConnectorLabel, null);
101         this.add(getDirectorConnectorText(), null);
102     }
103
104     /**
105      * This method initializes jCheckBox
106      *
107      * @return javax.swing.JCheckBox
108      */

109     private JCheckBox JavaDoc getHttpConnector() {
110         if (httpConnector == null) {
111             httpConnector = new JCheckBox JavaDoc();
112             httpConnector.setSelected(true);
113             httpConnector.setText("non-SSL HTTP Connector");
114             httpConnector.setName("httpConnector");
115             httpConnector.setPreferredSize(new java.awt.Dimension JavaDoc(175, 24));
116             httpConnector.addActionListener(new CustomActionListener());
117         }
118         return httpConnector;
119     }
120
121     /**
122      * This method initializes jTextField
123      *
124      * @return javax.swing.JTextField
125      */

126     private JTextField JavaDoc getHttpConnectorText() {
127         if (httpConnectorText == null) {
128             httpConnectorText = new JTextField JavaDoc();
129             httpConnectorText.setPreferredSize(new java.awt.Dimension JavaDoc(75, 20));
130             httpConnectorText.setName("httpConnectorText");
131             httpConnectorText.setText("8080");
132         }
133         return httpConnectorText;
134     }
135
136     /**
137      * This method initializes jCheckBox
138      *
139      * @return javax.swing.JCheckBox
140      */

141     private JCheckBox JavaDoc getSslHTTPConnector() {
142         if (sslHTTPConnector == null) {
143             sslHTTPConnector = new JCheckBox JavaDoc();
144             sslHTTPConnector.setText("SSL HTTP Connector");
145             sslHTTPConnector.setPreferredSize(new java.awt.Dimension JavaDoc(175, 24));
146             sslHTTPConnector.setSelected(true);
147             sslHTTPConnector.setName("sslHTTPConnector");
148             sslHTTPConnector.addActionListener(new CustomActionListener());
149         }
150         return sslHTTPConnector;
151     }
152
153     /**
154      * This method initializes jTextField
155      *
156      * @return javax.swing.JTextField
157      */

158     private JTextField JavaDoc getSslHTTPConnectorText() {
159         if (sslHTTPConnectorText == null) {
160             sslHTTPConnectorText = new JTextField JavaDoc();
161             sslHTTPConnectorText
162                     .setPreferredSize(new java.awt.Dimension JavaDoc(75, 20));
163             sslHTTPConnectorText.setName("sslHTTPConnectorText");
164             sslHTTPConnectorText.setText("8443");
165         }
166         return sslHTTPConnectorText;
167     }
168
169     /**
170      * This method initializes jCheckBox
171      *
172      * @return javax.swing.JCheckBox
173      */

174     private JCheckBox JavaDoc getAjpConnector() {
175         if (ajpConnector == null) {
176             ajpConnector = new JCheckBox JavaDoc();
177             ajpConnector.setSelected(true);
178             ajpConnector.setText("AJP Connector");
179             ajpConnector.setName("ajpConnector");
180             ajpConnector.setPreferredSize(new java.awt.Dimension JavaDoc(175, 24));
181             ajpConnector.addActionListener(new CustomActionListener());
182         }
183         return ajpConnector;
184     }
185
186     /**
187      * This method initializes jTextField
188      *
189      * @return javax.swing.JTextField
190      */

191     private JTextField JavaDoc getAjpConnectorText() {
192         if (ajpConnectorText == null) {
193             ajpConnectorText = new JTextField JavaDoc();
194             ajpConnectorText.setPreferredSize(new java.awt.Dimension JavaDoc(75, 20));
195             ajpConnectorText.setName("ajpConnectorLabel");
196             ajpConnectorText.setText("9009");
197         }
198         return ajpConnectorText;
199     }
200
201     /**
202      * This method initializes jCheckBox
203      *
204      * @return javax.swing.JCheckBox
205      */

206     private JCheckBox JavaDoc getDirectorConnector() {
207         if (directorConnector == null) {
208             directorConnector = new JCheckBox JavaDoc();
209             directorConnector.setSelected(true);
210             directorConnector.setText("Director Connector");
211             directorConnector.setName("directorConnector");
212             directorConnector.setPreferredSize(new java.awt.Dimension JavaDoc(175, 24));
213             directorConnector.addActionListener(new CustomActionListener());
214         }
215         return directorConnector;
216     }
217
218     /**
219      * This method initializes jTextField
220      *
221      * @return javax.swing.JTextField
222      */

223     private JTextField JavaDoc getDirectorConnectorText() {
224         if (directorConnectorText == null) {
225             directorConnectorText = new JTextField JavaDoc();
226             directorConnectorText.setPreferredSize(new java.awt.Dimension JavaDoc(75,
227                     20));
228             directorConnectorText.setName("directorConnectorText");
229             directorConnectorText.setText("9003");
230         }
231         return directorConnectorText;
232     }
233     
234     public boolean checkEntries (){
235         boolean valid = true;
236         if (httpConnector.isSelected()){
237             if ("".equals(httpConnectorText.getText())||httpConnectorText.getText()==null){
238                 displayErrorMessage("non-SSL Http Connector Port");
239                 valid = false;
240             } else {
241                 try {
242                     int temp = Integer.parseInt(httpConnectorText.getText());
243                 } catch (NumberFormatException JavaDoc ex){
244                     displayErrorMessage("non-SSL Http Connector Port");
245                     valid = false;
246                 }
247             }
248         }
249         
250         if (sslHTTPConnector.isSelected()){
251             if ("".equals(sslHTTPConnectorText.getText())||sslHTTPConnectorText.getText()==null){
252                 displayErrorMessage("SSL Http Connector Port");
253                 valid = false;
254             } else {
255                 try {
256                     int temp = Integer.parseInt(sslHTTPConnectorText.getText());
257                 } catch (NumberFormatException JavaDoc ex){
258                     displayErrorMessage("SSL Http Connector Port");
259                     valid = false;
260                 }
261             }
262         }
263         
264         if (ajpConnector.isSelected()){
265             if ("".equals(ajpConnectorText.getText())||ajpConnectorText.getText()==null){
266                 displayErrorMessage("AJP Connector Port");
267                 valid = false;
268             } else {
269                 try {
270                     int temp = Integer.parseInt(ajpConnectorText.getText());
271                 } catch (NumberFormatException JavaDoc ex){
272                     displayErrorMessage("AJP Connector Port");
273                     valid = false;
274                 }
275             }
276         }
277         
278         if (directorConnector.isSelected()){
279             if ("".equals(directorConnectorText.getText())||directorConnectorText.getText()==null){
280                 displayErrorMessage("Director Connector Port");
281                 valid = false;
282             } else {
283                 try {
284                     int temp = Integer.parseInt(directorConnectorText.getText());
285                 } catch (NumberFormatException JavaDoc ex){
286                     displayErrorMessage("Director Connector Port");
287                     valid = false;
288                 }
289             }
290         }
291         return valid;
292     }
293     
294     private void displayErrorMessage(String JavaDoc field){
295         JOptionPane.showMessageDialog(null, "Check '"+field+"' Field Setting!", "Enhydra Configuration Tool - Houston, we have a problem!",
296                 JOptionPane.ERROR_MESSAGE);
297     }
298     
299     public void setHttpPort (String JavaDoc port){
300         getHttpConnectorText().setText(port);
301     }
302     
303     public String JavaDoc getHttpPort (){
304         return getHttpConnectorText().getText();
305     }
306     
307     public void setSslHttpPort (String JavaDoc port){
308         getSslHTTPConnectorText().setText(port);
309     }
310     
311     public String JavaDoc getSslHttpPort (){
312         return getSslHTTPConnectorText().getText();
313     }
314     
315     public void setAjpPort (String JavaDoc port){
316         getAjpConnectorText().setText(port);
317     }
318     
319     public String JavaDoc getAjpPort (){
320         return getAjpConnectorText().getText();
321     }
322     
323     public void setDirectorPort (String JavaDoc port){
324         getDirectorConnectorText().setText(port);
325     }
326     
327     public String JavaDoc getDirectorPort (){
328         return getDirectorConnectorText().getText();
329     }
330     
331     public void setHttpChecked (boolean selected){
332         getHttpConnector().setSelected(selected);
333         
334         httpConnectorLabel.setEnabled(getHttpConnector().isSelected());
335         getHttpConnectorText().setEnabled(getHttpConnector().isSelected());
336     }
337     
338     public boolean getHttpChecked (){
339         return getHttpConnector().isSelected();
340     }
341     
342     public void setSslHttpChecked (boolean selected){
343         getSslHTTPConnector().setSelected(selected);
344         
345         sslHTTPConnectorLabel.setEnabled(getSslHTTPConnector().isSelected());
346         getSslHTTPConnectorText().setEnabled(
347                 getSslHTTPConnector().isSelected());
348     }
349     
350     public boolean getSslHttpChecked (){
351         return getSslHTTPConnector().isSelected();
352     }
353     
354     public void setAjpChecked (boolean selected){
355         getAjpConnector().setSelected(selected);
356         
357         ajpConnectorLabel.setEnabled(getAjpConnector().isSelected());
358         getAjpConnectorText()
359                 .setEnabled(getAjpConnector().isSelected());
360     }
361     
362     public boolean getAjpChecked (){
363         return getAjpConnector().isSelected();
364     }
365     
366     public void setDirectorChecked (boolean selected){
367         getDirectorConnector().setSelected(selected);
368         
369         directorConnectorLabel.setEnabled(getDirectorConnector().isSelected());
370         getDirectorConnectorText().setEnabled(
371                 getDirectorConnector().isSelected());
372     }
373     
374     public boolean getDirectorChecked (){
375         return getDirectorConnector().isSelected();
376     }
377     
378     private class CustomAction extends AbstractAction JavaDoc {
379         public void actionPerformed(ActionEvent JavaDoc ae) {
380             String JavaDoc command = ae.getActionCommand();
381             if ("non-SSL HTTP Connector".equals(command)) {
382                 httpConnectorLabel.setEnabled(getHttpConnector().isSelected());
383                 getHttpConnectorText().setEnabled(getHttpConnector().isSelected());
384             } else if ("SSL HTTP Connector".equals(command)) {
385                 sslHTTPConnectorLabel.setEnabled(getSslHTTPConnector().isSelected());
386                 getSslHTTPConnectorText().setEnabled(
387                         getSslHTTPConnector().isSelected());
388             } else if ("AJP Connector".equals(command)) {
389                 ajpConnectorLabel.setEnabled(getAjpConnector().isSelected());
390                 getAjpConnectorText()
391                         .setEnabled(getAjpConnector().isSelected());
392             } else if ("Director Connector".equals(command)) {
393                 directorConnectorLabel.setEnabled(getDirectorConnector().isSelected());
394                 getDirectorConnectorText().setEnabled(
395                         getDirectorConnector().isSelected());
396             }
397         }
398     }
399
400     private class CustomActionListener implements ActionListener JavaDoc {
401
402         protected AbstractAction JavaDoc action;
403
404         public CustomActionListener() {
405             action = new CustomAction();
406         }
407
408         public void actionPerformed(ActionEvent JavaDoc e) {
409             action.actionPerformed(e);
410         }
411     }
412 }
Popular Tags