Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.protocol.ldap.config.gui » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  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.protocol.ldap.config.gui;
   20   
   21   import java.awt.BorderLayout;
   22   import java.awt.CardLayout;
   23   import java.awt.event.ItemEvent;
   24   import java.awt.event.ItemListener;
   25   
   26   import javax.swing.BorderFactory;
   27   import javax.swing.ButtonGroup;
   28   import javax.swing.JCheckBox;
   29   import javax.swing.JLabel;
   30   import javax.swing.JPanel;
   31   import javax.swing.JRadioButton;
   32   import javax.swing.JTextField;
   33   import javax.swing.JPasswordField;
   34   
   35   import org.apache.jmeter.config.ConfigTestElement;
   36   import org.apache.jmeter.config.gui.AbstractConfigGui;
   37   import org.apache.jmeter.config.gui.ArgumentsPanel;
   38   import org.apache.jmeter.gui.util.VerticalPanel;
   39   import org.apache.jmeter.protocol.ldap.sampler.LDAPExtSampler;
   40   import org.apache.jmeter.protocol.ldap.config.gui.LDAPArgumentsPanel;
   41   import org.apache.jmeter.testelement.TestElement;
   42   import org.apache.jmeter.testelement.property.StringProperty;
   43   import org.apache.jmeter.testelement.property.TestElementProperty;
   44   import org.apache.jmeter.util.JMeterUtils;
   45   import org.apache.jorphan.gui.JLabeledChoice;
   46   
   47   /*******************************************************************************
   48    * author Dolf Smits(Dolf.Smits@Siemens.com) created Aug 09 2003 11:00 AM
   49    * company Siemens Netherlands N.V..
   50    *
   51    * Based on the work of: author T.Elanjchezhiyan(chezhiyan@siptech.co.in)
   52    * created Apr 29 2003 11:00 AM company Sip Technologies and Exports Ltd.
   53    ******************************************************************************/
   54   
   55   /*******************************************************************************
   56    * This class LdapConfigGui is user interface gui for getting all the
   57    * configuration value from the user
   58    ******************************************************************************/
   59   
   60   public class LdapExtConfigGui extends AbstractConfigGui implements ItemListener {
   61       // private final static String ROOTDN = "rootDn";
   62       // private final static String TEST = "tesT";
   63       // private static String testValue="NNNN";
   64   
   65       private JTextField rootdn = new JTextField(20);
   66   
   67       private JTextField searchbase = new JTextField(20);
   68   
   69       private JTextField searchfilter = new JTextField(20);
   70   
   71       private JTextField delete = new JTextField(20);
   72   
   73       private JTextField add = new JTextField(20);
   74   
   75       private JTextField modify = new JTextField(20);
   76   
   77       private JTextField servername = new JTextField(20);
   78   
   79       private JTextField port = new JTextField(20);
   80   
   81       /*
   82        * N.B. These entry indexes MUST agree with the SearchControls SCOPE_LEVELS, i.e.
   83        * 
   84        * javax.naming.directory.SearchControls.OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE
   85        * 
   86        * These have the values 0,1,2 so can be used as indexes in the array
   87        * as well as the value for the search itself.
   88        * 
   89        * N.B. Although the strings are used to set and get the options, language change
   90        * does not currently cause a problem, because that always saves the current settings first,
   91        * and then recreates all the GUI classes.
   92        */
   93       private final String[] SCOPE_STRINGS = new String[]{
   94           JMeterUtils.getResString("ldap_search_baseobject"),// $NON-NLS-1$
   95           JMeterUtils.getResString("ldap_search_onelevel"),// $NON-NLS-1$
   96           JMeterUtils.getResString("ldap_search_subtree"),// $NON-NLS-1$
   97           };
   98   
   99       // Names for the cards
  100       private static final String CARDS_DEFAULT = ""; // $NON-NLS-1$
  101       private static final String CARDS_ADD = "Add"; // $NON-NLS-1$
  102       private static final String CARDS_DELETE = "Delete"; // $NON-NLS-1$
  103       private static final String CARDS_BIND = "Bind"; // $NON-NLS-1$
  104       private static final String CARDS_RENAME = "Rename"; // $NON-NLS-1$
  105       private static final String CARDS_COMPARE = "Compare"; // $NON-NLS-1$
  106       private static final String CARDS_SEARCH = "Search"; // $NON-NLS-1$
  107       private static final String CARDS_MODIFY = "Modify"; // $NON-NLS-1$
  108   
  109       private JLabeledChoice scope =
  110           new JLabeledChoice(JMeterUtils.getResString("scope"), // $NON-NLS-1$
  111           SCOPE_STRINGS);
  112   
  113       private JTextField countlim = new JTextField(20);
  114   
  115       private JTextField timelim = new JTextField(20);
  116   
  117       private JTextField attribs = new JTextField(20);
  118   
  119       private JCheckBox retobj = new JCheckBox(JMeterUtils.getResString("retobj")); // $NON-NLS-1$
  120   
  121       private JCheckBox deref = new JCheckBox(JMeterUtils.getResString("deref")); // $NON-NLS-1$
  122   
  123       private JTextField userdn = new JTextField(20);
  124   
  125       private JTextField userpw = new JPasswordField(20);
  126   
  127       private JTextField comparedn = new JTextField(20);
  128   
  129       private JTextField comparefilt = new JTextField(20);
  130   
  131       private JTextField modddn = new JTextField(20);
  132   
  133       private JTextField newdn = new JTextField(20);
  134   
  135       private JTextField connto = new JTextField(20);
  136   
  137       private JCheckBox parseflag = new JCheckBox(JMeterUtils.getResString("ldap_parse_results")); // $NON-NLS-1$
  138   
  139       private JCheckBox secure = new JCheckBox(JMeterUtils.getResString("ldap_secure")); // $NON-NLS-1$
  140   
  141       private JRadioButton addTest = new JRadioButton(JMeterUtils.getResString("addtest")); // $NON-NLS-1$
  142   
  143       private JRadioButton modifyTest = new JRadioButton(JMeterUtils.getResString("modtest")); // $NON-NLS-1$
  144   
  145       private JRadioButton deleteTest = new JRadioButton(JMeterUtils.getResString("deltest")); // $NON-NLS-1$
  146   
  147       private JRadioButton searchTest = new JRadioButton(JMeterUtils.getResString("searchtest")); // $NON-NLS-1$
  148   
  149       private JRadioButton bind = new JRadioButton(JMeterUtils.getResString("bind")); // $NON-NLS-1$
  150   
  151       private JRadioButton rename = new JRadioButton(JMeterUtils.getResString("rename")); // $NON-NLS-1$
  152   
  153       private JRadioButton unbind = new JRadioButton(JMeterUtils.getResString("unbind")); // $NON-NLS-1$
  154   
  155       private JRadioButton sbind = new JRadioButton(JMeterUtils.getResString("sbind")); // $NON-NLS-1$
  156   
  157       private JRadioButton compare = new JRadioButton(JMeterUtils.getResString("compare")); // $NON-NLS-1$
  158   
  159       private ButtonGroup bGroup = new ButtonGroup();
  160   
  161       private boolean displayName = true;
  162   
  163       ArgumentsPanel tableAddPanel = new ArgumentsPanel(JMeterUtils.getResString("addtest")); // $NON-NLS-1$
  164   
  165       LDAPArgumentsPanel tableModifyPanel = new LDAPArgumentsPanel(JMeterUtils.getResString("modtest")); // $NON-NLS-1$
  166   
  167       private JPanel cards;
  168   
  169       /***************************************************************************
  170        * Default constructor for LdapConfigGui
  171        **************************************************************************/
  172       public LdapExtConfigGui() {
  173           this(true);
  174       }
  175   
  176       /***************************************************************************
  177        * !ToDo (Constructor description)
  178        *
  179        * @param displayName
  180        *            !ToDo (Parameter description)
  181        **************************************************************************/
  182       public LdapExtConfigGui(boolean displayName) {
  183           this.displayName = displayName;
  184           init();
  185       }
  186   
  187       public String getLabelResource() {
  188           return "ldapext_sample_title"; // $NON-NLS-1$
  189       }
  190   
  191       /**
  192        * A newly created component can be initialized with the contents of a Test
  193        * Element object by calling this method. The component is responsible for
  194        * querying the Test Element object for the relevant information to display
  195        * in its GUI.
  196        *
  197        * @param element
  198        *            the TestElement to configure
  199        */
  200       public void configure(TestElement element) {
  201           super.configure(element);
  202           servername.setText(element.getPropertyAsString(LDAPExtSampler.SERVERNAME));
  203           port.setText(element.getPropertyAsString(LDAPExtSampler.PORT));
  204           rootdn.setText(element.getPropertyAsString(LDAPExtSampler.ROOTDN));
  205              scope.setSelectedIndex(element.getPropertyAsInt(LDAPExtSampler.SCOPE));
  206           countlim.setText(element.getPropertyAsString(LDAPExtSampler.COUNTLIM));
  207           timelim.setText(element.getPropertyAsString(LDAPExtSampler.TIMELIM));
  208           attribs.setText(element.getPropertyAsString(LDAPExtSampler.ATTRIBS));
  209              retobj.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.RETOBJ));
  210              deref.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.DEREF));
  211           connto.setText(element.getPropertyAsString(LDAPExtSampler.CONNTO));
  212             parseflag.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.PARSEFLAG));
  213              secure.setSelected(element.getPropertyAsBoolean(LDAPExtSampler.SECURE));
  214           userpw.setText(element.getPropertyAsString(LDAPExtSampler.USERPW));
  215           userdn.setText(element.getPropertyAsString(LDAPExtSampler.USERDN));
  216           comparedn.setText(element.getPropertyAsString(LDAPExtSampler.COMPAREDN));
  217           comparefilt.setText(element.getPropertyAsString(LDAPExtSampler.COMPAREFILT));
  218           modddn.setText(element.getPropertyAsString(LDAPExtSampler.MODDDN));
  219           newdn.setText(element.getPropertyAsString(LDAPExtSampler.NEWDN));
  220           CardLayout cl = (CardLayout) (cards.getLayout());
  221           final String testType = element.getPropertyAsString(LDAPExtSampler.TEST);
  222           if (testType.equals(LDAPExtSampler.UNBIND)) {
  223               unbind.setSelected(true);
  224               cl.show(cards, CARDS_DEFAULT);
  225           } else if (testType.equals(LDAPExtSampler.BIND)) {
  226               bind.setSelected(true);
  227               cl.show(cards, CARDS_BIND);
  228           } else if (testType.equals(LDAPExtSampler.SBIND)) {
  229               sbind.setSelected(true);
  230               cl.show(cards, CARDS_DEFAULT);
  231           } else if (testType.equals(LDAPExtSampler.COMPARE)) {
  232               compare.setSelected(true);
  233               cl.show(cards, CARDS_COMPARE);
  234           } else if (testType.equals(LDAPExtSampler.ADD)) {
  235               addTest.setSelected(true);
  236               add.setText(element.getPropertyAsString(LDAPExtSampler.BASE_ENTRY_DN));
  237               tableAddPanel.configure((TestElement) element.getProperty(LDAPExtSampler.ARGUMENTS).getObjectValue());
  238               cl.show(cards, CARDS_ADD);
  239           } else if (testType.equals(LDAPExtSampler.MODIFY)) {
  240               modifyTest.setSelected(true);
  241               modify.setText(element.getPropertyAsString(LDAPExtSampler.BASE_ENTRY_DN));
  242               tableModifyPanel
  243                       .configure((TestElement) element.getProperty(LDAPExtSampler.LDAPARGUMENTS).getObjectValue());
  244               cl.show(cards, CARDS_MODIFY);
  245           } else if (testType.equals(LDAPExtSampler.DELETE)) {
  246               deleteTest.setSelected(true);
  247               delete.setText(element.getPropertyAsString(LDAPExtSampler.DELETE));
  248               cl.show(cards, CARDS_DELETE);
  249           } else if (testType.equals(LDAPExtSampler.RENAME)) {
  250               rename.setSelected(true);
  251               cl.show(cards, CARDS_RENAME);
  252           } else if (testType.equals(LDAPExtSampler.SEARCH)) {
  253               searchTest.setSelected(true);
  254               searchbase.setText(element.getPropertyAsString(LDAPExtSampler.SEARCHBASE));
  255               searchfilter.setText(element.getPropertyAsString(LDAPExtSampler.SEARCHFILTER));
  256               cl.show(cards, CARDS_SEARCH);
  257           }
  258       }
  259   
  260       /* Implements JMeterGUIComponent.createTestElement() */
  261       public TestElement createTestElement() {
  262           ConfigTestElement element = new ConfigTestElement();
  263           modifyTestElement(element);
  264           return element;
  265       }
  266   
  267       /**
  268        * Modifies a given TestElement to mirror the data in the gui components.
  269        *
  270        * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
  271        */
  272       public void modifyTestElement(TestElement element) {
  273           element.clear();
  274           configureTestElement(element);
  275           element.setProperty(LDAPExtSampler.SERVERNAME, servername.getText());
  276           element.setProperty(LDAPExtSampler.PORT, port.getText());
  277           element.setProperty(LDAPExtSampler.ROOTDN, rootdn.getText());
  278           element.setProperty(LDAPExtSampler.SCOPE,String.valueOf(scope.getSelectedIndex()));
  279           element.setProperty(LDAPExtSampler.COUNTLIM, countlim.getText());
  280           element.setProperty(LDAPExtSampler.TIMELIM, timelim.getText());
  281           element.setProperty(LDAPExtSampler.ATTRIBS, attribs.getText());
  282           element.setProperty(LDAPExtSampler.RETOBJ,Boolean.toString(retobj.isSelected()));
  283           element.setProperty(LDAPExtSampler.DEREF,Boolean.toString(deref.isSelected()));
  284           element.setProperty(LDAPExtSampler.CONNTO, connto.getText());
  285           element.setProperty(LDAPExtSampler.PARSEFLAG,Boolean.toString(parseflag.isSelected()));
  286           element.setProperty(LDAPExtSampler.SECURE,Boolean.toString(secure.isSelected()));
  287           element.setProperty(LDAPExtSampler.USERDN, userdn.getText());
  288           element.setProperty(LDAPExtSampler.USERPW, userpw.getText());
  289           element.setProperty(LDAPExtSampler.COMPAREDN, comparedn.getText());
  290           element.setProperty(LDAPExtSampler.COMPAREFILT, comparefilt.getText());
  291           element.setProperty(LDAPExtSampler.MODDDN, modddn.getText());
  292           element.setProperty(LDAPExtSampler.NEWDN, newdn.getText());
  293           if (addTest.isSelected()) {
  294               element.setProperty(new StringProperty(LDAPExtSampler.TEST, LDAPExtSampler.ADD));
  295               element.setProperty(new StringProperty(LDAPExtSampler.BASE_ENTRY_DN, add.getText()));
  296               element.setProperty(new TestElementProperty(LDAPExtSampler.ARGUMENTS, tableAddPanel.createTestElement()));
  297           }
  298           if (modifyTest.isSelected()) {
  299               element.setProperty(new StringProperty(LDAPExtSampler.TEST, LDAPExtSampler.MODIFY));
  300               element.setProperty(new StringProperty(LDAPExtSampler.BASE_ENTRY_DN, modify.getText()));
  301               element.setProperty(new TestElementProperty(LDAPExtSampler.LDAPARGUMENTS, tableModifyPanel
  302                       .createTestElement()));
  303           }
  304           if (deleteTest.isSelected()) {
  305               element.setProperty(new StringProperty(LDAPExtSampler.TEST, LDAPExtSampler.DELETE));
  306               element.setProperty(new StringProperty(LDAPExtSampler.DELETE, delete.getText()));
  307           }
  308           if (searchTest.isSelected()) {
  309               element.setProperty(new StringProperty(LDAPExtSampler.TEST, LDAPExtSampler.SEARCH));
  310               element.setProperty(new StringProperty(LDAPExtSampler.SEARCHBASE, searchbase.getText()));
  311               element.setProperty(new StringProperty(LDAPExtSampler.SEARCHFILTER, searchfilter.getText()));
  312           }
  313           if (bind.isSelected()) {
  314               element.setProperty(new StringProperty(LDAPExtSampler.TEST, LDAPExtSampler.BIND));
  315           }
  316           if (sbind.isSelected()) {
  317               element.setProperty(new StringProperty(LDAPExtSampler.TEST, LDAPExtSampler.SBIND));
  318           }
  319           if (compare.isSelected()) {
  320               element.setProperty(new StringProperty(LDAPExtSampler.TEST, LDAPExtSampler.COMPARE));
  321           }
  322           if (rename.isSelected()) {
  323               element.setProperty(new StringProperty(LDAPExtSampler.TEST, LDAPExtSampler.RENAME));
  324           }
  325           if (unbind.isSelected()) {
  326               element.setProperty(new StringProperty(LDAPExtSampler.TEST, LDAPExtSampler.UNBIND));
  327           }
  328       }
  329   
  330       /**
  331        * Implements JMeterGUIComponent.clearGui
  332        */
  333       public void clearGui() {
  334           super.clearGui();
  335   
  336           rootdn.setText(""); //$NON-NLS-1$
  337           searchbase.setText(""); //$NON-NLS-1$
  338           searchfilter.setText(""); //$NON-NLS-1$
  339           delete.setText(""); //$NON-NLS-1$
  340           add.setText(""); //$NON-NLS-1$
  341           modify.setText(""); //$NON-NLS-1$
  342           servername.setText(""); //$NON-NLS-1$
  343           port.setText(""); //$NON-NLS-1$
  344           add.setText(""); //$NON-NLS-1$
  345           scope.setSelectedIndex(SCOPE_STRINGS.length - 1);
  346           countlim.setText(""); //$NON-NLS-1$
  347           timelim.setText(""); //$NON-NLS-1$
  348           attribs.setText(""); //$NON-NLS-1$
  349           userdn.setText(""); //$NON-NLS-1$
  350           userpw.setText(""); //$NON-NLS-1$
  351           comparedn.setText(""); //$NON-NLS-1$
  352           comparefilt.setText(""); //$NON-NLS-1$
  353           modddn.setText(""); //$NON-NLS-1$
  354           newdn.setText(""); //$NON-NLS-1$
  355           connto.setText(""); //$NON-NLS-1$
  356           retobj.setSelected(false);
  357           deref.setSelected(false);
  358           parseflag.setSelected(false);
  359           secure.setSelected(false);
  360           addTest.setSelected(false);
  361           modifyTest.setSelected(false);
  362           deleteTest.setSelected(false);
  363           searchTest.setSelected(false);
  364           bind.setSelected(false);
  365           rename.setSelected(false);
  366           unbind.setSelected(false);
  367           sbind.setSelected(false);
  368           compare.setSelected(false);
  369   
  370           tableAddPanel.clear();
  371           tableModifyPanel.clear();
  372       }
  373   
  374       /***************************************************************************
  375        * This itemStateChanged listener for changing the card layout for based on
  376        * the test selected in the User defined test case.
  377        **************************************************************************/
  378       public void itemStateChanged(ItemEvent ie) {
  379           CardLayout cl = (CardLayout) (cards.getLayout());
  380           if (addTest.isSelected()) {
  381               cl.show(cards, CARDS_ADD);
  382           } else if (deleteTest.isSelected()) {
  383               cl.show(cards, CARDS_DELETE);
  384           } else if (bind.isSelected()) {
  385               cl.show(cards, CARDS_BIND);
  386           } else if (sbind.isSelected()) {
  387               cl.show(cards, CARDS_BIND);
  388           } else if (rename.isSelected()) {
  389               cl.show(cards, CARDS_RENAME);
  390           } else if (compare.isSelected()) {
  391               cl.show(cards, CARDS_COMPARE);
  392           } else if (searchTest.isSelected()) {
  393               cl.show(cards, CARDS_SEARCH);
  394           } else if (modifyTest.isSelected()) {
  395               cl.show(cards, CARDS_MODIFY);
  396           } else { // e.g unbind
  397               cl.show(cards, CARDS_DEFAULT);
  398           }
  399       }
  400   
  401       /***************************************************************************
  402        * This will create the servername panel in the LdapConfigGui
  403        **************************************************************************/
  404       private JPanel createServernamePanel() {
  405           JPanel serverPanel = new JPanel(new BorderLayout(5, 0));
  406           JLabel label = new JLabel(JMeterUtils.getResString("servername")); // $NON-NLS-1$
  407           label.setLabelFor(servername);
  408           serverPanel.add(label, BorderLayout.WEST);
  409           serverPanel.add(servername, BorderLayout.CENTER);
  410           return serverPanel;
  411       }
  412   
  413       /***************************************************************************
  414        * This will create the port panel in the LdapConfigGui
  415        **************************************************************************/
  416       private JPanel createPortPanel() {
  417           JPanel portPanel = new JPanel(new BorderLayout(5, 0));
  418           JLabel label = new JLabel(JMeterUtils.getResString("port")); // $NON-NLS-1$
  419           label.setLabelFor(port);
  420           portPanel.add(label, BorderLayout.WEST);
  421           portPanel.add(port, BorderLayout.CENTER);
  422           return portPanel;
  423       }
  424   
  425       /***************************************************************************
  426        * This will create the Root distinguised name panel in the LdapConfigGui
  427        **************************************************************************/
  428       private JPanel createRootdnPanel() {
  429           JPanel rootdnPanel = new JPanel(new BorderLayout(5, 0));
  430           JLabel label = new JLabel(JMeterUtils.getResString("ddn")); // $NON-NLS-1$
  431           label.setLabelFor(rootdn);
  432           rootdnPanel.add(label, BorderLayout.WEST);
  433           rootdnPanel.add(rootdn, BorderLayout.CENTER);
  434           return rootdnPanel;
  435       }
  436   
  437       /***************************************************************************
  438        * This will create the bind/sbind panel in the LdapConfigGui
  439        **************************************************************************/
  440       private JPanel createBindPanel() {
  441           VerticalPanel bindPanel = new VerticalPanel();
  442           bindPanel.add(createServernamePanel());
  443           bindPanel.add(createPortPanel());
  444           bindPanel.add(createRootdnPanel());
  445   
  446           JPanel BPanel = new JPanel(new BorderLayout(5, 0));
  447           JLabel Blabel0 = new JLabel(JMeterUtils.getResString("userdn")); // $NON-NLS-1$
  448           Blabel0.setLabelFor(userdn);
  449           BPanel.add(Blabel0, BorderLayout.WEST);
  450           BPanel.add(userdn, BorderLayout.CENTER);
  451           bindPanel.add(BPanel);
  452   
  453           JPanel B1Panel = new JPanel(new BorderLayout(5, 0));
  454           JLabel Blabel1 = new JLabel(JMeterUtils.getResString("userpw")); // $NON-NLS-1$
  455           Blabel1.setLabelFor(userpw);
  456           B1Panel.add(Blabel1, BorderLayout.WEST);
  457           B1Panel.add(userpw, BorderLayout.CENTER);
  458           bindPanel.add(B1Panel);
  459   
  460           JPanel B2Panel = new JPanel(new BorderLayout(5, 0));
  461           JLabel Blabel2 = new JLabel(JMeterUtils.getResString("ldap_connto")); // $NON-NLS-1$
  462           Blabel2.setLabelFor(connto);
  463           B2Panel.add(Blabel2, BorderLayout.WEST);
  464           B2Panel.add(connto, BorderLayout.CENTER);
  465           bindPanel.add(B2Panel);
  466   
  467           bindPanel.add(secure);
  468           return bindPanel;
  469       }
  470   
  471       /***************************************************************************
  472        * This will create the bind panel in the LdapConfigGui
  473        **************************************************************************/
  474       private JPanel createComparePanel() {
  475           VerticalPanel cbindPanel = new VerticalPanel();
  476           JPanel cBPanel = new JPanel(new BorderLayout(5, 0));
  477           JLabel cBlabel0 = new JLabel(JMeterUtils.getResString("entrydn")); // $NON-NLS-1$
  478           cBlabel0.setLabelFor(comparedn);
  479           cBPanel.add(cBlabel0, BorderLayout.WEST);
  480           cBPanel.add(comparedn, BorderLayout.CENTER);
  481           cbindPanel.add(cBPanel);
  482   
  483           JPanel cBPanel1 = new JPanel(new BorderLayout(5, 0));
  484           JLabel cBlabel1 = new JLabel(JMeterUtils.getResString("comparefilt")); // $NON-NLS-1$
  485           cBlabel1.setLabelFor(comparefilt);
  486           cBPanel1.add(cBlabel1, BorderLayout.WEST);
  487           cBPanel1.add(comparefilt, BorderLayout.CENTER);
  488           cbindPanel.add(cBPanel1);
  489   
  490           return cbindPanel;
  491       }
  492   
  493       /***************************************************************************
  494        * This will create the Search controls panel in the LdapConfigGui
  495        **************************************************************************/
  496       private JPanel createSCPanel() {
  497           VerticalPanel SCPanel = new VerticalPanel();
  498   
  499           SCPanel.add(scope);
  500   
  501           JPanel SC1Panel = new JPanel(new BorderLayout(5, 0));
  502           JLabel label1 = new JLabel(JMeterUtils.getResString("countlim")); // $NON-NLS-1$
  503           label1.setLabelFor(countlim);
  504           SC1Panel.add(label1, BorderLayout.WEST);
  505           SC1Panel.add(countlim, BorderLayout.CENTER);
  506           SCPanel.add(SC1Panel);
  507   
  508           JPanel SC2Panel = new JPanel(new BorderLayout(5, 0));
  509           JLabel label2 = new JLabel(JMeterUtils.getResString("timelim")); // $NON-NLS-1$
  510           label2.setLabelFor(timelim);
  511           SC2Panel.add(label2, BorderLayout.WEST);
  512           SC2Panel.add(timelim, BorderLayout.CENTER);
  513           SCPanel.add(SC2Panel);
  514   
  515           JPanel SC3Panel = new JPanel(new BorderLayout(5, 0));
  516           JLabel label3 = new JLabel(JMeterUtils.getResString("attrs")); // $NON-NLS-1$
  517           label3.setLabelFor(attribs);
  518           SC3Panel.add(label3, BorderLayout.WEST);
  519           SC3Panel.add(attribs, BorderLayout.CENTER);
  520           SCPanel.add(SC3Panel);
  521   
  522           SCPanel.add(retobj);
  523           SCPanel.add(deref);
  524           SCPanel.add(parseflag);
  525   
  526           return SCPanel;
  527       }
  528   
  529       /***************************************************************************
  530        * This will create the Search panel in the LdapConfigGui
  531        **************************************************************************/
  532   
  533       private JPanel createSearchPanel() {
  534           VerticalPanel searchPanel = new VerticalPanel();
  535   
  536           JPanel searchBPanel = new JPanel(new BorderLayout(5, 0));
  537           JLabel label = new JLabel(JMeterUtils.getResString("searchbase")); // $NON-NLS-1$
  538           label.setLabelFor(searchbase);
  539           searchBPanel.add(label, BorderLayout.WEST);
  540           searchBPanel.add(searchbase, BorderLayout.CENTER);
  541   
  542           JPanel searchFPanel = new JPanel(new BorderLayout(5, 0));
  543           JLabel label20 = new JLabel(JMeterUtils.getResString("searchfilter")); // $NON-NLS-1$
  544           label20.setLabelFor(searchfilter);
  545           searchFPanel.add(label20, BorderLayout.WEST);
  546           searchFPanel.add(searchfilter, BorderLayout.CENTER);
  547   
  548           searchPanel.add(searchBPanel);
  549           searchPanel.add(searchFPanel);
  550           searchPanel.add(createSCPanel());
  551   
  552           return searchPanel;
  553       }
  554   
  555       /***************************************************************************
  556        * This will create the Moddn panel in the LdapConfigGui
  557        **************************************************************************/
  558   
  559       private JPanel createModdnPanel() {
  560           VerticalPanel modPanel = new VerticalPanel();
  561   
  562           JPanel renamePanel = new JPanel(new BorderLayout(5, 0));
  563           JLabel labelmod = new JLabel(JMeterUtils.getResString("modddn")); // $NON-NLS-1$
  564           labelmod.setLabelFor(modddn);
  565           renamePanel.add(labelmod, BorderLayout.WEST);
  566           renamePanel.add(modddn, BorderLayout.CENTER);
  567   
  568           JPanel rename2Panel = new JPanel(new BorderLayout(5, 0));
  569           JLabel labelmod2 = new JLabel(JMeterUtils.getResString("newdn")); // $NON-NLS-1$
  570           labelmod2.setLabelFor(newdn);
  571           rename2Panel.add(labelmod2, BorderLayout.WEST);
  572           rename2Panel.add(newdn, BorderLayout.CENTER);
  573   
  574           modPanel.add(renamePanel);
  575           modPanel.add(rename2Panel);
  576           return modPanel;
  577       }
  578   
  579       /***************************************************************************
  580        * This will create the Delete panel in the LdapConfigGui
  581        **************************************************************************/
  582       private JPanel createDeletePanel() {
  583           VerticalPanel panel = new VerticalPanel();
  584           JPanel deletePanel = new JPanel(new BorderLayout(5, 0));
  585           JLabel label = new JLabel(JMeterUtils.getResString("delete")); // $NON-NLS-1$
  586           label.setLabelFor(delete);
  587           deletePanel.add(label, BorderLayout.WEST);
  588           deletePanel.add(delete, BorderLayout.CENTER);
  589           panel.add(deletePanel);
  590           return panel;
  591       }
  592   
  593       /***************************************************************************
  594        * This will create the Add test panel in the LdapConfigGui
  595        **************************************************************************/
  596       private JPanel createAddPanel() {
  597           JPanel addPanel = new JPanel(new BorderLayout(5, 0));
  598           JPanel addInnerPanel = new JPanel(new BorderLayout(5, 0));
  599           JLabel label = new JLabel(JMeterUtils.getResString("entrydn")); // $NON-NLS-1$
  600           label.setLabelFor(add);
  601           addInnerPanel.add(label, BorderLayout.WEST);
  602           addInnerPanel.add(add, BorderLayout.CENTER);
  603           addPanel.add(addInnerPanel, BorderLayout.NORTH);
  604           addPanel.add(tableAddPanel, BorderLayout.CENTER);
  605           return addPanel;
  606       }
  607   
  608       /***************************************************************************
  609        * This will create the Modify panel in the LdapConfigGui
  610        **************************************************************************/
  611       private JPanel createModifyPanel() {
  612           JPanel modifyPanel = new JPanel(new BorderLayout(5, 0));
  613           JPanel modifyInnerPanel = new JPanel(new BorderLayout(5, 0));
  614           JLabel label = new JLabel(JMeterUtils.getResString("entrydn")); // $NON-NLS-1$
  615           label.setLabelFor(modify);
  616           modifyInnerPanel.add(label, BorderLayout.WEST);
  617           modifyInnerPanel.add(modify, BorderLayout.CENTER);
  618           modifyPanel.add(modifyInnerPanel, BorderLayout.NORTH);
  619           modifyPanel.add(tableModifyPanel, BorderLayout.CENTER);
  620           return modifyPanel;
  621       }
  622   
  623       /***************************************************************************
  624        * This will create the user defined test panel for create or modify or
  625        * delete or search based on the panel selected in the itemevent in the
  626        * LdapConfigGui
  627        **************************************************************************/
  628       private JPanel testPanel() {
  629           cards = new JPanel(new CardLayout());
  630           cards.add(new JPanel(),         CARDS_DEFAULT);
  631           cards.add(createAddPanel(),     CARDS_ADD);
  632           cards.add(createModifyPanel(),  CARDS_MODIFY);
  633           cards.add(createModdnPanel(),   CARDS_RENAME);
  634           cards.add(createDeletePanel(),  CARDS_DELETE);
  635           cards.add(createSearchPanel(),  CARDS_SEARCH);
  636           cards.add(createBindPanel(),    CARDS_BIND);
  637           cards.add(createComparePanel(), CARDS_COMPARE);
  638           return cards;
  639       }
  640   
  641       /***************************************************************************
  642        * This will create the test panel in the LdapConfigGui
  643        **************************************************************************/
  644       private JPanel createTestPanel() {
  645           JPanel testPanel = new JPanel(new BorderLayout());
  646           testPanel.setBorder(BorderFactory.createTitledBorder(JMeterUtils.getResString("test_configuration"))); // $NON-NLS-1$
  647   
  648           testPanel.add(new JLabel(JMeterUtils.getResString("testt"))); // $NON-NLS-1$
  649           JPanel rowPanel = new JPanel();
  650           JPanel row2Panel = new JPanel();
  651   
  652           rowPanel.add(bind);
  653           bGroup.add(bind);
  654           rowPanel.add(unbind);
  655           bGroup.add(unbind);
  656           rowPanel.add(sbind);
  657           bGroup.add(sbind);
  658           rowPanel.add(rename);
  659           bGroup.add(rename);
  660           row2Panel.add(addTest);
  661           bGroup.add(addTest);
  662           row2Panel.add(deleteTest);
  663           bGroup.add(deleteTest);
  664           row2Panel.add(searchTest);
  665           bGroup.add(searchTest);
  666           row2Panel.add(compare);
  667           bGroup.add(compare);
  668           row2Panel.add(modifyTest);
  669           bGroup.add(modifyTest);
  670           testPanel.add(rowPanel, BorderLayout.NORTH);
  671           testPanel.add(row2Panel, BorderLayout.SOUTH);
  672           return testPanel;
  673       }
  674   
  675       /***************************************************************************
  676        * This will initalise all the panel in the LdapConfigGui
  677        **************************************************************************/
  678       private void init() {
  679           setLayout(new BorderLayout(0, 5));
  680           if (displayName) {
  681               setBorder(makeBorder());
  682               add(makeTitlePanel(), BorderLayout.NORTH);
  683           }
  684           VerticalPanel mainPanel = new VerticalPanel();
  685           mainPanel.add(createTestPanel());
  686           mainPanel.add(testPanel());
  687           add(mainPanel, BorderLayout.CENTER);
  688           // Take note of when buttong are changed so can change panel
  689           bind.addItemListener(this);
  690           sbind.addItemListener(this);
  691           unbind.addItemListener(this);
  692           compare.addItemListener(this);
  693           addTest.addItemListener(this);
  694           modifyTest.addItemListener(this);
  695           rename.addItemListener(this);
  696           deleteTest.addItemListener(this);
  697           searchTest.addItemListener(this);
  698       }
  699   }

Home » jakarta-jmeter-2.3.4_src » org.apache.jmeter.protocol.ldap.config.gui » [javadoc | source]