001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.jmeter.protocol.ldap.config.gui;
020:
021: import java.awt.BorderLayout;
022: import java.awt.CardLayout;
023: import java.awt.event.ItemEvent;
024: import java.awt.event.ItemListener;
025:
026: import javax.swing.BorderFactory;
027: import javax.swing.ButtonGroup;
028: import javax.swing.JCheckBox;
029: import javax.swing.JLabel;
030: import javax.swing.JPanel;
031: import javax.swing.JRadioButton;
032: import javax.swing.JTextField;
033: import javax.swing.JPasswordField;
034:
035: import org.apache.jmeter.config.ConfigTestElement;
036: import org.apache.jmeter.config.gui.AbstractConfigGui;
037: import org.apache.jmeter.config.gui.ArgumentsPanel;
038: import org.apache.jmeter.gui.util.VerticalPanel;
039: import org.apache.jmeter.protocol.ldap.sampler.LDAPExtSampler;
040: import org.apache.jmeter.protocol.ldap.config.gui.LDAPArgumentsPanel;
041: import org.apache.jmeter.testelement.TestElement;
042: import org.apache.jmeter.testelement.property.StringProperty;
043: import org.apache.jmeter.testelement.property.TestElementProperty;
044: import org.apache.jmeter.util.JMeterUtils;
045: import org.apache.jorphan.gui.JLabeledChoice;
046:
047: /*******************************************************************************
048: * author Dolf Smits(Dolf.Smits@Siemens.com) created Aug 09 2003 11:00 AM
049: * company Siemens Netherlands N.V..
050: *
051: * Based on the work of: author T.Elanjchezhiyan(chezhiyan@siptech.co.in)
052: * created Apr 29 2003 11:00 AM company Sip Technologies and Exports Ltd.
053: ******************************************************************************/
054:
055: /*******************************************************************************
056: * This class LdapConfigGui is user interface gui for getting all the
057: * configuration value from the user
058: ******************************************************************************/
059:
060: public class LdapExtConfigGui extends AbstractConfigGui implements
061: ItemListener {
062: // private final static String ROOTDN = "rootDn";
063: // private final static String TEST = "tesT";
064: // private static String testValue="NNNN";
065:
066: private JTextField rootdn = new JTextField(20);
067:
068: private JTextField searchbase = new JTextField(20);
069:
070: private JTextField searchfilter = new JTextField(20);
071:
072: private JTextField delete = new JTextField(20);
073:
074: private JTextField add = new JTextField(20);
075:
076: private JTextField modify = new JTextField(20);
077:
078: private JTextField servername = new JTextField(20);
079:
080: private JTextField port = new JTextField(20);
081:
082: /*
083: * N.B. These entries MUST agree with the LDAP SearchControls SCOPE_LEVELS
084: * These have the values 0,1,2 so can be used as indexes in the array
085: * as well as the value for the search itself.
086: */
087: private static final String[] SCOPE_STRINGS = new String[] {
088: JMeterUtils.getResString("ldap_search_baseobject"),// $NON-NLS-1$
089: JMeterUtils.getResString("ldap_search_onelevel"),// $NON-NLS-1$
090: JMeterUtils.getResString("ldap_search_subtree"),// $NON-NLS-1$
091: };
092:
093: // Names for the cards
094: private static final String CARDS_DEFAULT = ""; // $NON-NLS-1$
095: private static final String CARDS_ADD = "Add"; // $NON-NLS-1$
096: private static final String CARDS_DELETE = "Delete"; // $NON-NLS-1$
097: private static final String CARDS_BIND = "Bind"; // $NON-NLS-1$
098: private static final String CARDS_RENAME = "Rename"; // $NON-NLS-1$
099: private static final String CARDS_COMPARE = "Compare"; // $NON-NLS-1$
100: private static final String CARDS_SEARCH = "Search"; // $NON-NLS-1$
101: private static final String CARDS_MODIFY = "Modify"; // $NON-NLS-1$
102:
103: private JLabeledChoice scope = new JLabeledChoice(JMeterUtils
104: .getResString("scope"), // $NON-NLS-1$
105: SCOPE_STRINGS);
106:
107: private JTextField countlim = new JTextField(20);
108:
109: private JTextField timelim = new JTextField(20);
110:
111: private JTextField attribs = new JTextField(20);
112:
113: private JCheckBox retobj = new JCheckBox(JMeterUtils
114: .getResString("retobj")); // $NON-NLS-1$
115:
116: private JCheckBox deref = new JCheckBox(JMeterUtils
117: .getResString("deref")); // $NON-NLS-1$
118:
119: private JTextField userdn = new JTextField(20);
120:
121: private JTextField userpw = new JPasswordField(20);
122:
123: private JTextField comparedn = new JTextField(20);
124:
125: private JTextField comparefilt = new JTextField(20);
126:
127: private JTextField modddn = new JTextField(20);
128:
129: private JTextField newdn = new JTextField(20);
130:
131: private JTextField connto = new JTextField(20);
132:
133: private JCheckBox parseflag = new JCheckBox(JMeterUtils
134: .getResString("ldap_parse_results")); // $NON-NLS-1$
135:
136: private JCheckBox secure = new JCheckBox(JMeterUtils
137: .getResString("ldap_secure")); // $NON-NLS-1$
138:
139: private JRadioButton addTest = new JRadioButton(JMeterUtils
140: .getResString("addtest")); // $NON-NLS-1$
141:
142: private JRadioButton modifyTest = new JRadioButton(JMeterUtils
143: .getResString("modtest")); // $NON-NLS-1$
144:
145: private JRadioButton deleteTest = new JRadioButton(JMeterUtils
146: .getResString("deltest")); // $NON-NLS-1$
147:
148: private JRadioButton searchTest = new JRadioButton(JMeterUtils
149: .getResString("searchtest")); // $NON-NLS-1$
150:
151: private JRadioButton bind = new JRadioButton(JMeterUtils
152: .getResString("bind")); // $NON-NLS-1$
153:
154: private JRadioButton rename = new JRadioButton(JMeterUtils
155: .getResString("rename")); // $NON-NLS-1$
156:
157: private JRadioButton unbind = new JRadioButton(JMeterUtils
158: .getResString("unbind")); // $NON-NLS-1$
159:
160: private JRadioButton sbind = new JRadioButton(JMeterUtils
161: .getResString("sbind")); // $NON-NLS-1$
162:
163: private JRadioButton compare = new JRadioButton(JMeterUtils
164: .getResString("compare")); // $NON-NLS-1$
165:
166: private ButtonGroup bGroup = new ButtonGroup();
167:
168: private boolean displayName = true;
169:
170: ArgumentsPanel tableAddPanel = new ArgumentsPanel(JMeterUtils
171: .getResString("addtest")); // $NON-NLS-1$
172:
173: LDAPArgumentsPanel tableModifyPanel = new LDAPArgumentsPanel(
174: JMeterUtils.getResString("modtest")); // $NON-NLS-1$
175:
176: private JPanel cards;
177:
178: /***************************************************************************
179: * Default constructor for LdapConfigGui
180: **************************************************************************/
181: public LdapExtConfigGui() {
182: this (true);
183: }
184:
185: /***************************************************************************
186: * !ToDo (Constructor description)
187: *
188: * @param displayName
189: * !ToDo (Parameter description)
190: **************************************************************************/
191: public LdapExtConfigGui(boolean displayName) {
192: this .displayName = displayName;
193: init();
194: }
195:
196: public String getLabelResource() {
197: return "ldapext_sample_title"; // $NON-NLS-1$
198: }
199:
200: /**
201: * A newly created component can be initialized with the contents of a Test
202: * Element object by calling this method. The component is responsible for
203: * querying the Test Element object for the relevant information to display
204: * in its GUI.
205: *
206: * @param element
207: * the TestElement to configure
208: */
209: public void configure(TestElement element) {
210: super .configure(element);
211: servername.setText(element
212: .getPropertyAsString(LDAPExtSampler.SERVERNAME));
213: port.setText(element.getPropertyAsString(LDAPExtSampler.PORT));
214: rootdn.setText(element
215: .getPropertyAsString(LDAPExtSampler.ROOTDN));
216: scope.setSelectedIndex(element
217: .getPropertyAsInt(LDAPExtSampler.SCOPE));
218: countlim.setText(element
219: .getPropertyAsString(LDAPExtSampler.COUNTLIM));
220: timelim.setText(element
221: .getPropertyAsString(LDAPExtSampler.TIMELIM));
222: attribs.setText(element
223: .getPropertyAsString(LDAPExtSampler.ATTRIBS));
224: retobj.setSelected(element
225: .getPropertyAsBoolean(LDAPExtSampler.RETOBJ));
226: deref.setSelected(element
227: .getPropertyAsBoolean(LDAPExtSampler.DEREF));
228: connto.setText(element
229: .getPropertyAsString(LDAPExtSampler.CONNTO));
230: parseflag.setSelected(element
231: .getPropertyAsBoolean(LDAPExtSampler.PARSEFLAG));
232: secure.setSelected(element
233: .getPropertyAsBoolean(LDAPExtSampler.SECURE));
234: userpw.setText(element
235: .getPropertyAsString(LDAPExtSampler.USERPW));
236: userdn.setText(element
237: .getPropertyAsString(LDAPExtSampler.USERDN));
238: comparedn.setText(element
239: .getPropertyAsString(LDAPExtSampler.COMPAREDN));
240: comparefilt.setText(element
241: .getPropertyAsString(LDAPExtSampler.COMPAREFILT));
242: modddn.setText(element
243: .getPropertyAsString(LDAPExtSampler.MODDDN));
244: newdn
245: .setText(element
246: .getPropertyAsString(LDAPExtSampler.NEWDN));
247: CardLayout cl = (CardLayout) (cards.getLayout());
248: final String testType = element
249: .getPropertyAsString(LDAPExtSampler.TEST);
250: if (testType.equals(LDAPExtSampler.UNBIND)) {
251: unbind.setSelected(true);
252: cl.show(cards, CARDS_DEFAULT);
253: } else if (testType.equals(LDAPExtSampler.BIND)) {
254: bind.setSelected(true);
255: cl.show(cards, CARDS_BIND);
256: } else if (testType.equals(LDAPExtSampler.SBIND)) {
257: sbind.setSelected(true);
258: cl.show(cards, CARDS_DEFAULT);
259: } else if (testType.equals(LDAPExtSampler.COMPARE)) {
260: compare.setSelected(true);
261: cl.show(cards, CARDS_COMPARE);
262: } else if (testType.equals(LDAPExtSampler.ADD)) {
263: addTest.setSelected(true);
264: add.setText(element
265: .getPropertyAsString(LDAPExtSampler.BASE_ENTRY_DN));
266: tableAddPanel.configure((TestElement) element.getProperty(
267: LDAPExtSampler.ARGUMENTS).getObjectValue());
268: cl.show(cards, CARDS_ADD);
269: } else if (testType.equals(LDAPExtSampler.MODIFY)) {
270: modifyTest.setSelected(true);
271: modify.setText(element
272: .getPropertyAsString(LDAPExtSampler.BASE_ENTRY_DN));
273: tableModifyPanel.configure((TestElement) element
274: .getProperty(LDAPExtSampler.LDAPARGUMENTS)
275: .getObjectValue());
276: cl.show(cards, CARDS_MODIFY);
277: } else if (testType.equals(LDAPExtSampler.DELETE)) {
278: deleteTest.setSelected(true);
279: delete.setText(element
280: .getPropertyAsString(LDAPExtSampler.DELETE));
281: cl.show(cards, CARDS_DELETE);
282: } else if (testType.equals(LDAPExtSampler.RENAME)) {
283: rename.setSelected(true);
284: cl.show(cards, CARDS_RENAME);
285: } else if (testType.equals(LDAPExtSampler.SEARCH)) {
286: searchTest.setSelected(true);
287: searchbase.setText(element
288: .getPropertyAsString(LDAPExtSampler.SEARCHBASE));
289: searchfilter.setText(element
290: .getPropertyAsString(LDAPExtSampler.SEARCHFILTER));
291: cl.show(cards, CARDS_SEARCH);
292: }
293: }
294:
295: /* Implements JMeterGUIComponent.createTestElement() */
296: public TestElement createTestElement() {
297: ConfigTestElement element = new ConfigTestElement();
298: modifyTestElement(element);
299: return element;
300: }
301:
302: /**
303: * Modifies a given TestElement to mirror the data in the gui components.
304: *
305: * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
306: */
307: public void modifyTestElement(TestElement element) {
308: element.clear();
309: configureTestElement(element);
310: element.setProperty(LDAPExtSampler.SERVERNAME, servername
311: .getText());
312: element.setProperty(LDAPExtSampler.PORT, port.getText());
313: element.setProperty(LDAPExtSampler.ROOTDN, rootdn.getText());
314: element.setProperty(LDAPExtSampler.SCOPE, String.valueOf(scope
315: .getSelectedIndex()));
316: element
317: .setProperty(LDAPExtSampler.COUNTLIM, countlim
318: .getText());
319: element.setProperty(LDAPExtSampler.TIMELIM, timelim.getText());
320: element.setProperty(LDAPExtSampler.ATTRIBS, attribs.getText());
321: element.setProperty(LDAPExtSampler.RETOBJ, Boolean
322: .toString(retobj.isSelected()));
323: element.setProperty(LDAPExtSampler.DEREF, Boolean
324: .toString(deref.isSelected()));
325: element.setProperty(LDAPExtSampler.CONNTO, connto.getText());
326: element.setProperty(LDAPExtSampler.PARSEFLAG, Boolean
327: .toString(parseflag.isSelected()));
328: element.setProperty(LDAPExtSampler.SECURE, Boolean
329: .toString(secure.isSelected()));
330: element.setProperty(LDAPExtSampler.USERDN, userdn.getText());
331: element.setProperty(LDAPExtSampler.USERPW, userpw.getText());
332: element.setProperty(LDAPExtSampler.COMPAREDN, comparedn
333: .getText());
334: element.setProperty(LDAPExtSampler.COMPAREFILT, comparefilt
335: .getText());
336: element.setProperty(LDAPExtSampler.MODDDN, modddn.getText());
337: element.setProperty(LDAPExtSampler.NEWDN, newdn.getText());
338: if (addTest.isSelected()) {
339: element.setProperty(new StringProperty(LDAPExtSampler.TEST,
340: LDAPExtSampler.ADD));
341: element.setProperty(new StringProperty(
342: LDAPExtSampler.BASE_ENTRY_DN, add.getText()));
343: element.setProperty(new TestElementProperty(
344: LDAPExtSampler.ARGUMENTS, tableAddPanel
345: .createTestElement()));
346: }
347: if (modifyTest.isSelected()) {
348: element.setProperty(new StringProperty(LDAPExtSampler.TEST,
349: LDAPExtSampler.MODIFY));
350: element.setProperty(new StringProperty(
351: LDAPExtSampler.BASE_ENTRY_DN, modify.getText()));
352: element.setProperty(new TestElementProperty(
353: LDAPExtSampler.LDAPARGUMENTS, tableModifyPanel
354: .createTestElement()));
355: }
356: if (deleteTest.isSelected()) {
357: element.setProperty(new StringProperty(LDAPExtSampler.TEST,
358: LDAPExtSampler.DELETE));
359: element.setProperty(new StringProperty(
360: LDAPExtSampler.DELETE, delete.getText()));
361: }
362: if (searchTest.isSelected()) {
363: element.setProperty(new StringProperty(LDAPExtSampler.TEST,
364: LDAPExtSampler.SEARCH));
365: element.setProperty(new StringProperty(
366: LDAPExtSampler.SEARCHBASE, searchbase.getText()));
367: element
368: .setProperty(new StringProperty(
369: LDAPExtSampler.SEARCHFILTER, searchfilter
370: .getText()));
371: }
372: if (bind.isSelected()) {
373: element.setProperty(new StringProperty(LDAPExtSampler.TEST,
374: LDAPExtSampler.BIND));
375: }
376: if (sbind.isSelected()) {
377: element.setProperty(new StringProperty(LDAPExtSampler.TEST,
378: LDAPExtSampler.SBIND));
379: }
380: if (compare.isSelected()) {
381: element.setProperty(new StringProperty(LDAPExtSampler.TEST,
382: LDAPExtSampler.COMPARE));
383: }
384: if (rename.isSelected()) {
385: element.setProperty(new StringProperty(LDAPExtSampler.TEST,
386: LDAPExtSampler.RENAME));
387: }
388: if (unbind.isSelected()) {
389: element.setProperty(new StringProperty(LDAPExtSampler.TEST,
390: LDAPExtSampler.UNBIND));
391: }
392: }
393:
394: /**
395: * Implements JMeterGUIComponent.clearGui
396: */
397: public void clearGui() {
398: super .clearGui();
399:
400: rootdn.setText(""); //$NON-NLS-1$
401: searchbase.setText(""); //$NON-NLS-1$
402: searchfilter.setText(""); //$NON-NLS-1$
403: delete.setText(""); //$NON-NLS-1$
404: add.setText(""); //$NON-NLS-1$
405: modify.setText(""); //$NON-NLS-1$
406: servername.setText(""); //$NON-NLS-1$
407: port.setText(""); //$NON-NLS-1$
408: add.setText(""); //$NON-NLS-1$
409: scope.setSelectedIndex(SCOPE_STRINGS.length - 1);
410: countlim.setText(""); //$NON-NLS-1$
411: timelim.setText(""); //$NON-NLS-1$
412: attribs.setText(""); //$NON-NLS-1$
413: userdn.setText(""); //$NON-NLS-1$
414: userpw.setText(""); //$NON-NLS-1$
415: comparedn.setText(""); //$NON-NLS-1$
416: comparefilt.setText(""); //$NON-NLS-1$
417: modddn.setText(""); //$NON-NLS-1$
418: newdn.setText(""); //$NON-NLS-1$
419: connto.setText(""); //$NON-NLS-1$
420: retobj.setSelected(false);
421: deref.setSelected(false);
422: parseflag.setSelected(false);
423: secure.setSelected(false);
424: addTest.setSelected(false);
425: modifyTest.setSelected(false);
426: deleteTest.setSelected(false);
427: searchTest.setSelected(false);
428: bind.setSelected(false);
429: rename.setSelected(false);
430: unbind.setSelected(false);
431: sbind.setSelected(false);
432: compare.setSelected(false);
433:
434: tableAddPanel.clear();
435: tableModifyPanel.clear();
436: }
437:
438: /***************************************************************************
439: * This itemStateChanged listener for changing the card layout for based on
440: * the test selected in the User defined test case.
441: **************************************************************************/
442: public void itemStateChanged(ItemEvent ie) {
443: CardLayout cl = (CardLayout) (cards.getLayout());
444: if (addTest.isSelected()) {
445: cl.show(cards, CARDS_ADD);
446: } else if (deleteTest.isSelected()) {
447: cl.show(cards, CARDS_DELETE);
448: } else if (bind.isSelected()) {
449: cl.show(cards, CARDS_BIND);
450: } else if (sbind.isSelected()) {
451: cl.show(cards, CARDS_BIND);
452: } else if (rename.isSelected()) {
453: cl.show(cards, CARDS_RENAME);
454: } else if (compare.isSelected()) {
455: cl.show(cards, CARDS_COMPARE);
456: } else if (searchTest.isSelected()) {
457: cl.show(cards, CARDS_SEARCH);
458: } else if (modifyTest.isSelected()) {
459: cl.show(cards, CARDS_MODIFY);
460: } else { // e.g unbind
461: cl.show(cards, CARDS_DEFAULT);
462: }
463: }
464:
465: /***************************************************************************
466: * This will create the servername panel in the LdapConfigGui
467: **************************************************************************/
468: private JPanel createServernamePanel() {
469: JPanel serverPanel = new JPanel(new BorderLayout(5, 0));
470: JLabel label = new JLabel(JMeterUtils
471: .getResString("servername")); // $NON-NLS-1$
472: label.setLabelFor(servername);
473: serverPanel.add(label, BorderLayout.WEST);
474: serverPanel.add(servername, BorderLayout.CENTER);
475: return serverPanel;
476: }
477:
478: /***************************************************************************
479: * This will create the port panel in the LdapConfigGui
480: **************************************************************************/
481: private JPanel createPortPanel() {
482: JPanel portPanel = new JPanel(new BorderLayout(5, 0));
483: JLabel label = new JLabel(JMeterUtils.getResString("port")); // $NON-NLS-1$
484: label.setLabelFor(port);
485: portPanel.add(label, BorderLayout.WEST);
486: portPanel.add(port, BorderLayout.CENTER);
487: return portPanel;
488: }
489:
490: /***************************************************************************
491: * This will create the Root distinguised name panel in the LdapConfigGui
492: **************************************************************************/
493: private JPanel createRootdnPanel() {
494: JPanel rootdnPanel = new JPanel(new BorderLayout(5, 0));
495: JLabel label = new JLabel(JMeterUtils.getResString("ddn")); // $NON-NLS-1$
496: label.setLabelFor(rootdn);
497: rootdnPanel.add(label, BorderLayout.WEST);
498: rootdnPanel.add(rootdn, BorderLayout.CENTER);
499: return rootdnPanel;
500: }
501:
502: /***************************************************************************
503: * This will create the bind/sbind panel in the LdapConfigGui
504: **************************************************************************/
505: private JPanel createBindPanel() {
506: VerticalPanel bindPanel = new VerticalPanel();
507: bindPanel.add(createServernamePanel());
508: bindPanel.add(createPortPanel());
509: bindPanel.add(createRootdnPanel());
510:
511: JPanel BPanel = new JPanel(new BorderLayout(5, 0));
512: JLabel Blabel0 = new JLabel(JMeterUtils.getResString("userdn")); // $NON-NLS-1$
513: Blabel0.setLabelFor(userdn);
514: BPanel.add(Blabel0, BorderLayout.WEST);
515: BPanel.add(userdn, BorderLayout.CENTER);
516: bindPanel.add(BPanel);
517:
518: JPanel B1Panel = new JPanel(new BorderLayout(5, 0));
519: JLabel Blabel1 = new JLabel(JMeterUtils.getResString("userpw")); // $NON-NLS-1$
520: Blabel1.setLabelFor(userpw);
521: B1Panel.add(Blabel1, BorderLayout.WEST);
522: B1Panel.add(userpw, BorderLayout.CENTER);
523: bindPanel.add(B1Panel);
524:
525: JPanel B2Panel = new JPanel(new BorderLayout(5, 0));
526: JLabel Blabel2 = new JLabel(JMeterUtils
527: .getResString("ldap_connto")); // $NON-NLS-1$
528: Blabel2.setLabelFor(connto);
529: B2Panel.add(Blabel2, BorderLayout.WEST);
530: B2Panel.add(connto, BorderLayout.CENTER);
531: bindPanel.add(B2Panel);
532:
533: bindPanel.add(secure);
534: return bindPanel;
535: }
536:
537: /***************************************************************************
538: * This will create the bind panel in the LdapConfigGui
539: **************************************************************************/
540: private JPanel createComparePanel() {
541: VerticalPanel cbindPanel = new VerticalPanel();
542: JPanel cBPanel = new JPanel(new BorderLayout(5, 0));
543: JLabel cBlabel0 = new JLabel(JMeterUtils
544: .getResString("entrydn")); // $NON-NLS-1$
545: cBlabel0.setLabelFor(comparedn);
546: cBPanel.add(cBlabel0, BorderLayout.WEST);
547: cBPanel.add(comparedn, BorderLayout.CENTER);
548: cbindPanel.add(cBPanel);
549:
550: JPanel cBPanel1 = new JPanel(new BorderLayout(5, 0));
551: JLabel cBlabel1 = new JLabel(JMeterUtils
552: .getResString("comparefilt")); // $NON-NLS-1$
553: cBlabel1.setLabelFor(comparefilt);
554: cBPanel1.add(cBlabel1, BorderLayout.WEST);
555: cBPanel1.add(comparefilt, BorderLayout.CENTER);
556: cbindPanel.add(cBPanel1);
557:
558: return cbindPanel;
559: }
560:
561: /***************************************************************************
562: * This will create the Search controls panel in the LdapConfigGui
563: **************************************************************************/
564: private JPanel createSCPanel() {
565: VerticalPanel SCPanel = new VerticalPanel();
566:
567: JPanel SC0Panel = new JPanel(new BorderLayout(5, 0));
568: JLabel label0 = new JLabel(JMeterUtils.getResString("scope")); // $NON-NLS-1$
569: label0.setLabelFor(scope);
570: SC0Panel.add(label0, BorderLayout.WEST);
571: SC0Panel.add(scope, BorderLayout.CENTER);
572: SCPanel.add(SC0Panel);
573:
574: JPanel SC1Panel = new JPanel(new BorderLayout(5, 0));
575: JLabel label1 = new JLabel(JMeterUtils.getResString("countlim")); // $NON-NLS-1$
576: label1.setLabelFor(countlim);
577: SC1Panel.add(label1, BorderLayout.WEST);
578: SC1Panel.add(countlim, BorderLayout.CENTER);
579: SCPanel.add(SC1Panel);
580:
581: JPanel SC2Panel = new JPanel(new BorderLayout(5, 0));
582: JLabel label2 = new JLabel(JMeterUtils.getResString("timelim")); // $NON-NLS-1$
583: label2.setLabelFor(timelim);
584: SC2Panel.add(label2, BorderLayout.WEST);
585: SC2Panel.add(timelim, BorderLayout.CENTER);
586: SCPanel.add(SC2Panel);
587:
588: JPanel SC3Panel = new JPanel(new BorderLayout(5, 0));
589: JLabel label3 = new JLabel(JMeterUtils.getResString("attrs")); // $NON-NLS-1$
590: label3.setLabelFor(attribs);
591: SC3Panel.add(label3, BorderLayout.WEST);
592: SC3Panel.add(attribs, BorderLayout.CENTER);
593: SCPanel.add(SC3Panel);
594:
595: SCPanel.add(retobj);
596: SCPanel.add(deref);
597: SCPanel.add(parseflag);
598:
599: return SCPanel;
600: }
601:
602: /***************************************************************************
603: * This will create the Search panel in the LdapConfigGui
604: **************************************************************************/
605:
606: private JPanel createSearchPanel() {
607: VerticalPanel searchPanel = new VerticalPanel();
608:
609: JPanel searchBPanel = new JPanel(new BorderLayout(5, 0));
610: JLabel label = new JLabel(JMeterUtils
611: .getResString("searchbase")); // $NON-NLS-1$
612: label.setLabelFor(searchbase);
613: searchBPanel.add(label, BorderLayout.WEST);
614: searchBPanel.add(searchbase, BorderLayout.CENTER);
615:
616: JPanel searchFPanel = new JPanel(new BorderLayout(5, 0));
617: JLabel label20 = new JLabel(JMeterUtils
618: .getResString("searchfilter")); // $NON-NLS-1$
619: label20.setLabelFor(searchfilter);
620: searchFPanel.add(label20, BorderLayout.WEST);
621: searchFPanel.add(searchfilter, BorderLayout.CENTER);
622:
623: searchPanel.add(searchBPanel);
624: searchPanel.add(searchFPanel);
625: searchPanel.add(createSCPanel());
626:
627: return searchPanel;
628: }
629:
630: /***************************************************************************
631: * This will create the Moddn panel in the LdapConfigGui
632: **************************************************************************/
633:
634: private JPanel createModdnPanel() {
635: VerticalPanel modPanel = new VerticalPanel();
636:
637: JPanel renamePanel = new JPanel(new BorderLayout(5, 0));
638: JLabel labelmod = new JLabel(JMeterUtils.getResString("modddn")); // $NON-NLS-1$
639: labelmod.setLabelFor(modddn);
640: renamePanel.add(labelmod, BorderLayout.WEST);
641: renamePanel.add(modddn, BorderLayout.CENTER);
642:
643: JPanel rename2Panel = new JPanel(new BorderLayout(5, 0));
644: JLabel labelmod2 = new JLabel(JMeterUtils.getResString("newdn")); // $NON-NLS-1$
645: labelmod2.setLabelFor(newdn);
646: rename2Panel.add(labelmod2, BorderLayout.WEST);
647: rename2Panel.add(newdn, BorderLayout.CENTER);
648:
649: modPanel.add(renamePanel);
650: modPanel.add(rename2Panel);
651: return modPanel;
652: }
653:
654: /***************************************************************************
655: * This will create the Delete panel in the LdapConfigGui
656: **************************************************************************/
657: private JPanel createDeletePanel() {
658: VerticalPanel panel = new VerticalPanel();
659: JPanel deletePanel = new JPanel(new BorderLayout(5, 0));
660: JLabel label = new JLabel(JMeterUtils.getResString("delete")); // $NON-NLS-1$
661: label.setLabelFor(delete);
662: deletePanel.add(label, BorderLayout.WEST);
663: deletePanel.add(delete, BorderLayout.CENTER);
664: panel.add(deletePanel);
665: return panel;
666: }
667:
668: /***************************************************************************
669: * This will create the Add test panel in the LdapConfigGui
670: **************************************************************************/
671: private JPanel createAddPanel() {
672: JPanel addPanel = new JPanel(new BorderLayout(5, 0));
673: JPanel addInnerPanel = new JPanel(new BorderLayout(5, 0));
674: JLabel label = new JLabel(JMeterUtils.getResString("entrydn")); // $NON-NLS-1$
675: label.setLabelFor(add);
676: addInnerPanel.add(label, BorderLayout.WEST);
677: addInnerPanel.add(add, BorderLayout.CENTER);
678: addPanel.add(addInnerPanel, BorderLayout.NORTH);
679: addPanel.add(tableAddPanel, BorderLayout.CENTER);
680: return addPanel;
681: }
682:
683: /***************************************************************************
684: * This will create the Modify panel in the LdapConfigGui
685: **************************************************************************/
686: private JPanel createModifyPanel() {
687: JPanel modifyPanel = new JPanel(new BorderLayout(5, 0));
688: JPanel modifyInnerPanel = new JPanel(new BorderLayout(5, 0));
689: JLabel label = new JLabel(JMeterUtils.getResString("entrydn")); // $NON-NLS-1$
690: label.setLabelFor(modify);
691: modifyInnerPanel.add(label, BorderLayout.WEST);
692: modifyInnerPanel.add(modify, BorderLayout.CENTER);
693: modifyPanel.add(modifyInnerPanel, BorderLayout.NORTH);
694: modifyPanel.add(tableModifyPanel, BorderLayout.CENTER);
695: return modifyPanel;
696: }
697:
698: /***************************************************************************
699: * This will create the user defined test panel for create or modify or
700: * delete or search based on the panel selected in the itemevent in the
701: * LdapConfigGui
702: **************************************************************************/
703: private JPanel testPanel() {
704: cards = new JPanel(new CardLayout());
705: cards.add(new JPanel(), CARDS_DEFAULT);
706: cards.add(createAddPanel(), CARDS_ADD);
707: cards.add(createModifyPanel(), CARDS_MODIFY);
708: cards.add(createModdnPanel(), CARDS_RENAME);
709: cards.add(createDeletePanel(), CARDS_DELETE);
710: cards.add(createSearchPanel(), CARDS_SEARCH);
711: cards.add(createBindPanel(), CARDS_BIND);
712: cards.add(createComparePanel(), CARDS_COMPARE);
713: return cards;
714: }
715:
716: /***************************************************************************
717: * This will create the test panel in the LdapConfigGui
718: **************************************************************************/
719: private JPanel createTestPanel() {
720: JPanel testPanel = new JPanel(new BorderLayout());
721: testPanel.setBorder(BorderFactory
722: .createTitledBorder(JMeterUtils
723: .getResString("test_configuration"))); // $NON-NLS-1$
724:
725: testPanel.add(new JLabel(JMeterUtils.getResString("testt"))); // $NON-NLS-1$
726: JPanel rowPanel = new JPanel();
727: JPanel row2Panel = new JPanel();
728:
729: rowPanel.add(bind);
730: bGroup.add(bind);
731: rowPanel.add(unbind);
732: bGroup.add(unbind);
733: rowPanel.add(sbind);
734: bGroup.add(sbind);
735: rowPanel.add(rename);
736: bGroup.add(rename);
737: row2Panel.add(addTest);
738: bGroup.add(addTest);
739: row2Panel.add(deleteTest);
740: bGroup.add(deleteTest);
741: row2Panel.add(searchTest);
742: bGroup.add(searchTest);
743: row2Panel.add(compare);
744: bGroup.add(compare);
745: row2Panel.add(modifyTest);
746: bGroup.add(modifyTest);
747: testPanel.add(rowPanel, BorderLayout.NORTH);
748: testPanel.add(row2Panel, BorderLayout.SOUTH);
749: return testPanel;
750: }
751:
752: /***************************************************************************
753: * This will initalise all the panel in the LdapConfigGui
754: **************************************************************************/
755: private void init() {
756: setLayout(new BorderLayout(0, 5));
757: if (displayName) {
758: setBorder(makeBorder());
759: add(makeTitlePanel(), BorderLayout.NORTH);
760: }
761: VerticalPanel mainPanel = new VerticalPanel();
762: mainPanel.add(createTestPanel());
763: mainPanel.add(testPanel());
764: add(mainPanel, BorderLayout.CENTER);
765: // Take note of when buttong are changed so can change panel
766: bind.addItemListener(this);
767: sbind.addItemListener(this);
768: unbind.addItemListener(this);
769: compare.addItemListener(this);
770: addTest.addItemListener(this);
771: modifyTest.addItemListener(this);
772: rename.addItemListener(this);
773: deleteTest.addItemListener(this);
774: searchTest.addItemListener(this);
775: }
776: }
|