Source Code Cross Referenced for ServerNavigatorOperator.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » gravy » dataconnectivity » 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.modules.visualweb.gravy.dataconnectivity 
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:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.visualweb.gravy.dataconnectivity;
043:
044:        import java.awt.Point;
045:        import org.netbeans.jemmy.*;
046:        import org.netbeans.jemmy.operators.*;
047:        import org.netbeans.jellytools.Bundle;
048:        import javax.swing.tree.TreePath;
049:        import java.awt.event.KeyEvent;
050:        import java.io.File;
051:        import java.text.MessageFormat;
052:        import org.netbeans.modules.visualweb.gravy.*;
053:        import junit.framework.*;
054:
055:        /**
056:         * This class implements test functionality for the window "Server Navigator".
057:         */
058:        public class ServerNavigatorOperator extends ServerExplorerOperator {
059:            private static final String pointbaseName = "Bundled Database";
060:            private static final String[] pbParams = new String[] { "",
061:                    pointbaseName };
062:
063:            JTreeOperator tree = null;
064:
065:            /**
066:             * Creates a new instance of this class
067:             * @param parent an object ContainerOperator related to container, which
068:             * includes window "Server Navigator".
069:             */
070:            public ServerNavigatorOperator(ContainerOperator parent) {
071:                super (parent);
072:                getTree();
073:            }
074:
075:            /**
076:             * Creates a new instance of this class
077:             */
078:            public ServerNavigatorOperator() {
079:                this (Util.getMainWindow());
080:            }
081:
082:            /**
083:             * Makes the window "Server Navigator" visible.
084:             * @return an object ServerNavigatorOperator
085:             */
086:            public static ServerNavigatorOperator showNavigatorOperator() {
087:                // Util.getMainMenu().pushMenuNoBlock("Window|"+Bundle.getStringTrimmed("com.sun.rave.servernav.Bundle", "LBL_ServerNavigator"));
088:                Util.getMainMenu().pushMenuNoBlock("Window|Services");
089:                Util.wait(1000);
090:                new QueueTool().waitEmpty();
091:                return (new ServerNavigatorOperator());
092:            }
093:
094:            /**
095:             * Adds database table on Design View via popup menu, related to its tree node.
096:             * @param p_path a path of required tree node as an object TreePath
097:             */
098:            public void addTable(TreePath p_path) {
099:                JPopupMenuOperator popup = new JPopupMenuOperator(getTree()
100:                        .callPopupOnPath(p_path));
101:                popup.pushMenu(getBundleString("Add_to_Form"));
102:            }
103:
104:            /**
105:             * Adds a data source into window "Server Navigator".
106:             * @param p_dsname a name of data source
107:             * @param p_ds an object DataSource with properties of data source
108:             * @return true if data source was added successfully
109:             */
110:            public boolean addDataSource(String p_dsname, DataSource p_ds) {
111:
112:                pushPopup(getBundleString("Databases"),
113:                        getBundleString("New connection..."));
114:
115:                AddDataSourceOperator a_dlg = new AddDataSourceOperator();
116:
117:                JComboBoxOperator a_cbo = a_dlg.cboServerType();
118:                System.out.println("DBType=" + p_ds.getDbType());
119:
120:                // Following line don't work :( Imitating...
121:                System.out.println("DBType now=" + a_cbo.getSelectedItem());
122:                if (p_ds.getDbType() != null && p_ds.getDbType().length() > 0) {
123:                    a_cbo.selectItem(p_ds.getDbType());
124:                }
125:                /*        int ind = -1;
126:                 for (int i = 0; i < a_cbo.getItemCount(); i++) {
127:                 if ((((JdbcDriverInfo) a_cbo.getItemAt(i)).getDisplayName()).equals(p_ds.getDbType())) {
128:                 ind = i;
129:                 }
130:                 }
131:                 a_cbo.selectItem(ind);
132:                 */
133:                Util.wait(1000);
134:                /*
135:                 a_dlg.txtDSName().clearText();
136:                 a_dlg.txtDSName().typeText(p_dsname);
137:                 Util.wait(500);
138:                
139:                 if (a_dlg.txtHostName().isEditable()) {
140:                 a_dlg.txtHostName().clearText();
141:                 a_dlg.txtHostName().typeText(p_ds.getDbHost());
142:                 }
143:                 Util.wait(500);
144:                
145:                 if (a_dlg.txtDBName().isEditable()) {
146:                 a_dlg.txtDBName().clearText();
147:                 a_dlg.txtDBName().typeText(p_ds.getDbName());
148:                 }
149:                 Util.wait(500);
150:                 */
151:                System.out.println("DB URL=" + p_ds.getDbUrl());
152:                if (p_ds.getDbUrl() != null && p_ds.getDbUrl().length() > 0) {
153:                    a_dlg.cboURL().clearText();
154:                    a_dlg.cboURL().typeText(p_ds.getDbUrl());
155:                }
156:                Util.wait(500);
157:
158:                a_dlg.txtUser().clearText();
159:                a_dlg.txtUser().typeText(p_ds.getUser());
160:                Util.wait(500);
161:
162:                a_dlg.txtPassword().clearText();
163:                a_dlg.txtPassword().typeText(p_ds.getPassword());
164:                Util.wait(500);
165:                /*
166:                 if (p_ds.getValidationTable()!=null){
167:                 a_dlg.txtValidationTable().clearText();
168:                 a_dlg.txtValidationTable().typeText(p_ds.getValidationTable());
169:                 }else try {
170:                 //select first table of schema as validation table
171:                 a_dlg.btSelectTable().push();
172:                 JDialogOperator selectDlg=new JDialogOperator();
173:                 new JListOperator(selectDlg).selectItem(0);
174:                 new JButtonOperator(selectDlg,0).push();
175:                 }catch (org.netbeans.jemmy.TimeoutExpiredException e){
176:                 // exception appears if connection isn't successful at all
177:                 }
178:                 Util.wait(1000);
179:                
180:                 //a_dlg.txtURL().clearText();
181:                 //a_dlg.txtURL().typeText(p_ds.getDbUrl());
182:                
183:                 new QueueTool().waitEmpty();
184:                
185:                 // Test connection
186:                
187:                 a_dlg.btTestConnection().push();
188:                 JDialogOperator a_dlg1 = new JDialogOperator(a_dlg);
189:                 Util.wait(1000);
190:                
191:                 boolean success = !(new JTextFieldOperator(a_dlg1).getText().equals("Failed") ||
192:                 new JTextFieldOperator(a_dlg1,1).getText().equals("Failed")
193:                 );
194:                 */
195:                new JButtonOperator(a_dlg, getBundleString("OK")).push();
196:
197:                // Add data source, if connection is OK
198:
199:                Util.wait(10000);
200:                if (p_ds.getDbType().equalsIgnoreCase("mysql")) {
201:                    new JButtonOperator(a_dlg, getBundleString("OK")).push();
202:                }
203:                return true;
204:            }
205:
206:            /**
207:             * Opens connection with a data source.
208:             * @param p_dsname a name of data source
209:             * @param p_ds an object DataSource with properties of data source
210:             */
211:            public void connectToDataSource(String p_dsname, DataSource p_ds) {
212:
213:                String[] a_ss = { getBundleString("Databases"), p_dsname };
214:                pushPopup(a_ss, getBundleString("Connect..."));
215:                Util.wait(1000);
216:
217:                JDialogOperator a_dlg = new JDialogOperator();
218:                Util.wait(1000);
219:
220:                JTextFieldOperator tfUser = new JTextFieldOperator(a_dlg, 0);
221:                tfUser.clearText();
222:                tfUser.typeText(p_ds.getUser());
223:                Util.wait(500);
224:
225:                JTextFieldOperator tfPassword = new JTextFieldOperator(a_dlg, 1);
226:                tfPassword.clearText();
227:                tfPassword.typeText(p_ds.getPassword());
228:                Util.wait(500);
229:
230:                JCheckBoxOperator chkRemember = new JCheckBoxOperator(a_dlg);
231:                chkRemember.setSelected(true);
232:
233:                new JButtonOperator(a_dlg, getBundleString("OK")).pushNoBlock();
234:
235:                // Add data source, if connection is OK
236:
237:                Util.wait(2000);
238:                try {
239:                    new org.netbeans.jellytools.TopComponentOperator("Output")
240:                            .close();
241:                } catch (Exception e) {
242:                    e.printStackTrace();
243:                }
244:                //new JButtonOperator(a_dlg, getBundleString("OK")).pushNoBlock();
245:
246:            }
247:
248:            /**
249:             * Changes parameters of a data source.
250:             * @param p_dsname a name of data source
251:             * @param p_ds an object DataSource with properties of data source
252:             * @return true if data source was modified successfully
253:             */
254:            public boolean modifyDataSource(String p_dsname, DataSource p_ds) {
255:
256:                String[] a_ss = { getBundleString("Databases"), p_dsname };
257:                pushPopup(a_ss, getBundleString("MODIFY_DATASOURCE"));
258:
259:                ModifyDataSourceOperator a_dlg = new ModifyDataSourceOperator();
260:
261:                JTextFieldOperator a_tfo = a_dlg.txtDSName();
262:                a_tfo.clearText();
263:                a_tfo.typeText(p_dsname);
264:                Util.wait(500);
265:
266:                a_tfo = a_dlg.txtUser();
267:                a_tfo.clearText();
268:                a_tfo.typeText(p_ds.getUser());
269:                Util.wait(500);
270:
271:                a_tfo = a_dlg.txtPassword();
272:                a_tfo.clearText();
273:                a_tfo.typeText(p_ds.getPassword());
274:                Util.wait(500);
275:
276:                a_tfo = a_dlg.txtURL();
277:                a_tfo.clearText();
278:                a_tfo.typeText(p_ds.getDbUrl());
279:                Util.wait(2000);
280:
281:                //a_tf=(JTextField)a_dlg.waitSubComponent(new TextFieldChooser(6));
282:                //a_tf.setText(p_ds.getDbUrl());
283:
284:                new QueueTool().waitEmpty();
285:
286:                // Test connection
287:
288:                a_dlg.btTestConnection().push();
289:                JDialogOperator a_dlg1 = new JDialogOperator(a_dlg, 0);
290:
291:                boolean success = a_dlg1.getTitle().equals("Information");
292:                new JButtonOperator(a_dlg1, getBundleString("OK")).push();
293:
294:                // Modify data source, if connection is OK
295:
296:                new JButtonOperator(a_dlg, getBundleString(success ? "MODIFY"
297:                        : "CANCEL")).push();
298:
299:                return success;
300:            }
301:
302:            /**
303:             * Removes a data source.
304:             * @param p_dsname a name of data source
305:             * @return true if data source was removed successfully
306:             */
307:            public boolean removeDataSource(String p_dsname) {
308:
309:                String[] a_ss = { getBundleString("Databases"), p_dsname };
310:
311:                pushPopup(a_ss, getBundleString("REMOVE_CONNECTION"));
312:
313:                Util.wait(1000);
314:
315:                return true;
316:            }
317:
318:            /**
319:             * Adds new type of DB server into Server Navigator.
320:             * @param p_typeName a name of server type
321:             * @param p_template not used
322:             * @param p_iniDrivers drivers, needed for this DB server
323:             */
324:            public void addNewServerType(String p_typeName, String p_template,
325:                    String p_iniDrivers) {
326:                addNewServerType(p_typeName, p_template, p_iniDrivers, "");
327:            }
328:
329:            /**
330:             * Adds new type of DB server into Server Navigator.
331:             * @param p_typeName a name of server type
332:             * @param p_template not used
333:             * @param p_iniDrivers drivers, needed for this DB server
334:             * @param p_addDrivers additional drivers, which should be added
335:             */
336:            public void addNewServerType(String p_typeName, String p_template,
337:                    String p_iniDrivers, String p_addDrivers) {
338:
339:                pushPopup(new String[] { getBundleString("Databases"),
340:                        getBundleString("Drivers") },
341:                        getBundleString("New driver..."));
342:
343:                EditServerTypesOperator a_dlg = new EditServerTypesOperator();
344:                Util.wait(1000);
345:
346:                a_dlg.btNew().pushNoBlock();
347:                JDialogOperator a_dlg1 = new JDialogOperator(
348:                        getBundleString("Select Driver"));
349:
350:                if (System.getProperty("os.name").equals("Mac OS X")) {
351:                    String[] splittedPath = p_iniDrivers.substring(1,
352:                            p_iniDrivers.length()).split(File.separator);
353:                    TestUtils.wait(1000);
354:                    JComboBoxOperator cbRoot = new JComboBoxOperator(a_dlg1);
355:                    for (int i = 0; i < cbRoot.getItemCount(); i++)
356:                        if (cbRoot.getItemAt(i).toString().equals(
357:                                File.separator)) {
358:                            cbRoot.setSelectedIndex(i);
359:                            break;
360:                        }
361:                    String toCompare = "";
362:                    for (int i = 0; i < splittedPath.length; i++) {
363:                        JTableOperator jtoPath = new JTableOperator(a_dlg1);
364:                        toCompare += "/" + splittedPath[i];
365:                        System.out.println("toComapre=" + toCompare);
366:                        Point cell = jtoPath
367:                                .findCell(toCompare,
368:                                        new Operator.DefaultStringComparator(
369:                                                true, true), 0);
370:                        TestUtils.wait(1000);
371:                        jtoPath.clickOnCell((int) cell.getY(), (int) cell
372:                                .getX(), 2);
373:                        TestUtils.wait(1000);
374:                    }
375:                } else {
376:
377:                    JTextFieldOperator a_tf1 = new JTextFieldOperator(a_dlg1);
378:                    a_tf1.typeText(p_iniDrivers);
379:                    Util.wait(500);
380:                    new JButtonOperator(a_dlg1, "Open").push();
381:                    Util.wait(1000);
382:                }
383:                /*Case when more then one file commented
384:                 if (!(p_addDrivers == null) && !(p_addDrivers.equals(""))) {
385:                
386:                 new JButtonOperator(a_dlg, getBundleString("Add...")).pushNoBlock();
387:                 a_dlg1 = new JDialogOperator(getBundleString("Select driver"));
388:                
389:                 a_tf1 = new JTextFieldOperator(a_dlg1);
390:                 a_tf1.typeText(p_addDrivers);
391:                
392:                 new JButtonOperator(a_dlg1, "Open").push();
393:                 Util.wait(1000);
394:                 }
395:                
396:                 a_tf1 = a_dlg.txtName();
397:                 a_tf1.clearText();
398:                 a_tf1.typeText(p_typeName);
399:                 Util.wait(1000);
400:                 */
401:                /*
402:                 a_tf1 = a_dlg.txtTemplate();
403:                 a_tf1.clearText();
404:                 a_tf1.typeText(p_template);
405:                 Util.wait(1000);
406:                
407:                
408:                 // try to close window without choosing driver class. Error message should appear
409:                 a_dlg.btOK().push();
410:                 a_dlg1 = new JDialogOperator("Information");
411:                 Util.wait(1000);
412:                 new JButtonOperator(a_dlg1, getBundleString("OK")).push();
413:                 */
414:                // choose driver class and close window
415:                //a_dlg.btFind().push();
416:                //a_dlg.cboDriver().setSelectedIndex(0);
417:                Util.wait(1000);
418:                a_dlg.btOK().push();
419:
420:            }
421:
422:            /**
423:             * Deletes a type of DB server from Server Navigator.
424:             * @param p_typeName a name of server type
425:             */
426:            public void deleteServerType(String p_typeName) {
427:
428:                pushPopup(getBundleString("Databases"),
429:                        getBundleString("CONFIGURE_JDBC_DRIVER"));
430:
431:                EditServerTypesOperator a_dlg = new EditServerTypesOperator();
432:                Util.wait(1000);
433:
434:                a_dlg.lstServerTypes().setSelectedValue(p_typeName, true);
435:                a_dlg.btRemove().pushNoBlock();
436:
437:                //        JDialogOperator a_dlg1=new JDialogOperator("Question");
438:                //        a_dlg1.pressKey(KeyEvent.VK_ENTER);
439:
440:                Util.wait(1000);
441:
442:                a_dlg.closeByButton();
443:            }
444:
445:            /**
446:             * Opens a window "View Data" for some database table/view.
447:             * @param p_path a path of required tree node
448:             */
449:            public void viewData(String p_path) {
450:                pushPopup(p_path, getBundleString("VIEW_DATA"));
451:            }
452:
453:            /**
454:             * Opens a window "View Data" for some database table/view.
455:             * @param p_path a string array with path of required tree node
456:             * (sequence of node names from the root node to a required node)
457:             */
458:            public void viewData(String[] p_path) {
459:                pushPopup(p_path, getBundleString("VIEW_DATA"));
460:            }
461:
462:            //    public void viewData(TreePath p_path) {
463:            //
464:            //        JPopupMenuOperator popup = new JPopupMenuOperator(tree.callPopupOnPath(p_path));
465:            //        popup.pushMenu(getBundleString("VIEW_DATA"));
466:            //    }
467:
468:            /**
469:             * Closes an opened window "View Data".
470:             */
471:            public void closeDataView() {
472:                Util.closeWindow();
473:            }
474:
475:            /**
476:             * Opens a window "View Data" for a schema of some database table/view.
477:             * @param p_ds a name of required data source
478:             * @param p_schema not used
479:             */
480:            public void showSchema(String p_ds, String[] p_schema) {
481:                pushPopup(getBundleString("Databases") + "/" + p_ds,
482:                        getBundleString("VIEW_DATA"));
483:            }
484:
485:            /**
486:             * Finds in a bundle file and returns an actual text of control component.
487:             * @param p_text string-key corresponding to required control component.
488:             * @return actual text of control component
489:             */
490:            public static String getBundleString(String p_text) {
491:                System.out.println("Getting bundle for " + p_text);
492:                /*        try {
493:                 return Bundle.getStringTrimmed("org.netbeans.modules.visualweb.dataconnectivity.actions.Bundle", p_text);
494:                 } catch (JemmyException e) {}
495:                 try {
496:                 return Bundle.getStringTrimmed("org.netbeans.modules.visualweb.dataconnectivity.ui.Bundle", p_text);
497:                 } catch (JemmyException e) {}
498:                 return null;
499:                 */
500:
501:                // stub
502:                return p_text;
503:            }
504:
505:            /**
506:             * Checks, whether built-in database server PointBase is running or not.
507:             * @return true - DB server ir running, false - otherwise
508:             */
509:            public static boolean isPBRunning() {
510:                boolean result = true;
511:                JPopupMenuOperator pointbasePopupMenu = getTreeNodePopupMenu(Bundle
512:                        .getStringTrimmed(
513:                                "org.netbeans.modules.visualweb.dataconnectivity.explorer.ideDb.Bundle",
514:                                "Bundled_DB_ServerNav_NodeName", pbParams));
515:                if (pointbasePopupMenu != null) {
516:                    result = !(TestUtils
517:                            .findPopupMenuItemByLabel(
518:                                    pointbasePopupMenu,
519:                                    Bundle
520:                                            .getStringTrimmed(
521:                                                    "org.netbeans.modules.visualweb.dataconnectivity.explorer.ideDb.Bundle",
522:                                                    "Bundled_DB_Start",
523:                                                    pbParams)).isEnabled());
524:                } else {
525:                    Assert.fail("Popup menu for bundled server not found");
526:                }
527:                pointbasePopupMenu.pressKey(KeyEvent.VK_ESCAPE);
528:                new QueueTool().waitEmpty();
529:                Util.wait(500);
530:                return result;
531:            }
532:
533:            /**
534:             * Shuts a built-in database server PointBase down.
535:             */
536:            public static void stopPB() {
537:                JPopupMenuOperator pointbasePopupMenu = getTreeNodePopupMenu(Bundle
538:                        .getStringTrimmed(
539:                                "org.netbeans.modules.visualweb.dataconnectivity.explorer.ideDb.Bundle",
540:                                "Bundled_DB_ServerNav_NodeName", pbParams));
541:                if (pointbasePopupMenu != null) {
542:                    pointbasePopupMenu
543:                            .pushMenuNoBlock(Bundle
544:                                    .getStringTrimmed(
545:                                            "org.netbeans.modules.visualweb.dataconnectivity.explorer.ideDb.Bundle",
546:                                            "Bundled_DB_Stop", pbParams));
547:                    new QueueTool().waitEmpty();
548:                    Util.wait(2000);
549:                    System.out
550:                            .println("Pointbase Database Server has been stopped.");
551:                }
552:                new QueueTool().waitEmpty();
553:                Util.wait(1000);
554:            }
555:
556:            /**
557:             * Launches a built-in database server PointBase.
558:             */
559:            public static void startPB() {
560:                JPopupMenuOperator pointbasePopupMenu = getTreeNodePopupMenu(Bundle
561:                        .getStringTrimmed(
562:                                "org.netbeans.modules.visualweb.dataconnectivity.explorer.ideDb.Bundle",
563:                                "Bundled_DB_ServerNav_NodeName", pbParams));
564:                if (pointbasePopupMenu != null) {
565:                    pointbasePopupMenu
566:                            .pushMenuNoBlock(Bundle
567:                                    .getStringTrimmed(
568:                                            "org.netbeans.modules.visualweb.dataconnectivity.explorer.ideDb.Bundle",
569:                                            "Bundled_DB_Start", pbParams));
570:                    new QueueTool().waitEmpty();
571:                    Util.wait(2000);
572:                    System.out
573:                            .println("Pointbase Database Server has started.");
574:                }
575:                new QueueTool().waitEmpty();
576:                Util.wait(1000);
577:            }
578:
579:            private static JTreeOperator selectTreeNode(String nodeName) {
580:                try {
581:                    // select the Server Navigator and set the JTreeOperator
582:                    QueueTool queueTool = new QueueTool();
583:                    queueTool.waitEmpty(100);
584:                    ServerNavigatorOperator serverExplorer = showNavigatorOperator();
585:                    serverExplorer.makeComponentVisible();
586:
587:                    JTreeOperator tree = serverExplorer.getTree();
588:
589:                    // Increase timeout for tree to redisplay after refresh
590:                    tree.getTimeouts().setTimeout(
591:                            "JTreeOperator.WaitNodeExpandedTimeout", 60000);
592:                    tree.getTimeouts().setTimeout(
593:                            "JTreeOperator.WaitNextNodeTimeout", 60000);
594:                    tree.getTimeouts().setTimeout(
595:                            "JTreeOperator.WaitNodeVisibleTimeout", 60000);
596:
597:                    TreePath serverNode = tree.findPath(nodeName);
598:                    serverExplorer.getTree().selectPath(serverNode);
599:                    queueTool.waitEmpty(100);
600:
601:                    return tree;
602:                } catch (Exception e) {
603:                    e.printStackTrace();
604:                    return null;
605:                }
606:            }
607:
608:            private static JPopupMenuOperator getTreeNodePopupMenu(
609:                    String nodeName) {
610:                try {
611:                    QueueTool queueTool = new QueueTool();
612:                    JTreeOperator tree = selectTreeNode(nodeName);
613:
614:                    TreePath serverNode = tree.findPath(nodeName);
615:                    queueTool.waitEmpty(100);
616:
617:                    JPopupMenuOperator popupMenu = new JPopupMenuOperator(tree
618:                            .callPopupOnPath(serverNode));
619:                    queueTool.waitEmpty(100);
620:                    Util.wait(100);
621:
622:                    return popupMenu;
623:                } catch (Exception e) {
624:                    e.printStackTrace();
625:                    return null;
626:                }
627:            }
628:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.