Source Code Cross Referenced for LdapConfigGui.java in  » Testing » jakarta-jmeter » org » apache » jmeter » protocol » ldap » config » gui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » jakarta jmeter » org.apache.jmeter.protocol.ldap.config.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:
034:        import org.apache.jmeter.config.ConfigTestElement;
035:        import org.apache.jmeter.config.gui.AbstractConfigGui;
036:        import org.apache.jmeter.config.gui.ArgumentsPanel;
037:        import org.apache.jmeter.gui.util.VerticalPanel;
038:        import org.apache.jmeter.protocol.ldap.sampler.LDAPSampler;
039:        import org.apache.jmeter.testelement.TestElement;
040:        import org.apache.jmeter.testelement.property.BooleanProperty;
041:        import org.apache.jmeter.testelement.property.StringProperty;
042:        import org.apache.jmeter.testelement.property.TestElementProperty;
043:        import org.apache.jmeter.util.JMeterUtils;
044:
045:        /**
046:         * This class LdapConfigGui is user interface gui for getting all the
047:         * configuration values from the user.
048:         * 
049:         * Created Apr 29 2003 11:45 AM
050:         * 
051:         */
052:        public class LdapConfigGui extends AbstractConfigGui implements 
053:                ItemListener {
054:
055:            private JTextField rootdn = new JTextField(20);
056:
057:            private JTextField searchbase = new JTextField(20);
058:
059:            private JTextField searchfilter = new JTextField(20);
060:
061:            private JTextField delete = new JTextField(20);
062:
063:            private JTextField add = new JTextField(20);
064:
065:            private JTextField modify = new JTextField(20);
066:
067:            private JTextField servername = new JTextField(20);
068:
069:            private JTextField port = new JTextField(20);
070:
071:            private JCheckBox user_Defined = new JCheckBox(JMeterUtils
072:                    .getResString("user_defined_test")); // $NON-NLS-1$
073:
074:            private JRadioButton addTest = new JRadioButton(JMeterUtils
075:                    .getResString("add_test")); // $NON-NLS-1$
076:
077:            private JRadioButton modifyTest = new JRadioButton(JMeterUtils
078:                    .getResString("modify_test")); // $NON-NLS-1$
079:
080:            private JRadioButton deleteTest = new JRadioButton(JMeterUtils
081:                    .getResString("delete_test")); // $NON-NLS-1$
082:
083:            private JRadioButton searchTest = new JRadioButton(JMeterUtils
084:                    .getResString("search_test")); // $NON-NLS-1$
085:
086:            private ButtonGroup bGroup = new ButtonGroup();
087:
088:            private boolean displayName = true;
089:
090:            ArgumentsPanel tableAddPanel = new ArgumentsPanel(JMeterUtils
091:                    .getResString("add_test")); // $NON-NLS-1$
092:
093:            ArgumentsPanel tableModifyPanel = new ArgumentsPanel(JMeterUtils
094:                    .getResString("modify_test")); // $NON-NLS-1$
095:
096:            private JPanel cards;
097:
098:            /**
099:             * Default constructor for LdapConfigGui.
100:             */
101:            public LdapConfigGui() {
102:                this (true);
103:            }
104:
105:            public String getLabelResource() {
106:                return "ldap_sample_title"; // $NON-NLS-1$
107:            }
108:
109:            /**
110:             * A newly created component can be initialized with the contents of a Test
111:             * Element object by calling this method. The component is responsible for
112:             * querying the Test Element object for the relevant information to display
113:             * in its GUI.
114:             * 
115:             * @param element
116:             *            the TestElement to configure
117:             */
118:            public void configure(TestElement element) {
119:                super .configure(element);
120:                servername.setText(element
121:                        .getPropertyAsString(LDAPSampler.SERVERNAME));
122:                port.setText(element.getPropertyAsString(LDAPSampler.PORT));
123:                rootdn.setText(element.getPropertyAsString(LDAPSampler.ROOTDN));
124:                CardLayout cl = (CardLayout) (cards.getLayout());
125:                final String testType = element
126:                        .getPropertyAsString(LDAPSampler.TEST);
127:                if (testType.equals(LDAPSampler.ADD)) {
128:                    addTest.setSelected(true);
129:                    add.setText(element
130:                            .getPropertyAsString(LDAPSampler.BASE_ENTRY_DN));
131:                    tableAddPanel.configure((TestElement) element.getProperty(
132:                            LDAPSampler.ARGUMENTS).getObjectValue());
133:                    cl.show(cards, "Add");
134:                } else if (testType.equals(LDAPSampler.MODIFY)) {
135:                    modifyTest.setSelected(true);
136:                    modify.setText(element
137:                            .getPropertyAsString(LDAPSampler.BASE_ENTRY_DN));
138:                    tableModifyPanel.configure((TestElement) element
139:                            .getProperty(LDAPSampler.ARGUMENTS)
140:                            .getObjectValue());
141:                    cl.show(cards, "Modify");
142:                } else if (testType.equals(LDAPSampler.DELETE)) {
143:                    deleteTest.setSelected(true);
144:                    delete.setText(element
145:                            .getPropertyAsString(LDAPSampler.DELETE));
146:                    cl.show(cards, "Delete");
147:                } else if (testType.equals(LDAPSampler.SEARCHBASE)) {
148:                    searchTest.setSelected(true);
149:                    searchbase.setText(element
150:                            .getPropertyAsString(LDAPSampler.SEARCHBASE));
151:                    searchfilter.setText(element
152:                            .getPropertyAsString(LDAPSampler.SEARCHFILTER));
153:                    cl.show(cards, "Search");
154:                }
155:
156:                if (element.getPropertyAsBoolean(LDAPSampler.USER_DEFINED)) {
157:                    user_Defined.setSelected(true);
158:                } else {
159:                    user_Defined.setSelected(false);
160:                    cl.show(cards, ""); // $NON-NLS-1$
161:                }
162:            }
163:
164:            /* Implements JMeterGUIComponent.createTestElement() */
165:            public TestElement createTestElement() {
166:                ConfigTestElement element = new ConfigTestElement();
167:                modifyTestElement(element);
168:                return element;
169:            }
170:
171:            /**
172:             * Modifies a given TestElement to mirror the data in the gui components.
173:             * 
174:             * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
175:             */
176:            public void modifyTestElement(TestElement element) {
177:                element.clear();
178:                configureTestElement(element);
179:                element.setProperty(LDAPSampler.SERVERNAME, servername
180:                        .getText());
181:                element.setProperty(LDAPSampler.PORT, port.getText());
182:                element.setProperty(LDAPSampler.ROOTDN, rootdn.getText());
183:                element.setProperty(new BooleanProperty(
184:                        LDAPSampler.USER_DEFINED, user_Defined.isSelected()));
185:
186:                if (addTest.isSelected()) {
187:                    element.setProperty(new StringProperty(LDAPSampler.TEST,
188:                            LDAPSampler.ADD));
189:                    element.setProperty(new StringProperty(
190:                            LDAPSampler.BASE_ENTRY_DN, add.getText()));
191:                    element.setProperty(new TestElementProperty(
192:                            LDAPSampler.ARGUMENTS, tableAddPanel
193:                                    .createTestElement()));
194:                }
195:
196:                if (modifyTest.isSelected()) {
197:                    element.setProperty(new StringProperty(LDAPSampler.TEST,
198:                            LDAPSampler.MODIFY));
199:                    element.setProperty(new StringProperty(
200:                            LDAPSampler.BASE_ENTRY_DN, modify.getText()));
201:                    element.setProperty(new TestElementProperty(
202:                            LDAPSampler.ARGUMENTS, tableModifyPanel
203:                                    .createTestElement()));
204:                }
205:
206:                if (deleteTest.isSelected()) {
207:                    element.setProperty(new StringProperty(LDAPSampler.TEST,
208:                            LDAPSampler.DELETE));
209:                    element.setProperty(new StringProperty(LDAPSampler.DELETE,
210:                            delete.getText()));
211:                }
212:
213:                if (searchTest.isSelected()) {
214:                    element.setProperty(new StringProperty(LDAPSampler.TEST,
215:                            LDAPSampler.SEARCHBASE));
216:                    element.setProperty(new StringProperty(
217:                            LDAPSampler.SEARCHBASE, searchbase.getText()));
218:                    element.setProperty(new StringProperty(
219:                            LDAPSampler.SEARCHFILTER, searchfilter.getText()));
220:                }
221:            }
222:
223:            /**
224:             * Implements JMeterGUIComponent.clearGui
225:             */
226:            public void clearGui() {
227:                super .clearGui();
228:
229:                rootdn.setText(""); //$NON-NLS-1$
230:                searchbase.setText(""); //$NON-NLS-1$
231:                searchfilter.setText(""); //$NON-NLS-1$
232:                delete.setText(""); //$NON-NLS-1$
233:                add.setText(""); //$NON-NLS-1$
234:                modify.setText(""); //$NON-NLS-1$
235:                servername.setText(""); //$NON-NLS-1$
236:                port.setText(""); //$NON-NLS-1$
237:                user_Defined.setSelected(false);
238:                addTest.setSelected(false);
239:                modifyTest.setSelected(false);
240:                deleteTest.setSelected(false);
241:                searchTest.setSelected(false);
242:            }
243:
244:            /**
245:             * This itemStateChanged listener for changing the card layout for based on\
246:             * the test selected in the User defined test case.
247:             */
248:            public void itemStateChanged(ItemEvent ie) {
249:                CardLayout cl = (CardLayout) (cards.getLayout());
250:                if (user_Defined.isSelected()) {
251:                    if (addTest.isSelected()) {
252:                        cl.show(cards, "Add");
253:                        tableModifyPanel.clear();
254:                        modify.setText(""); // $NON-NLS-1$
255:                        searchbase.setText(""); // $NON-NLS-1$
256:                        searchfilter.setText(""); // $NON-NLS-1$
257:                        delete.setText("");
258:                    } else if (deleteTest.isSelected()) {
259:                        cl.show(cards, "Delete");
260:                        tableModifyPanel.clear();
261:                        modify.setText(""); // $NON-NLS-1$
262:                        tableAddPanel.clear();
263:                        add.setText(""); // $NON-NLS-1$
264:                        searchbase.setText(""); // $NON-NLS-1$
265:                        searchfilter.setText(""); // $NON-NLS-1$
266:                    } else if (searchTest.isSelected()) {
267:                        cl.show(cards, "Search");
268:                        delete.setText(""); // $NON-NLS-1$
269:                        tableModifyPanel.clear();
270:                        modify.setText(""); // $NON-NLS-1$
271:                        tableAddPanel.clear();
272:                        add.setText(""); // $NON-NLS-1$
273:                    } else if (modifyTest.isSelected()) {
274:                        cl.show(cards, "Modify");
275:                        tableAddPanel.clear();
276:                        add.setText(""); // $NON-NLS-1$
277:                        searchbase.setText(""); // $NON-NLS-1$
278:                        searchfilter.setText(""); // $NON-NLS-1$
279:                        delete.setText("");
280:                    } else {
281:                        cl.show(cards, ""); // $NON-NLS-1$
282:                        tableAddPanel.clear();
283:                        add.setText(""); // $NON-NLS-1$
284:                        tableModifyPanel.clear();
285:                        modify.setText(""); // $NON-NLS-1$
286:                        searchbase.setText(""); // $NON-NLS-1$
287:                        searchfilter.setText(""); // $NON-NLS-1$
288:                        delete.setText(""); // $NON-NLS-1$
289:                    }
290:                } else {
291:                    cl.show(cards, ""); // $NON-NLS-1$
292:                    tableAddPanel.clear();
293:                    add.setText(""); // $NON-NLS-1$
294:                    tableModifyPanel.clear();
295:                    modify.setText(""); // $NON-NLS-1$
296:                    searchbase.setText(""); // $NON-NLS-1$
297:                    searchfilter.setText(""); // $NON-NLS-1$
298:                    delete.setText(""); // $NON-NLS-1$
299:                }
300:            }
301:
302:            public LdapConfigGui(boolean displayName) {
303:                this .displayName = displayName;
304:                init();
305:            }
306:
307:            /**
308:             * This will create the servername panel in the LdapConfigGui.
309:             */
310:            private JPanel createServernamePanel() {
311:                JPanel serverPanel = new JPanel(new BorderLayout(5, 0));
312:                JLabel label = new JLabel(JMeterUtils
313:                        .getResString("servername")); // $NON-NLS-1$
314:                label.setLabelFor(servername);
315:                serverPanel.add(label, BorderLayout.WEST);
316:                serverPanel.add(servername, BorderLayout.CENTER);
317:                return serverPanel;
318:            }
319:
320:            /**
321:             * This will create the port panel in the LdapConfigGui.
322:             */
323:            private JPanel createPortPanel() {
324:                JPanel portPanel = new JPanel(new BorderLayout(5, 0));
325:                JLabel label = new JLabel(JMeterUtils.getResString("port")); // $NON-NLS-1$
326:                label.setLabelFor(port);
327:                portPanel.add(label, BorderLayout.WEST);
328:                portPanel.add(port, BorderLayout.CENTER);
329:                return portPanel;
330:            }
331:
332:            /**
333:             * This will create the Root distinguised name panel in the LdapConfigGui.
334:             */
335:            private JPanel createRootdnPanel() {
336:                JPanel rootdnPanel = new JPanel(new BorderLayout(5, 0));
337:                JLabel label = new JLabel(JMeterUtils.getResString("dn")); // $NON-NLS-1$
338:                label.setLabelFor(rootdn);
339:                rootdnPanel.add(label, BorderLayout.WEST);
340:                rootdnPanel.add(rootdn, BorderLayout.CENTER);
341:                return rootdnPanel;
342:            }
343:
344:            /**
345:             * This will create the Search panel in the LdapConfigGui.
346:             */
347:            private JPanel createSearchPanel() {
348:                VerticalPanel searchPanel = new VerticalPanel();
349:                JPanel searchBPanel = new JPanel(new BorderLayout(5, 0));
350:                JLabel label = new JLabel(JMeterUtils
351:                        .getResString("search_base")); // $NON-NLS-1$
352:                label.setLabelFor(searchbase);
353:                searchBPanel.add(label, BorderLayout.WEST);
354:                searchBPanel.add(searchbase, BorderLayout.CENTER);
355:                JPanel searchFPanel = new JPanel(new BorderLayout(5, 0));
356:                JLabel label2 = new JLabel(JMeterUtils
357:                        .getResString("search_filter")); // $NON-NLS-1$
358:                label2.setLabelFor(searchfilter);
359:                searchFPanel.add(label2, BorderLayout.WEST);
360:                searchFPanel.add(searchfilter, BorderLayout.CENTER);
361:                searchPanel.add(searchBPanel);
362:                searchPanel.add(searchFPanel);
363:                return searchPanel;
364:            }
365:
366:            /**
367:             * This will create the Delete panel in the LdapConfigGui.
368:             */
369:            private JPanel createDeletePanel() {
370:                VerticalPanel panel = new VerticalPanel();
371:                JPanel deletePanel = new JPanel(new BorderLayout(5, 0));
372:                JLabel label = new JLabel(JMeterUtils.getResString("delete")); // $NON-NLS-1$
373:                label.setLabelFor(delete);
374:                deletePanel.add(label, BorderLayout.WEST);
375:                deletePanel.add(delete, BorderLayout.CENTER);
376:                panel.add(deletePanel);
377:                return panel;
378:            }
379:
380:            /**
381:             * This will create the Add test panel in the LdapConfigGui.
382:             */
383:            private JPanel createAddPanel() {
384:                JPanel addPanel = new JPanel(new BorderLayout(5, 0));
385:                JPanel addInnerPanel = new JPanel(new BorderLayout(5, 0));
386:                JLabel label = new JLabel(JMeterUtils.getResString("entry_dn")); // $NON-NLS-1$
387:                label.setLabelFor(add);
388:                addInnerPanel.add(label, BorderLayout.WEST);
389:                addInnerPanel.add(add, BorderLayout.CENTER);
390:                addPanel.add(addInnerPanel, BorderLayout.NORTH);
391:                addPanel.add(tableAddPanel, BorderLayout.CENTER);
392:                return addPanel;
393:            }
394:
395:            /**
396:             * This will create the Modify panel in the LdapConfigGui.
397:             */
398:            private JPanel createModifyPanel() {
399:                JPanel modifyPanel = new JPanel(new BorderLayout(5, 0));
400:                JPanel modifyInnerPanel = new JPanel(new BorderLayout(5, 0));
401:                JLabel label = new JLabel(JMeterUtils.getResString("entry_dn")); // $NON-NLS-1$
402:                label.setLabelFor(modify);
403:                modifyInnerPanel.add(label, BorderLayout.WEST);
404:                modifyInnerPanel.add(modify, BorderLayout.CENTER);
405:                modifyPanel.add(modifyInnerPanel, BorderLayout.NORTH);
406:                modifyPanel.add(tableModifyPanel, BorderLayout.CENTER);
407:                return modifyPanel;
408:            }
409:
410:            /**
411:             * This will create the user defined test panel for create or modify or
412:             * delete or search based on the panel selected in the itemevent in the
413:             * LdapConfigGui.
414:             */
415:            private JPanel testPanel() {
416:                cards = new JPanel(new CardLayout());
417:                cards.add(new JPanel(), "");
418:                cards.add(createAddPanel(), "Add");
419:                cards.add(createModifyPanel(), "Modify");
420:                cards.add(createDeletePanel(), "Delete");
421:                cards.add(createSearchPanel(), "Search");
422:                return cards;
423:            }
424:
425:            /**
426:             * This will create the test panel in the LdapConfigGui.
427:             */
428:            private JPanel createTestPanel() {
429:                JPanel testPanel = new JPanel(new BorderLayout());
430:                testPanel.setBorder(BorderFactory
431:                        .createTitledBorder(JMeterUtils
432:                                .getResString("test_configuration"))); // $NON-NLS-1$
433:
434:                testPanel.add(new JLabel(JMeterUtils.getResString("test"))); // $NON-NLS-1$
435:                JPanel rowPanel = new JPanel();
436:
437:                rowPanel.add(addTest);
438:                bGroup.add(addTest);
439:                rowPanel.add(deleteTest);
440:                bGroup.add(deleteTest);
441:                rowPanel.add(searchTest);
442:                bGroup.add(searchTest);
443:                rowPanel.add(modifyTest);
444:                bGroup.add(modifyTest);
445:                testPanel.add(rowPanel, BorderLayout.NORTH);
446:                testPanel.add(user_Defined, BorderLayout.CENTER);
447:                return testPanel;
448:            }
449:
450:            /**
451:             * This will initialise all the panel in the LdapConfigGui.
452:             */
453:            private void init() {
454:                setLayout(new BorderLayout(0, 5));
455:
456:                if (displayName) {
457:                    setBorder(makeBorder());
458:                    add(makeTitlePanel(), BorderLayout.NORTH);
459:                }
460:                VerticalPanel mainPanel = new VerticalPanel();
461:                mainPanel.add(createServernamePanel());
462:                mainPanel.add(createPortPanel());
463:                mainPanel.add(createRootdnPanel());
464:                mainPanel.add(createTestPanel());
465:                mainPanel.add(testPanel());
466:                add(mainPanel, BorderLayout.CENTER);
467:
468:                user_Defined.addItemListener(this);
469:                addTest.addItemListener(this);
470:                modifyTest.addItemListener(this);
471:                deleteTest.addItemListener(this);
472:                searchTest.addItemListener(this);
473:            }
474:        }
w__w__w_._j___a__v__a2_s.c__o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.