Source Code Cross Referenced for MailReaderSamplerGui.java in  » Testing » jakarta-jmeter » org » apache » jmeter » protocol » mail » sampler » 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.mail.sampler.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:        package org.apache.jmeter.protocol.mail.sampler.gui;
019:
020:        import java.awt.event.ActionEvent;
021:        import java.awt.event.ActionListener;
022:
023:        import javax.swing.ButtonGroup;
024:        import javax.swing.DefaultComboBoxModel;
025:        import javax.swing.JCheckBox;
026:        import javax.swing.JComboBox;
027:        import javax.swing.JLabel;
028:        import javax.swing.JPanel;
029:        import javax.swing.JRadioButton;
030:        import javax.swing.JTextField;
031:        import javax.swing.event.ChangeEvent;
032:        import javax.swing.event.ChangeListener;
033:
034:        import org.apache.jmeter.gui.util.HorizontalPanel;
035:        import org.apache.jmeter.protocol.mail.sampler.MailReaderSampler;
036:        import org.apache.jmeter.samplers.gui.AbstractSamplerGui;
037:        import org.apache.jmeter.testelement.TestElement;
038:        import org.apache.jmeter.util.JMeterUtils;
039:        import org.apache.jorphan.gui.layout.VerticalLayout;
040:
041:        public class MailReaderSamplerGui extends AbstractSamplerGui {
042:
043:            // Gui Components
044:            private JComboBox serverTypeBox;
045:
046:            private JTextField serverBox;
047:
048:            private JTextField usernameBox;
049:
050:            private JTextField passwordBox;
051:
052:            private JTextField folderBox;
053:
054:            private JLabel folderLabel;
055:
056:            private JRadioButton allMessagesButton;
057:
058:            private JRadioButton someMessagesButton;
059:
060:            private JTextField someMessagesField;
061:
062:            private JCheckBox deleteBox;
063:
064:            // Labels
065:            private final static String POP3Label = JMeterUtils
066:                    .getResString("mail_reader_pop3");// $NON-NLS-1$
067:
068:            private final static String IMAPLabel = JMeterUtils
069:                    .getResString("mail_reader_imap");// $NON-NLS-1$
070:
071:            private final static String ServerTypeLabel = JMeterUtils
072:                    .getResString("mail_reader_server_type");// $NON-NLS-1$
073:
074:            private final static String ServerLabel = JMeterUtils
075:                    .getResString("mail_reader_server");// $NON-NLS-1$
076:
077:            private final static String AccountLabel = JMeterUtils
078:                    .getResString("mail_reader_account");// $NON-NLS-1$
079:
080:            private final static String PasswordLabel = JMeterUtils
081:                    .getResString("mail_reader_password");// $NON-NLS-1$
082:
083:            private final static String NumMessagesLabel = JMeterUtils
084:                    .getResString("mail_reader_num_messages");// $NON-NLS-1$
085:
086:            private final static String AllMessagesLabel = JMeterUtils
087:                    .getResString("mail_reader_all_messages");// $NON-NLS-1$
088:
089:            private final static String DeleteLabel = JMeterUtils
090:                    .getResString("mail_reader_delete");// $NON-NLS-1$
091:
092:            private final static String FolderLabel = JMeterUtils
093:                    .getResString("mail_reader_folder");// $NON-NLS-1$
094:
095:            private static final String INBOX = "INBOX"; // $NON-NLS-1$
096:
097:            public MailReaderSamplerGui() {
098:                init();
099:                initGui();
100:            }
101:
102:            public String getLabelResource() {
103:                return "mail_reader_title"; // $NON-NLS-1$
104:            }
105:
106:            /*
107:             * (non-Javadoc) Copy the data from the test element to the GUI
108:             * 
109:             * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(org.apache.jmeter.testelement.TestElement)
110:             */
111:            public void configure(TestElement element) {
112:                MailReaderSampler mrs = (MailReaderSampler) element;
113:                if (mrs.getServerType().equals(MailReaderSampler.TYPE_POP3)) {
114:                    serverTypeBox.setSelectedItem(POP3Label);
115:                    folderBox.setText(INBOX);
116:                } else {
117:                    serverTypeBox.setSelectedItem(IMAPLabel);
118:                    folderBox.setText(mrs.getFolder());
119:                }
120:                serverBox.setText(mrs.getServer());
121:                usernameBox.setText(mrs.getUserName());
122:                passwordBox.setText(mrs.getPassword());
123:                if (mrs.getNumMessages() == MailReaderSampler.ALL_MESSAGES) {
124:                    allMessagesButton.setSelected(true);
125:                    someMessagesField.setText("0"); // $NON-NLS-1$
126:                } else {
127:                    someMessagesButton.setSelected(true);
128:                    someMessagesField.setText(mrs.getNumMessagesString());
129:                }
130:                deleteBox.setSelected(mrs.getDeleteMessages());
131:                super .configure(element);
132:            }
133:
134:            /*
135:             * (non-Javadoc) Create the corresponding Test Element and set up its data
136:             * 
137:             * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
138:             */
139:            public TestElement createTestElement() {
140:                MailReaderSampler sampler = new MailReaderSampler();
141:                modifyTestElement(sampler);
142:                return sampler;
143:            }
144:
145:            /*
146:             * (non-Javadoc) Modifies a given TestElement to mirror the data in the gui
147:             * components.
148:             * 
149:             * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
150:             */
151:            public void modifyTestElement(TestElement te) {
152:                te.clear();
153:                configureTestElement(te);
154:
155:                MailReaderSampler mrs = (MailReaderSampler) te;
156:
157:                if (((String) serverTypeBox.getSelectedItem())
158:                        .equals(POP3Label))
159:                    mrs.setServerType(MailReaderSampler.TYPE_POP3);
160:                else
161:                    mrs.setServerType(MailReaderSampler.TYPE_IMAP);
162:
163:                mrs.setFolder(folderBox.getText());
164:                mrs.setServer(serverBox.getText());
165:                mrs.setUserName(usernameBox.getText());
166:                mrs.setPassword(passwordBox.getText());
167:                if (allMessagesButton.isSelected())
168:                    mrs.setNumMessages(MailReaderSampler.ALL_MESSAGES);
169:                else
170:                    mrs.setNumMessages(someMessagesField.getText());
171:                mrs.setDeleteMessages(deleteBox.isSelected());
172:            }
173:
174:            // TODO - fix GUI layout problems
175:
176:            /*
177:             * Helper method to set up the GUI screen
178:             */
179:            private void init() {
180:                setLayout(new VerticalLayout(5, VerticalLayout.BOTH,
181:                        VerticalLayout.TOP));
182:                setBorder(makeBorder());
183:                add(makeTitlePanel());
184:
185:                JPanel serverTypePanel = new JPanel();
186:                serverTypePanel.add(new JLabel(ServerTypeLabel));
187:                DefaultComboBoxModel serverTypeModel = new DefaultComboBoxModel();
188:                serverTypeModel.addElement(POP3Label);
189:                serverTypeModel.addElement(IMAPLabel);
190:                serverTypeBox = new JComboBox(serverTypeModel);
191:                serverTypeBox.addActionListener(new ActionListener() {
192:                    public void actionPerformed(ActionEvent e) {
193:                        if (((String) serverTypeBox.getSelectedItem())
194:                                .equals(POP3Label)) {
195:                            folderLabel.setEnabled(false);
196:                            folderBox.setText(INBOX);
197:                            folderBox.setEnabled(false);
198:                        } else {
199:                            folderLabel.setEnabled(true);
200:                            folderBox.setEnabled(true);
201:                        }
202:                    }
203:                });
204:                serverTypePanel.add(serverTypeBox);
205:                add(serverTypePanel);
206:
207:                JPanel serverPanel = new JPanel();
208:                serverPanel.add(new JLabel(ServerLabel));
209:                serverBox = new JTextField(20);
210:                serverPanel.add(serverBox);
211:                add(serverPanel);
212:
213:                JPanel accountNamePanel = new JPanel();
214:                accountNamePanel.add(new JLabel(AccountLabel));
215:                usernameBox = new JTextField(20);
216:                accountNamePanel.add(usernameBox);
217:                add(accountNamePanel);
218:
219:                JPanel accountPassPanel = new JPanel();
220:                accountPassPanel.add(new JLabel(PasswordLabel));
221:                passwordBox = new JTextField(20);
222:                accountPassPanel.add(passwordBox);
223:                add(accountPassPanel);
224:
225:                JPanel folderPanel = new JPanel();
226:                folderLabel = new JLabel(FolderLabel);
227:                folderBox = new JTextField(INBOX, 10);
228:                folderPanel.add(folderLabel);
229:                folderPanel.add(folderBox);
230:                add(folderPanel);
231:
232:                HorizontalPanel numMessagesPanel = new HorizontalPanel();
233:                numMessagesPanel.add(new JLabel(NumMessagesLabel));
234:                ButtonGroup nmbg = new ButtonGroup();
235:                allMessagesButton = new JRadioButton(AllMessagesLabel);
236:                allMessagesButton.addChangeListener(new ChangeListener() {
237:                    public void stateChanged(ChangeEvent e) {
238:                        if (allMessagesButton.isSelected()) {
239:                            someMessagesField.setEnabled(false);
240:                        }
241:                    }
242:                });
243:                someMessagesButton = new JRadioButton();
244:                someMessagesButton.addChangeListener(new ChangeListener() {
245:                    public void stateChanged(ChangeEvent e) {
246:                        if (someMessagesButton.isSelected()) {
247:                            someMessagesField.setEnabled(true);
248:                        }
249:                    }
250:                });
251:                nmbg.add(allMessagesButton);
252:                nmbg.add(someMessagesButton);
253:                someMessagesField = new JTextField(5);
254:                allMessagesButton.setSelected(true);
255:                numMessagesPanel.add(allMessagesButton);
256:                numMessagesPanel.add(someMessagesButton);
257:                numMessagesPanel.add(someMessagesField);
258:                add(numMessagesPanel);
259:
260:                deleteBox = new JCheckBox(DeleteLabel);
261:                add(deleteBox);
262:            }
263:
264:            public void clearGui() {
265:                super .clearGui();
266:                initGui();
267:            }
268:
269:            private void initGui() {
270:                allMessagesButton.setSelected(true);
271:                //someMessagesButton.setSelected(false);
272:                //someMessagesField.setText("0");
273:                deleteBox.setSelected(false);
274:                folderBox.setText(INBOX);
275:                passwordBox.setText("");
276:                serverBox.setText("");
277:                usernameBox.setText("");
278:            }
279:        }
w___w___w.ja_va___2s___._com_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.