Source Code Cross Referenced for VirtualFormConfigurator.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » test » dataprovider » cachedrowsetdataprovider » 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 » IDE Netbeans » visualweb.api.designer » org.netbeans.test.dataprovider.cachedrowsetdataprovider 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:
004:        Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:
006:
007:        The contents of this file are subject to the terms of either the GNU
008:        General Public License Version 2 only ("GPL") or the Common
009:        Development and Distribution License("CDDL") (collectively, the
010:        "License"). You may not use this file except in compliance with the
011:        License. You can obtain a copy of the License at
012:        http://www.netbeans.org/cddl-gplv2.html
013:        or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
014:        specific language governing permissions and limitations under the
015:        License.  When distributing the software, include this License Header
016:        Notice in each file and include the License file at
017:        nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
018:        particular file as subject to the "Classpath" exception as provided
019:        by Sun in the GPL Version 2 section of the License file that
020:        accompanied this code. If applicable, add the following below the
021:        License Header, with the fields enclosed by brackets [] replaced by
022:        your own identifying information:
023:        "Portions Copyrighted [year] [name of copyright owner]"
024:
025:        Contributor(s):
026:
027:        The Original Software is NetBeans. The Initial Developer of the Original
028:        Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
029:        Microsystems, Inc. All Rights Reserved.
030:
031:        If you wish your version of this file to be governed by only the CDDL
032:        or only the GPL Version 2, indicate your decision by adding
033:        "[Contributor] elects to include this software in this distribution
034:        under the [CDDL or GPL Version 2] license." If you do not indicate a
035:        single choice of license, a recipient has the option to distribute
036:        your version of this file under either the CDDL, the GPL Version 2 or
037:        to extend the choice of license to its licensees as provided above.
038:        However, if you add GPL Version 2 code and therefore, elected the GPL
039:        Version 2 license, then the option applies only if the new code is
040:        made subject to such option by the copyright holder.
041:         */
042:        package org.netbeans.test.dataprovider.cachedrowsetdataprovider;
043:
044:        import java.awt.*;
045:        import java.util.*;
046:        import java.util.List;
047:        import java.awt.event.*;
048:        import javax.swing.*;
049:        import javax.swing.table.*;
050:        import javax.swing.tree.*;
051:        import org.netbeans.jemmy.*;
052:        import org.netbeans.jemmy.operators.*;
053:        import org.netbeans.modules.visualweb.gravy.*;
054:        import org.netbeans.modules.visualweb.gravy.designer.*;
055:        import org.netbeans.modules.visualweb.gravy.toolbox.*;
056:        import org.netbeans.test.dataprovider.common.*;
057:
058:        public class VirtualFormConfigurator implements  Constants {
059:            private JDialogOperator dialogOp;
060:            private List<VirtualFormEntry> virtualFormEntryList = new ArrayList<VirtualFormEntry>();
061:
062:            public VirtualFormConfigurator(String propertyName) {
063:                String virtualFormData = TestPropertiesHandler
064:                        .getTestProperty(propertyName);
065:                if (virtualFormData == null) {
066:                    throw new RuntimeException("Virtual Form Data ["
067:                            + propertyName + "] is not found");
068:                }
069:                Utils.logMsg("+++ Virtual Form Data for property ["
070:                        + propertyName + "] = [" + virtualFormData + "]");
071:                virtualFormEntryList = parseVirtualFormData(virtualFormData);
072:            }
073:
074:            private List<VirtualFormEntry> parseVirtualFormData(
075:                    String virtualFormData) {
076:                List<VirtualFormEntry> entryList = new ArrayList<VirtualFormEntry>();
077:
078:                String[] entryArray = virtualFormData.split("[{}]");
079:                for (String entry : entryArray) {
080:                    entry = entry.trim();
081:                    if (entry.length() > 0) {
082:                        String[] valueArray = entry.split("[,]");
083:                        int valueCounter = 0;
084:                        VirtualFormEntry virtualFormEntry = null;
085:                        for (String value : valueArray) {
086:                            value = value.trim();
087:                            if (value.length() > 0) {
088:                                if (valueCounter == 0) {
089:                                    virtualFormEntry = new VirtualFormEntry();
090:                                    virtualFormEntry.setComponentID(value);
091:                                } else if (valueCounter == 1) {
092:                                    virtualFormEntry.setVirtualFormName(value);
093:                                } else if (valueCounter == 2) {
094:                                    virtualFormEntry.setParticipateValue(value);
095:                                } else if (valueCounter == 3) {
096:                                    virtualFormEntry.setSubmitValue(value);
097:                                }
098:                                ++valueCounter;
099:                            }
100:                        }
101:                        if (virtualFormEntry != null) {
102:                            entryList.add(virtualFormEntry);
103:                        }
104:                    }
105:                }
106:                Utils.logMsg("+++ Virtual Form Entry List = "
107:                        + entryList.toString());
108:                return entryList;
109:            }
110:
111:            public void configureVirtualForm() {
112:                if (virtualFormEntryList.size() == 0) {
113:                    throw new RuntimeException(
114:                            "Virtual Form Entry List is empty");
115:                }
116:                for (VirtualFormEntry virtualFormEntry : virtualFormEntryList) {
117:                    String componentID = virtualFormEntry.getComponentID();
118:                    Utils.callPopupMenuOnNavigatorTreeNode(
119:                            NAVIGATOR_TREE_NODE_FORM_PREFIX + componentID,
120:                            POPUP_MENU_ITEM_CONFIGURE_VIRTUAL_FORMS);
121:
122:                    dialogOp = new JDialogOperator(
123:                            DIALOG_TITLE_CONFIGURE_VIRTUAL_FORMS);
124:                    Util.wait(500);
125:                    new QueueTool().waitEmpty();
126:                    Utils.logMsg("+++ Dialog ["
127:                            + DIALOG_TITLE_CONFIGURE_VIRTUAL_FORMS
128:                            + "] is found");
129:                    try {
130:                        updateVirtualForm(virtualFormEntry);
131:                    } finally {
132:                        closeVirtualFormDialog();
133:                    }
134:                }
135:            }
136:
137:            private void updateVirtualForm(VirtualFormEntry virtualFormEntry) {
138:                JTableOperator jTableOp = new JTableOperator(dialogOp);
139:
140:                String newVirtualFormName = virtualFormEntry
141:                        .getVirtualFormName(), newParticipateValue = virtualFormEntry
142:                        .getParticipateValue(), newSubmitValue = virtualFormEntry
143:                        .getSubmitValue();
144:
145:                int rowNum = findVirtualFormRow(jTableOp, newVirtualFormName);
146:                Utils.logMsg("+++ Virtual Form: cell values in the row ["
147:                        + rowNum + "] are changing...");
148:
149:                // modify cell values
150:                jTableOp.setValueAt(newVirtualFormName, rowNum,
151:                        VIRTUAL_FORM_COL_NAME);
152:                Util.wait(500);
153:                new QueueTool().waitEmpty();
154:
155:                jTableOp.setValueAt(newParticipateValue, rowNum,
156:                        VIRTUAL_FORM_COL_PARTICIPATE);
157:                Util.wait(500);
158:                new QueueTool().waitEmpty();
159:
160:                jTableOp.setValueAt(newSubmitValue, rowNum,
161:                        VIRTUAL_FORM_COL_SUBMIT);
162:                Util.wait(500);
163:                new QueueTool().waitEmpty();
164:
165:                checkUpdatingResult(jTableOp, rowNum, virtualFormEntry);
166:                Utils.logMsg("+++ Virtual Form has been updated properly");
167:            }
168:
169:            private void checkUpdatingResult(JTableOperator jTableOp,
170:                    int rowNum, VirtualFormEntry virtualFormEntry) {
171:                StringBuffer errMsg = new StringBuffer();
172:                String virtualFormName = jTableOp.getValueAt(rowNum,
173:                        VIRTUAL_FORM_COL_NAME).toString(), participateValue = jTableOp
174:                        .getValueAt(rowNum, VIRTUAL_FORM_COL_PARTICIPATE)
175:                        .toString(), submitValue = jTableOp.getValueAt(rowNum,
176:                        VIRTUAL_FORM_COL_SUBMIT).toString();
177:                Utils.logMsg("+++ Virtual Form: current NAME value = ["
178:                        + virtualFormName + "]");
179:                Utils.logMsg("+++ Virtual Form: current PARTICIPATE value = ["
180:                        + participateValue + "]");
181:                Utils.logMsg("+++ Virtual Form: current SUBMIT value = ["
182:                        + submitValue + "]");
183:
184:                if (!virtualFormName.equals(virtualFormEntry
185:                        .getVirtualFormName())) {
186:                    errMsg.append("Virtual Form: NAME value should be ["
187:                            + virtualFormEntry.getVirtualFormName()
188:                            + "], but it's [" + virtualFormName + "]");
189:                }
190:                if (!participateValue.equals(virtualFormEntry
191:                        .getParticipateValue())) {
192:                    if (errMsg.length() > 0)
193:                        errMsg.append(" ");
194:                    errMsg.append("Virtual Form: PARTICIPATE value should be ["
195:                            + virtualFormEntry.getParticipateValue()
196:                            + "], but it's [" + participateValue + "]");
197:                }
198:                if (!submitValue.equals(virtualFormEntry.getSubmitValue())) {
199:                    if (errMsg.length() > 0)
200:                        errMsg.append(" ");
201:                    errMsg.append("Virtual Form: SUBMIT value should be ["
202:                            + virtualFormEntry.getSubmitValue()
203:                            + "], but it's [" + submitValue + "]");
204:                }
205:                if (errMsg.length() > 0) {
206:                    throw new RuntimeException(errMsg.toString());
207:                }
208:            }
209:
210:            private int findVirtualFormRow(JTableOperator jTableOp,
211:                    String virtualFormName) {
212:                int rowNum = jTableOp.findCellRow(virtualFormName);
213:                Util.wait(500);
214:                new QueueTool().waitEmpty();
215:                if (rowNum < 0) {
216:                    addNewVirtualForm();
217:                    rowNum = jTableOp.getRowCount() - 1;
218:                }
219:                jTableOp.setRowSelectionInterval(rowNum, rowNum);
220:                Util.wait(500);
221:                new QueueTool().waitEmpty();
222:                return rowNum;
223:            }
224:
225:            private void addNewVirtualForm() {
226:                new JButtonOperator(dialogOp, BUTTON_LABEL_NEW).pushNoBlock();
227:                Util.wait(500);
228:                new QueueTool().waitEmpty();
229:            }
230:
231:            private void closeVirtualFormDialog() {
232:                new JButtonOperator(dialogOp, BUTTON_LABEL_OK).pushNoBlock();
233:                Util.wait(500);
234:                new QueueTool().waitEmpty();
235:            }
236:
237:            //========================================================================//
238:            private class VirtualFormEntry {
239:                private String virtualFormName, componentID, participateValue,
240:                        submitValue;
241:
242:                public String getVirtualFormName() {
243:                    return virtualFormName;
244:                }
245:
246:                public String getComponentID() {
247:                    return componentID;
248:                }
249:
250:                public String getParticipateValue() {
251:                    return participateValue;
252:                }
253:
254:                public String getSubmitValue() {
255:                    return submitValue;
256:                }
257:
258:                public void setVirtualFormName(String virtualFormName) {
259:                    this .virtualFormName = virtualFormName.trim();
260:                }
261:
262:                public void setComponentID(String componentID) {
263:                    this .componentID = componentID.trim();
264:                }
265:
266:                public void setSubmitValue(String submitValue) {
267:                    this .submitValue = submitValue.trim().equalsIgnoreCase(
268:                            VIRTUAL_FORM_YES) ? VIRTUAL_FORM_YES
269:                            : VIRTUAL_FORM_NO;
270:                }
271:
272:                public void setParticipateValue(String participateValue) {
273:                    this .participateValue = participateValue.trim()
274:                            .equalsIgnoreCase(VIRTUAL_FORM_YES) ? VIRTUAL_FORM_YES
275:                            : VIRTUAL_FORM_NO;
276:                }
277:
278:                public String toString() {
279:                    return "{" + getComponentID() + "," + getVirtualFormName()
280:                            + "," + getParticipateValue() + ","
281:                            + getSubmitValue() + "}";
282:                }
283:            }
284:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.