Source Code Cross Referenced for JMSPublisherGui.java in  » Testing » jakarta-jmeter » org » apache » jmeter » protocol » jms » control » 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.jms.control.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.jms.control.gui;
020:
021:        import java.awt.Dimension;
022:        import java.awt.Font;
023:        import java.awt.event.ActionEvent;
024:
025:        import javax.swing.JCheckBox;
026:        import javax.swing.JOptionPane;
027:        import javax.swing.JLabel;
028:        import javax.swing.JPanel;
029:        import javax.swing.border.Border;
030:        import javax.swing.border.EmptyBorder;
031:        import javax.swing.event.ChangeEvent;
032:        import javax.swing.event.ChangeListener;
033:
034:        import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
035:        import org.apache.jmeter.testelement.TestElement;
036:        import org.apache.jmeter.util.JMeterUtils;
037:        import org.apache.jmeter.gui.util.FilePanel;
038:        import org.apache.jorphan.gui.JLabeledRadio;
039:        import org.apache.jorphan.gui.JLabeledTextField;
040:        import org.apache.jorphan.gui.JLabeledTextArea;
041:        import org.apache.jorphan.gui.layout.VerticalLayout;
042:
043:        import org.apache.jmeter.protocol.jms.sampler.PublisherSampler;
044:
045:        /**
046:         * This is the GUI for JMS Publisher <br>
047:         * Created on: October 13, 2003
048:         * 
049:         */
050:        public class JMSPublisherGui extends AbstractSamplerGui implements 
051:                java.awt.event.ActionListener, ChangeListener {
052:
053:            private static final String ALL_FILES = "*.*"; //$NON-NLS-1$
054:
055:            public static final String use_file = JMeterUtils
056:                    .getResString("jms_use_file"); //$NON-NLS-1$
057:
058:            public static final String use_random = JMeterUtils
059:                    .getResString("jms_use_random_file"); //$NON-NLS-1$
060:
061:            public static final String use_text = JMeterUtils
062:                    .getResString("jms_use_text"); //$NON-NLS-1$
063:
064:            private String[] items = { use_file, use_random, use_text };
065:
066:            private String text_msg = JMeterUtils
067:                    .getResString("jms_text_message"); //$NON-NLS-1$
068:
069:            private String object_msg = JMeterUtils
070:                    .getResString("jms_object_message"); //$NON-NLS-1$
071:
072:            private String[] msgTypes = { text_msg, object_msg };
073:
074:            private String required = JMeterUtils
075:                    .getResString("jms_auth_required"); //$NON-NLS-1$
076:
077:            private String not_req = JMeterUtils
078:                    .getResString("jms_auth_not_required"); //$NON-NLS-1$
079:
080:            private String[] auth_items = { required, not_req };
081:
082:            JCheckBox useProperties = new JCheckBox(JMeterUtils
083:                    .getResString("jms_use_properties_file"), false); //$NON-NLS-1$
084:
085:            JLabeledRadio configChoice = new JLabeledRadio(JMeterUtils
086:                    .getResString("jms_config"), items, use_text); //$NON-NLS-1$
087:
088:            JLabeledTextField jndiICF = new JLabeledTextField(JMeterUtils
089:                    .getResString("jms_initial_context_factory")); //$NON-NLS-1$
090:
091:            JLabeledTextField urlField = new JLabeledTextField(JMeterUtils
092:                    .getResString("jms_provider_url")); //$NON-NLS-1$
093:
094:            JLabeledTextField jndiConnFac = new JLabeledTextField(JMeterUtils
095:                    .getResString("jms_connection_factory")); //$NON-NLS-1$
096:
097:            JLabeledTextField jmsTopic = new JLabeledTextField(JMeterUtils
098:                    .getResString("jms_topic")); //$NON-NLS-1$
099:
100:            JLabeledRadio reqAuth = new JLabeledRadio(JMeterUtils
101:                    .getResString("jms_authentication"), auth_items, not_req); //$NON-NLS-1$
102:
103:            JLabeledTextField jmsUser = new JLabeledTextField(JMeterUtils
104:                    .getResString("jms_user")); //$NON-NLS-1$
105:
106:            JLabeledTextField jmsPwd = new JLabeledTextField(JMeterUtils
107:                    .getResString("jms_pwd")); //$NON-NLS-1$
108:
109:            JLabeledTextField iterations = new JLabeledTextField(JMeterUtils
110:                    .getResString("jms_itertions")); //$NON-NLS-1$
111:
112:            FilePanel messageFile = new FilePanel(JMeterUtils
113:                    .getResString("jms_file"), ALL_FILES); //$NON-NLS-1$
114:
115:            FilePanel randomFile = new FilePanel(JMeterUtils
116:                    .getResString("jms_random_file"), ALL_FILES); //$NON-NLS-1$
117:
118:            JLabeledTextArea textMessage = new JLabeledTextArea(text_msg);
119:
120:            JLabeledRadio msgChoice = new JLabeledRadio(JMeterUtils
121:                    .getResString("jms_message_type"), msgTypes, text_msg); //$NON-NLS-1$
122:
123:            /**
124:             * This is the font for the note.
125:             */
126:            Font plainText = new Font("plain", Font.PLAIN, 10); //$NON-NLS-1$
127:
128:            private JPanel lookup = null;
129:
130:            private JPanel messagePanel = null;
131:
132:            public JMSPublisherGui() {
133:                init();
134:            }
135:
136:            /**
137:             * the name of the property for the JMSPublisherGui is jms_publisher.
138:             */
139:            public String getLabelResource() {
140:                return "jms_publisher"; //$NON-NLS-1$
141:            }
142:
143:            /**
144:             * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
145:             */
146:            public TestElement createTestElement() {
147:                PublisherSampler sampler = new PublisherSampler();
148:                this .configureTestElement(sampler);
149:                sampler.setUseJNDIProperties(String.valueOf(useProperties
150:                        .isSelected()));
151:                sampler.setJNDIIntialContextFactory(jndiICF.getText());
152:                sampler.setProviderUrl(urlField.getText());
153:                sampler.setConnectionFactory(jndiConnFac.getText());
154:                sampler.setTopic(jmsTopic.getText());
155:                sampler.setUsername(jmsUser.getText());
156:                sampler.setPassword(jmsPwd.getText());
157:                sampler.setTextMessage(textMessage.getText());
158:                sampler.setInputFile(messageFile.getFilename());
159:                sampler.setRandomPath(randomFile.getFilename());
160:                sampler.setConfigChoice(configChoice.getText());
161:                sampler.setMessageChoice(msgChoice.getText());
162:                sampler.setIterations(iterations.getText());
163:                sampler.setUseAuth(reqAuth.getText());
164:                return sampler;
165:            }
166:
167:            /**
168:             * Modifies a given TestElement to mirror the data in the gui components.
169:             * 
170:             * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
171:             */
172:            public void modifyTestElement(TestElement s) {
173:                PublisherSampler sampler = (PublisherSampler) s;
174:                this .configureTestElement(sampler);
175:                sampler.setUseJNDIProperties(String.valueOf(useProperties
176:                        .isSelected()));
177:                sampler.setJNDIIntialContextFactory(jndiICF.getText());
178:                sampler.setProviderUrl(urlField.getText());
179:                sampler.setConnectionFactory(jndiConnFac.getText());
180:                sampler.setTopic(jmsTopic.getText());
181:                sampler.setUsername(jmsUser.getText());
182:                sampler.setPassword(jmsPwd.getText());
183:                sampler.setTextMessage(textMessage.getText());
184:                sampler.setInputFile(messageFile.getFilename());
185:                sampler.setRandomPath(randomFile.getFilename());
186:                sampler.setConfigChoice(configChoice.getText());
187:                sampler.setMessageChoice(msgChoice.getText());
188:                sampler.setIterations(iterations.getText());
189:                sampler.setUseAuth(reqAuth.getText());
190:            }
191:
192:            /**
193:             * init() adds jndiICF to the mainPanel. The class reuses logic from
194:             * SOAPSampler, since it is common.
195:             */
196:            private void init() {
197:                this .setLayout(new VerticalLayout(5, VerticalLayout.LEFT,
198:                        VerticalLayout.TOP));
199:
200:                // MAIN PANEL
201:                JPanel mainPanel = new JPanel();
202:                Border margin = new EmptyBorder(10, 10, 5, 10);
203:                mainPanel.setBorder(margin);
204:                mainPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
205:
206:                // TITLE
207:                JLabel panelTitleLabel = new JLabel(getStaticLabel());
208:                Font curFont = panelTitleLabel.getFont();
209:                int curFontSize = curFont.getSize();
210:                curFontSize += 4;
211:                panelTitleLabel.setFont(new Font(curFont.getFontName(), curFont
212:                        .getStyle(), curFontSize));
213:                mainPanel.add(panelTitleLabel);
214:                // NAME
215:                mainPanel.add(getNamePanel());
216:
217:                // Button for browsing webservice wsdl
218:                lookup = new JPanel();
219:                lookup.setLayout(new VerticalLayout(6, VerticalLayout.LEFT));
220:                mainPanel.add(lookup);
221:                lookup.add(useProperties);
222:                useProperties.addChangeListener(this );
223:                lookup.add(jndiICF);
224:                lookup.add(urlField);
225:                lookup.add(jndiConnFac);
226:
227:                configChoice.addChangeListener(this );
228:                msgChoice.addChangeListener(this );
229:                reqAuth.addChangeListener(this );
230:
231:                JPanel commonParams = new JPanel();
232:                commonParams.setLayout(new VerticalLayout(6,
233:                        VerticalLayout.LEFT));
234:                mainPanel.add(commonParams);
235:                commonParams.add(jmsTopic);
236:                commonParams.add(reqAuth);
237:                commonParams.add(jmsUser);
238:                commonParams.add(jmsPwd);
239:                commonParams.add(iterations);
240:
241:                messagePanel = new JPanel();
242:                messagePanel.setLayout(new VerticalLayout(3,
243:                        VerticalLayout.LEFT));
244:                messagePanel.add(configChoice);
245:                messagePanel.add(msgChoice);
246:                messagePanel.add(messageFile);
247:                messagePanel.add(randomFile);
248:                messagePanel.add(textMessage);
249:                mainPanel.add(messagePanel);
250:
251:                Dimension pref = new Dimension(400, 200);
252:                textMessage.setPreferredSize(pref);
253:
254:                // we have to add the gui to the change listener
255:                this .add(mainPanel);
256:            }
257:
258:            public void clearGui() {
259:                super .clearGui();
260:                useProperties.setSelected(false);
261:                jndiICF.setText(""); // $NON-NLS-1$
262:                urlField.setText(""); // $NON-NLS-1$
263:                jndiConnFac.setText(""); // $NON-NLS-1$
264:                jmsTopic.setText(""); // $NON-NLS-1$
265:                jmsUser.setText(""); // $NON-NLS-1$
266:                jmsPwd.setText(""); // $NON-NLS-1$
267:                textMessage.setText(""); // $NON-NLS-1$
268:                messageFile.setFilename(""); // $NON-NLS-1$
269:                randomFile.setFilename(""); // $NON-NLS-1$
270:                msgChoice.setText(""); // $NON-NLS-1$
271:                configChoice.setText(use_text);
272:                updateConfig(use_text);
273:                iterations.setText(""); // $NON-NLS-1$
274:                reqAuth.setText(""); // $NON-NLS-1$
275:            }
276:
277:            /**
278:             * the implementation loads the URL and the soap action for the request.
279:             */
280:            public void configure(TestElement el) {
281:                super .configure(el);
282:                PublisherSampler sampler = (PublisherSampler) el;
283:                useProperties.setSelected(sampler
284:                        .getUseJNDIPropertiesAsBoolean());
285:                jndiICF.setText(sampler.getJNDIInitialContextFactory());
286:                urlField.setText(sampler.getProviderUrl());
287:                jndiConnFac.setText(sampler.getConnectionFactory());
288:                jmsTopic.setText(sampler.getTopic());
289:                jmsUser.setText(sampler.getUsername());
290:                jmsPwd.setText(sampler.getPassword());
291:                textMessage.setText(sampler.getTextMessage());
292:                messageFile.setFilename(sampler.getInputFile());
293:                randomFile.setFilename(sampler.getRandomPath());
294:                configChoice.setText(sampler.getConfigChoice());
295:                msgChoice.setText(sampler.getMessageChoice());
296:                updateConfig(sampler.getConfigChoice());
297:                iterations.setText(sampler.getIterations());
298:                reqAuth.setText(sampler.getUseAuth());
299:            }
300:
301:            /**
302:             * method from ActionListener
303:             * 
304:             * @param event
305:             *            that occurred
306:             */
307:            public void actionPerformed(ActionEvent event) {
308:            }
309:
310:            /**
311:             * When a widget state changes, it will notify this class so we can
312:             * enable/disable the correct items.
313:             */
314:            public void stateChanged(ChangeEvent event) {
315:                if (event.getSource() == this .configChoice) {
316:                    updateConfig(this .configChoice.getText());
317:                } else if (event.getSource() == this .msgChoice) {
318:                    updateMessageType(this .msgChoice.getText());
319:                } else if (event.getSource() == useProperties) {
320:                    if (useProperties.isSelected()) {
321:                        this .jndiICF.setEnabled(false);
322:                        this .urlField.setEnabled(false);
323:                    } else {
324:                        this .jndiICF.setEnabled(true);
325:                        this .urlField.setEnabled(true);
326:                    }
327:                }
328:            }
329:
330:            /**
331:             * Update config contains the actual logic for enabling or disabling text
332:             * message, file or random path.
333:             * 
334:             * @param command
335:             */
336:            public void updateConfig(String command) {
337:                if (command.equals(use_text)) {
338:                    textMessage.setEnabled(true);
339:                    messageFile.enableFile(false);
340:                    randomFile.enableFile(false);
341:                } else if (command.equals(use_random)) {
342:                    textMessage.setEnabled(false);
343:                    messageFile.enableFile(false);
344:                    randomFile.enableFile(true);
345:                } else {
346:                    textMessage.setEnabled(false);
347:                    messageFile.enableFile(true);
348:                    randomFile.enableFile(false);
349:                }
350:            }
351:
352:            /**
353:             * 
354:             * @param msgType
355:             */
356:            public void updateMessageType(String msgType) {
357:                if (msgType.equals(object_msg)) {
358:                    if (configChoice.getText().equals(use_text)) {
359:                        JOptionPane.showConfirmDialog(this ,
360:                                JMeterUtils.getResString("jms_error_msg"), //$NON-NLS-1$
361:                                "Warning", JOptionPane.OK_CANCEL_OPTION,
362:                                JOptionPane.ERROR_MESSAGE);
363:                    }
364:                }
365:            }
366:        }
w___ww__.j__av___a2___s.___co__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.