1 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 ; 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 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 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 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 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 namePanel = new NamePanel(model); 104 mainPanel.add(namePanel); 105 106 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 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 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 |