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 javax.swing.tree.*;
046: import org.netbeans.jemmy.*;
047: import org.netbeans.modules.visualweb.gravy.*;
048: import org.netbeans.modules.visualweb.gravy.designer.*;
049: import org.netbeans.modules.visualweb.gravy.toolbox.*;
050: import org.netbeans.test.dataprovider.common.*;
051:
052: public class PersonDropDownList extends JSFComponent {
053: public PersonDropDownList() {
054: this ("dropDown1"); // default DropDownList id
055: }
056:
057: public PersonDropDownList(String componentID) {
058: componentName = COMPONENT_DROP_DOWN_LIST_NAME;
059: this .componentID = componentID;
060: dbTableName = DB_TABLE_PERSON;
061: }
062:
063: public String makePersonDropDownList() {
064: String errMsg = null;
065: try {
066: putVisualComponentOnDesigner(25, 25);
067: // now DropDownList component is selected in Navigator
068: String newDropDownID = TestPropertiesHandler
069: .getTestProperty("ID_DropDownList_For_DBTablePerson");
070: changeComponentID(newDropDownID); // component should be selected
071: componentPoint = getComponentPoint(); // component should be selected
072: Utils.doSaveAll();
073: putDBTableOnComponent();
074: callPopupMenuItem(POPUP_MENU_ITEM_AUTO_SUBMIT);
075: Utils.doSaveAll();
076:
077: VirtualFormConfigurator virtFormConfigurator = new VirtualFormConfigurator(
078: "Virtual_Form_Person");
079: virtFormConfigurator.configureVirtualForm();
080: Utils.doSaveAll();
081: } catch (Exception e) {
082: e.printStackTrace(Utils.logStream);
083: errMsg = (e.getMessage() == null ? e.toString() : e
084: .getMessage());
085: }
086: return errMsg;
087: }
088:
089: public String modifyJavaCode() {
090: String errMsg = null;
091: try {
092: insertEventHandlerJavaCode();
093: insertPrerenderJavaCode();
094: } catch (Exception e) {
095: e.printStackTrace(Utils.logStream);
096: errMsg = (e.getMessage() == null ? e.toString() : e
097: .getMessage());
098: }
099: return errMsg;
100: }
101:
102: private void insertEventHandlerJavaCode() {
103: String javaCode = TestPropertiesHandler
104: .getTestProperty("personDD_EventHandler_ProcessValueChange");
105: // change string "/n/" to new_line character "\n"
106: javaCode = javaCode.replace("/n/", "\n");
107:
108: if (Utils.isUsedDBOracle() || Utils.isUsedDBPostgres()) {
109: javaCode = javaCode.replace(dbTableName + ".", ""); // remove DB table name from java code
110: }
111: callPopupMenuItem(POPUP_MENU_ITEM_PROCESS_VALUE_CHANGE);
112:
113: EditorOperator editor = Utils.getJavaEditor();
114: editor.pushDownArrowKey();
115: Util.wait(500);
116: new QueueTool().waitEmpty();
117: editor.insert(javaCode);
118: Util.wait(1000);
119: new QueueTool().waitEmpty();
120:
121: Util.getMainMenu().pushMenuNoBlock(
122: MAIN_MENU_ITEM_SOURCE_FIX_IMPORTS);
123: Util.wait(1000);
124: new QueueTool().waitEmpty();
125:
126: Utils.doSaveAll();
127:
128: String editorText = editor.getText();
129: Utils.logMsg("+++ Source java code: [" + editorText + "]");
130: if (!editorText.contains(javaCode)) {
131: throw new RuntimeException(
132: "Java Editor Code doesn't contain java code: ["
133: + javaCode + "]");
134: }
135: DesignerPaneOperator designPaneOp = new DesignerPaneOperator(
136: RaveWindowOperator.getDefaultRave());
137: designPaneOp.switchToDesignerPane();
138: /*
139: //=====================
140: // workaround:
141: // if getVerification() returns "true", waiter, defined in the method
142: // JTextComponentOperator.waitText(String, int), won't find inserted
143: // javaCodeText
144: javaEditor.txtEditorPane().setVerification(false);
145: //=====================
146: */
147: }
148:
149: private void insertPrerenderJavaCode() {
150: String javaCode = TestPropertiesHandler
151: .getTestProperty("prerenderMethod");
152: // change string "/n/" to new_line character "\n"
153: javaCode = javaCode.replace("/n/", "\n");
154:
155: if (Utils.isUsedDBOracle() || Utils.isUsedDBPostgres()) {
156: javaCode = javaCode.replace(dbTableName + ".", ""); // remove DB table name from java code
157: }
158:
159: DesignerPaneOperator designPaneOp = new DesignerPaneOperator(
160: RaveWindowOperator.getDefaultRave());
161: designPaneOp.switchToJavaSource();
162:
163: EditorOperator editor = Utils.getJavaEditor();
164: editor.setCaretPosition(METHOD_DECLARATION_PRERENDER, true);
165:
166: editor.pushDownArrowKey();
167: Util.wait(500);
168: new QueueTool().waitEmpty();
169: editor.insert(javaCode);
170: Util.wait(500);
171: new QueueTool().waitEmpty();
172:
173: Util.getMainMenu().pushMenuNoBlock(
174: MAIN_MENU_ITEM_SOURCE_FIX_IMPORTS);
175: Util.wait(1000);
176: new QueueTool().waitEmpty();
177:
178: Utils.doSaveAll();
179:
180: String editorText = editor.getText();
181: Utils.logMsg("+++ Source java code: [" + editorText + "]");
182: if (!editorText.contains(javaCode)) {
183: throw new RuntimeException(
184: "Java Editor Code doesn't contain java code: ["
185: + javaCode + "]");
186: }
187: designPaneOp = new DesignerPaneOperator(RaveWindowOperator
188: .getDefaultRave());
189: designPaneOp.switchToDesignerPane();
190: /*
191: //=====================
192: // workaround:
193: // if getVerification() returns "true", waiter, defined in the method
194: // JTextComponentOperator.waitText(String, int), won't find inserted
195: // javaCodeText
196: javaEditor.txtEditorPane().setVerification(false);
197: //=====================
198: */
199: }
200: }
|