KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > ejb > jndi > config > gui > LookupConfigGui


1 // $Header: /home/cvs/jakarta-jmeter/src/protocol/jndi/config/gui/LookupConfigGui.java,v 1.3 2004/02/13 02:40:53 sebb Exp $
2
/*
3  * Copyright 2001-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */

18
19 package org.apache.jmeter.ejb.jndi.config.gui;
20
21 import javax.swing.*;
22 import javax.swing.border.*;
23 import java.awt.event.*;
24 import javax.naming.InitialContext JavaDoc;
25 import java.awt.*;
26 import java.util.*;
27
28 import org.apache.jmeter.gui.ModelSupported;
29 import org.apache.jmeter.gui.NamePanel;
30 import org.apache.jmeter.gui.VerticalLayout;
31 import org.apache.jmeter.config.gui.ArgumentsPanel;
32 import org.apache.jmeter.config.Arguments;
33 import org.apache.jmeter.util.JMeterUtils;
34 import org.apache.jmeter.ejb.jndi.config.LookupConfig;
35 import org.apache.log4j.Category;
36
37 /**
38  * Provides the gui interface to configure JNDI lookup
39  * @author Khor Soon Hin
40  * @version $Revision: 1.3 $ Last updated: $Date: 2004/02/13 02:40:53 $
41  * Created 2001 Dec 18
42  */

43 public class LookupConfigGui extends JPanel implements ModelSupported,
44     KeyListener
45 {
46   private static Category catClass = Category.getInstance(
47     LookupConfigGui.class.getName());
48
49   protected JTextField lookupField;
50
51   protected NamePanel namePanel;
52   protected boolean displayName;
53   protected LookupConfig model;
54
55   public LookupConfigGui()
56   {
57     displayName = true;
58   }
59
60   public LookupConfigGui(boolean displayName)
61   {
62     this.displayName = displayName;
63   }
64
65   public void setModel(Object JavaDoc model)
66   {
67     this.model = (LookupConfig)model;
68     init();
69   }
70
71   public void updateGui()
72   {
73     lookupField.setText(model.getLookupName());
74     if(displayName)
75     {
76       namePanel.updateGui();
77     }
78   }
79
80   protected void init()
81   {
82     lookupField = new JTextField(20);
83     if(displayName)
84     {
85       this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT,
86     VerticalLayout.TOP));
87       // main panel
88
JPanel mainPanel = new JPanel();
89       Border margin = new EmptyBorder(10, 10, 5, 10);
90       mainPanel.setBorder(margin);
91       mainPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
92
93       // title
94
JLabel panelTitleLabel = new JLabel(
95     JMeterUtils.getResString("jndi_lookup_title"));
96       Font curFont = panelTitleLabel.getFont();
97       int curFontSize = curFont.getSize();
98       curFontSize += 4;
99       panelTitleLabel.setFont(new Font(curFont.getFontName(), curFont.getStyle(), curFontSize));
100       mainPanel.add(panelTitleLabel);
101
102       // name
103
namePanel = new NamePanel(model);
104       mainPanel.add(namePanel);
105
106       // jndi properties
107
JPanel jndiPanel = new JPanel();
108       jndiPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
109       jndiPanel.setBorder(BorderFactory.createTitledBorder(
110     JMeterUtils.getResString("jndi_lookup_name")));
111
112       jndiPanel.add(getLookupNamePanel());
113
114       mainPanel.add(jndiPanel);
115       this.add(mainPanel);
116     }
117     else
118     {
119       this.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
120
121       // url and driver class
122
JPanel jndiPanel = new JPanel();
123       jndiPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
124       jndiPanel.setBorder(BorderFactory.createTitledBorder(
125     JMeterUtils.getResString("jndi_lookup_name")));
126
127       jndiPanel.add(getLookupNamePanel());
128
129       this.add(jndiPanel);
130     }
131   }
132
133   protected JPanel getLookupNamePanel()
134   {
135     catClass.info("Start : getLookupNamePanel1");
136     JPanel panel = new JPanel();
137     panel.add(new JLabel(JMeterUtils.getResString("jndi_lookup_name")));
138     lookupField.setText(model.getLookupName());
139     lookupField.setName(JMeterUtils.getResString("jndi_lookup_name"));
140     lookupField.addKeyListener(this);
141     panel.add(lookupField);
142     catClass.info("End : getLookupNamePanel1");
143     return panel;
144   }
145
146   public void keyPressed(KeyEvent e)
147   {
148   }
149
150   public void keyTyped(KeyEvent e)
151   {
152   }
153
154   public void keyReleased(KeyEvent e)
155   {
156     String JavaDoc name = e.getComponent().getName();
157     if(name.equals(JMeterUtils.getResString("jndi_lookup_name")))
158     {
159       model.setLookupName(lookupField.getText());
160     }
161   }
162 }
163
Popular Tags