Source Code Cross Referenced for QueryBuilderOperator.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 org.netbeans.modules.visualweb.gravy.Util;
045:        import org.netbeans.modules.db.sql.visualeditor.querybuilder.*;
046:        import java.awt.*;
047:        import java.util.*;
048:        import javax.swing.*;
049:        import java.awt.event.*;
050:        import org.netbeans.jemmy.*;
051:        import org.netbeans.jemmy.operators.*;
052:        import org.netbeans.jellytools.Bundle;
053:
054:        /**
055:         * This class implements test functionality for a window "QueryBuilder".
056:         */
057:        public class QueryBuilderOperator extends ContainerOperator {
058:            ComponentOperator desktop = null;
059:            JTextComponentOperator query = null;
060:            public static final String SORT_TYPE = "Sort Type";
061:            public static final String SORT_ORDER = "Sort Order";
062:            public static final String DESCENDING = "Descending";
063:            public static final String ASCENDING = "Ascending";
064:
065:            static final String ADD_QUERY_CRITERIA = "Add Query Criteria";
066:            public static final String CRITERIA = "Criteria";
067:            private static final String COLUMN = "Column";
068:            static final String POPUP_MENU_ITEM_PARSE_QUERY = "Parse Query";
069:            static final String POPUP_MENU_ITEM_RUN_QUERY = "Run Query";
070:            public static final String POPUP_MENU_ITEM_ADD_TABLE = "Add Table"; // "Add Table...";
071:            public static final String DIALOG_TITLE_ADD_TABLE = "Select Table"; // "Select Table(s) to Add";
072:            public final static String CANCEL = "Cancel";
073:            public final static String GROUP_BY = "Group By";
074:            public static final String POPUP_MENU_ITEM_REMOVE_FROM_QUERY = "Remove from Query";
075:            public final static String EQUALS = "Equals";
076:            public final static String NOT_EQUALS = "Not Equals";
077:            public final static String LESS_THAN = "Less Than";
078:            public final static String LESS_THAN_EQUALS = "Less Than Equals";
079:            public final static String GREATER_THAN = "Greater Than";
080:            public final static String GREATER_THAN_EQUALS = "Greater Than Equals";
081:
082:            /**
083:             * @param tableName looking for given table to choose correct QueryBuilder instance
084:             * @return Container instanceof QueryBuilder
085:             */
086:            private static Container findQueryBuilder(String tableName) {
087:                java.awt.Container container = new org.netbeans.jemmy.operators.JTableOperator(
088:                        Util.getMainWindow(),
089:                        new QueryBuilderInputTableChooser(tableName))
090:                        .getParent();
091:                while (!(container instanceof  QueryBuilder)) {
092:                    //System.out.println("TRACE: findQueryBuilder: " + container.getClass().getName());
093:                    container = container.getParent();
094:                }
095:                return container;
096:            }
097:
098:            /**
099:             * Creates new instance of this class.
100:             * @param parent an object ContainerOperator related to container, which includes created Query Builder
101:             * @param tabId a name of required tab
102:             */
103:            public QueryBuilderOperator(ContainerOperator parent, String tabId) {
104:                //super(parent, new QueryBuilderChooser(tabId));
105:                super (findQueryBuilder(tabId));
106:                this .setComparator(new Operator.DefaultStringComparator(true,
107:                        true));
108:            }
109:
110:            /**
111:             * Creates new instance of this class.
112:             * @param tabId a name of required tab
113:             */
114:            public QueryBuilderOperator(String tabId) {
115:                this (Util.getMainWindow(), tabId);
116:            }
117:
118:            /**
119:             * Creates new instance of this class.
120:             * @param parent an object ContainerOperator related to container, which includes created Query Builder
121:             */
122:            public QueryBuilderOperator(ContainerOperator parent) {
123:                super (parent, new QueryBuilderChooser());
124:                this .setComparator(new Operator.DefaultStringComparator(true,
125:                        true));
126:            }
127:
128:            /**
129:             * Creates new instance of this class.
130:             */
131:            public QueryBuilderOperator() {
132:                this (Util.getMainWindow());
133:            }
134:
135:            /**
136:             * Closes a window of Query Builder.
137:             */
138:            public void close() {
139:                Util.closeWindow();
140:            }
141:
142:            /**
143:             * TODO: Fix it
144:             * Returns an object QueryBuilderGraphFrameOperator
145:             * @return QueryBuilderGraphFrameOperator
146:             */
147:            public QueryBuilderPaneOperator getGraphFrame() {
148:                return (new QueryBuilderPaneOperator());
149:            }
150:
151:            /**
152:             * Returns an object TableFrameOperator
153:             * Represent Operator for Table with given name in Graph Frame of the QueryBuilder
154:             * @param tableName
155:             * @return TableFrameOperator
156:             * 
157:             */
158:            public TableFrameOperator getTableFrame(String tableName) {
159:                return (new TableFrameOperator(tableName));
160:            }
161:
162:            /**
163:             * Returns an object InputTableOperator
164:             * @return InputTableOperator
165:             */
166:            public InputTableOperator getInputTable() {
167:                return (new InputTableOperator());
168:            }
169:
170:            /**
171:             * TODO: Fix it
172:             */
173:            private ComponentOperator getDesktop() {
174:                if (desktop == null) {
175:                    //desktop = new ComponentOperator(new QueryBuilderOperator().getGraphFrame(),
176:                    //        new Operator.Finder(JDesktopPane.class));
177:                    desktop = new QueryBuilderOperator().getGraphFrame();
178:                }
179:                return (desktop);
180:            }
181:
182:            /**
183:             * Initializes (if necessary) and returns an object JTextComponentOperator (query text).
184:             * @return JTextComponentOperator
185:             */
186:            public JTextComponentOperator getQueryTextComponent() {
187:                if (query == null) {
188:                    //query = new JTextComponentOperator(this);
189:                    query = new JEditorPaneOperator(this );
190:                }
191:                return (query);
192:            }
193:
194:            /**
195:             * Returns an object JTableOperator (result table of a query)
196:             * @return JTableOperator
197:             */
198:            public JTableOperator getResultTable() {
199:                return (new JTableOperator(this , new Operator.Finder(
200:                        QueryBuilderResultTable.class)));
201:            }
202:
203:            /**
204:             * Clicks an item of a popup menu.
205:             * @param menuText a menu item
206:             */
207:            public void pushPopup(String menuText) {
208:                getDesktop().clickForPopup(10, 10);
209:                new JPopupMenuOperator().pushMenuNoBlock(menuText);
210:            }
211:
212:            /**
213:             * Returns JComponentOperator, which wraps component, presenting
214:             * Graph Panel of Query Editor
215:             */
216:            public JComponentOperator getGraphComponent() {
217:                JComponent jComponent = (JComponent) findComponent(
218:                        (Container) this .getSource(), new ComponentChooser() {
219:                            public boolean checkComponent(Component comp) {
220:                                return (comp.getClass().getName().endsWith(
221:                                        "SceneComponent") ? true : false);
222:                            }
223:
224:                            public String getDescription() {
225:                                return ("Graph component [SceneComponent] is being found...");
226:                            }
227:                        });
228:                return (new JComponentOperator(jComponent));
229:            }
230:
231:            /**
232:             * Returns JScrollPaneOperator, which wraps a scroll pane
233:             * of Graph Panel of Query Editor
234:             */
235:            public JScrollPaneOperator getGraphScrollPane() {
236:                Component component = getGraphComponent().getSource();
237:                do {
238:                    component = component.getParent();
239:                } while (!(component instanceof  JScrollPane));
240:                return (new JScrollPaneOperator((JScrollPane) component));
241:            }
242:
243:            //========================================================================//
244:            /**
245:             * Class for component, presenting DB Table on Graph Panel of Query Editor
246:             */
247:            private static class DBTableGraphComponent {
248:                private QueryBuilderOperator queryBuilder;
249:                private Container dbTableGraphObject;
250:                private JTable structureTable;
251:
252:                private DBTableGraphComponent(
253:                        QueryBuilderOperator queryBuilder,
254:                        Container dbTableGraphObject) {
255:                    this .queryBuilder = queryBuilder;
256:                    this .dbTableGraphObject = dbTableGraphObject;
257:                    structureTable = (JTable) ComponentOperator.findComponent(
258:                            dbTableGraphObject, new ComponentChooser() {
259:                                public boolean checkComponent(Component comp) {
260:                                    return (comp instanceof  JTable ? true
261:                                            : false);
262:                                }
263:
264:                                public String getDescription() {
265:                                    return "DB table component on Query Editor Graph Panel";
266:                                }
267:                            });
268:                }
269:
270:                private String getDBTableName() {
271:                    QueryBuilderTableModel tableModel = (QueryBuilderTableModel) structureTable
272:                            .getModel();
273:                    return tableModel.getTableName();
274:                }
275:
276:                public JTable getStructureTable() {
277:                    return structureTable;
278:                }
279:
280:                private void callPopupMenu(String popupMenuItem) {
281:                    new ComponentOperator(dbTableGraphObject)
282:                            .makeComponentVisible();
283:                    Util.wait(1000);
284:                    new QueueTool().waitEmpty();
285:
286:                    JComponentOperator graphComponentOp = queryBuilder
287:                            .getGraphComponent();
288:                    Point pointGraphComponent = graphComponentOp
289:                            .getLocationOnScreen(), pointDBTableObj = dbTableGraphObject
290:                            .getLocationOnScreen();
291:                    int dx = pointDBTableObj.x - pointGraphComponent.x + 3, dy = pointDBTableObj.y
292:                            - pointGraphComponent.y - 3;
293:
294:                    graphComponentOp.clickForPopup(dx, dy);
295:                    Util.wait(1000);
296:                    new QueueTool().waitEmpty();
297:
298:                    new JPopupMenuOperator().pushMenuNoBlock(popupMenuItem);
299:                    Util.wait(1000);
300:                    new QueueTool().waitEmpty();
301:                }
302:
303:                @Override
304:                public String toString() {
305:                    return getDBTableName();
306:                }
307:
308:                @Override
309:                public boolean equals(Object obj) {
310:                    if (obj == null)
311:                        return false;
312:                    if (obj instanceof  String)
313:                        return (getDBTableName().equals(obj.toString()));
314:
315:                    if (getClass() != obj.getClass())
316:                        return false;
317:
318:                    DBTableGraphComponent other = (DBTableGraphComponent) obj;
319:                    return (getDBTableName().equals(other.getDBTableName()));
320:                }
321:
322:                @Override
323:                public int hashCode() {
324:                    return getDBTableName().hashCode();
325:                }
326:
327:                private static java.util.List<DBTableGraphComponent> getDBTableGraphComponentList(
328:                        QueryBuilderOperator queryBuilder) {
329:                    java.util.List<DBTableGraphComponent> componentList = new ArrayList<DBTableGraphComponent>();
330:                    Container container = (Container) queryBuilder
331:                            .getGraphComponent().getSource();
332:                    Component[] components = container.getComponents();
333:                    for (Component component : components) {
334:                        if (component.getClass().getName().endsWith(
335:                                "QBNodeComponent")) {
336:                            componentList.add(new DBTableGraphComponent(
337:                                    queryBuilder, (Container) component));
338:                        }
339:                    }
340:                    return componentList;
341:                }
342:
343:                private static DBTableGraphComponent findDBTable(
344:                        QueryBuilderOperator queryBuilder, String dbTableName) {
345:                    return findDBTable(
346:                            getDBTableGraphComponentList(queryBuilder),
347:                            dbTableName);
348:                }
349:
350:                private static DBTableGraphComponent findDBTable(
351:                        java.util.List<DBTableGraphComponent> dbTableList,
352:                        String dbTableName) {
353:                    for (DBTableGraphComponent dbTable : dbTableList) {
354:                        if (dbTable.equals(dbTableName))
355:                            return dbTable;
356:                    }
357:                    return null;
358:                }
359:            }
360:
361:            //========================================================================//
362:
363:            public JTableOperator getStructureTableOfDBTableOnGraphPanel(
364:                    String dbTableName) {
365:                DBTableGraphComponent graphComponent = DBTableGraphComponent
366:                        .findDBTable(this , dbTableName);
367:                if (graphComponent == null)
368:                    return null;
369:                return (new JTableOperator(graphComponent.getStructureTable()));
370:            }
371:
372:            public boolean isDBTableOpenedOnGraphPanel(String dbTableName) {
373:                return (DBTableGraphComponent.findDBTable(this , dbTableName) != null);
374:            }
375:
376:            /**
377:             * Adds a database table into a query.
378:             * @param dbTableName name of a database table
379:             */
380:            public void addTable(String dbTableName) {
381:                DBTableGraphComponent dbTable = DBTableGraphComponent
382:                        .findDBTable(this , dbTableName);
383:                if (dbTable != null)
384:                    return; // DB table is already opened in Graph Pane of Query Editor
385:
386:                JComponentOperator jCompOp = getGraphComponent();
387:                Util.wait(1000);
388:                new QueueTool().waitEmpty();
389:
390:                //pushPopup(getBundleString("Add_Table"));
391:                jCompOp.clickForPopup(2, 2);
392:                Util.wait(1000);
393:                new QueueTool().waitEmpty();
394:
395:                new JPopupMenuOperator()
396:                        .pushMenuNoBlock(POPUP_MENU_ITEM_ADD_TABLE);
397:                Util.wait(1000);
398:                new QueueTool().waitEmpty();
399:
400:                //JDialogOperator addTableDialog = new JDialogOperator(getBundleString("Add_Table_Title"));
401:                JDialogOperator addTableDialog = new JDialogOperator(
402:                        DIALOG_TITLE_ADD_TABLE);
403:                Util.wait(1000);
404:                new QueueTool().waitEmpty();
405:
406:                new JListOperator(addTableDialog).selectItem(dbTableName);
407:                Util.wait(1000);
408:                new QueueTool().waitEmpty();
409:
410:                new JButtonOperator(addTableDialog, "OK").pushNoBlock();
411:                Util.wait(1000);
412:                new QueueTool().waitEmpty();
413:            }
414:
415:            /**
416:             * Removes a database table from a query.
417:             * @param dbTableName name of a database table
418:             */
419:            public void removeTable(String dbTableName) {
420:                DBTableGraphComponent dbTable = DBTableGraphComponent
421:                        .findDBTable(this , dbTableName);
422:                dbTable.callPopupMenu(POPUP_MENU_ITEM_REMOVE_FROM_QUERY);
423:                Util.wait(1000);
424:                new QueueTool().waitEmpty();
425:            }
426:
427:            /**
428:             * Updates text of a query.
429:             * @param newQuery text of query
430:             */
431:            public void retypeQuery(String newQuery) {
432:                //        this.getQueryTextComponent().clearText();
433:                //        Util.wait(500);
434:                //        this.getQueryTextComponent().typeText(newQuery);
435:                this .getQueryTextComponent().setText(newQuery);
436:                Util.wait(1500);
437:                new QueueTool().waitEmpty();
438:            }
439:
440:            /**
441:             * Changes text of a query.
442:             * @param substring a part of query text, which should be changed
443:             * @param newSubstring new text, which will replace a part of query text
444:             */
445:            public void changeQuery(String substring, String newSubstring) {
446:                getQueryTextComponent().selectText(substring);
447:                getQueryTextComponent().replaceSelection(newSubstring);
448:            }
449:
450:            /**
451:             * Performs a query.
452:             * @return object JTableOperator
453:             */
454:            public JTableOperator runQuery() {
455:                getQueryTextComponent().clickForPopup(2, 2);
456:                Util.wait(1000);
457:                new QueueTool().waitEmpty();
458:
459:                new JPopupMenuOperator()
460:                        .pushMenuNoBlock(POPUP_MENU_ITEM_RUN_QUERY);
461:                Util.wait(1000);
462:                new QueueTool().waitEmpty();
463:                return (getResultTable());
464:            }
465:
466:            /**
467:             * Parses a query.
468:             */
469:            public void parseQuery() {
470:                getQueryTextComponent().clickForPopup(2, 2);
471:                Util.wait(1000);
472:                new QueueTool().waitEmpty();
473:
474:                new JPopupMenuOperator()
475:                        .pushMenuNoBlock(POPUP_MENU_ITEM_PARSE_QUERY);
476:                Util.wait(1000);
477:                new QueueTool().waitEmpty();
478:            }
479:
480:            /**
481:             * Invokes a dialog "Add query criteria".
482:             * @param column a name of a required column
483:             * @return an object AddQueryCriteriaOperator
484:             */
485:            public AddQueryCriteriaOperator invokeAddCriteria(String column) {
486:                return invokeAddCriteria(getInputTable().findCellRow(column));
487:            }
488:
489:            /**
490:             * Invokes a dialog "Add query criteria".
491:             * @param column a number of a required column
492:             * @return an object AddQueryCriteriaOperator
493:             */
494:            public AddQueryCriteriaOperator invokeAddCriteria(int column) {
495:                JTableOperator inputTable = getInputTable();
496:                //Point p = inputTable.getPointToClick(column, inputTable.findColumn(getBundleString("CRITERIA")));
497:                //Point p = inputTable.getPointToClick(column, inputTable.findColumn(CRITERIA));
498:                Point p = inputTable.getPointToClick(column, inputTable
499:                        .findColumn(COLUMN));
500:                Util.wait(500);
501:                new QueueTool().waitEmpty();
502:
503:                inputTable.clickForPopup(p.x, p.y);
504:                JPopupMenuOperator popup = new JPopupMenuOperator();
505:                Util.wait(500);
506:                new QueueTool().waitEmpty();
507:
508:                //popup.pushMenuNoBlock(getBundleString("ADD_QUERY_CRITERIA"));
509:                popup.pushMenuNoBlock(ADD_QUERY_CRITERIA);
510:                Util.wait(500);
511:                new QueueTool().waitEmpty();
512:
513:                return new AddQueryCriteriaOperator();
514:            }
515:
516:            /**
517:             * Adds query criteria to a column of a database table.
518:             * @param column a name of a required column
519:             * @param value text of criteria value
520:             * @param operatorValue string with a comparison operator or a statement,
521:             * which is used in criteria (for example, "=")
522:             */
523:            public void addSimpleCriteria(String column, String value,
524:                    String operatorValue) {
525:                // invoke add query criteria dialog
526:                AddQueryCriteriaOperator dialog = invokeAddCriteria(column);
527:
528:                if (operatorValue != null)
529:                    dialog.cboCompareType().selectItem(operatorValue);
530:
531:                dialog.txtValue().setText(value);
532:                Util.wait(1000);
533:                new QueueTool().waitEmpty();
534:
535:                dialog.btOK().pushNoBlock();
536:                Util.wait(1000);
537:                new QueueTool().waitEmpty();
538:            }
539:
540:            /**
541:             * Adds a new parameter to a query criteria.
542:             * @param column a name of a required column
543:             */
544:            public void addParamCriteria(String column) {
545:                AddQueryCriteriaOperator dialog = invokeAddCriteria(column);
546:
547:                dialog.rbtParameter().setSelected(true);
548:                Util.wait(1000);
549:                new QueueTool().waitEmpty();
550:
551:                dialog.btOK().pushNoBlock();
552:                Util.wait(1500);
553:                new QueueTool().waitEmpty();
554:            }
555:
556:            /**
557:             * Adds a new parameter to a query criteria.
558:             * @param column a number of a required column
559:             */
560:            public void addParamCriteria(int column) {
561:                AddQueryCriteriaOperator dialog = invokeAddCriteria(column);
562:
563:                dialog.rbtParameter().setSelected(true);
564:                Util.wait(1000);
565:                new QueueTool().waitEmpty();
566:
567:                dialog.btOK().pushNoBlock();
568:                Util.wait(1500);
569:                new QueueTool().waitEmpty();
570:            }
571:
572:            /**
573:             * Selects "graphical join" of database tables (an arrow between 2 tables)
574:             * on graphical diagram.
575:             * @param table1 the 1st database table
576:             * @param table2 the 2nd database table
577:             * @deprecated Uses old graph library
578:             */
579:            public void selectJoin(String table1, String table2) {
580:                QueryBuilderGraphFrame gframe = (QueryBuilderGraphFrame) getGraphFrame()
581:                        .getSource();
582:
583:                QueryBuilderInternalFrame fr1 = (QueryBuilderInternalFrame) getTableFrame(
584:                        table1).getSource();
585:                QueryBuilderInternalFrame fr2 = (QueryBuilderInternalFrame) getTableFrame(
586:                        table2).getSource();
587:                /* TODO: jgraph remnoed
588:                 DefaultGraphCell cell1 = fr1.getGraphCell();
589:                 DefaultGraphCell cell2 = fr2.getGraphCell();
590:                
591:                 for(int i=0;i<gframe.getGraph().getModel().getRootCount();i++) {
592:                 Object o = gframe.getGraph().getModel().getRootAt(i);
593:                
594:                 if(gframe.getGraph().getModel().isEdge(o)) {
595:                
596:                 DefaultEdge e = (DefaultEdge) o;
597:                
598:                 DefaultPort sourcePort = (DefaultPort)e.getSource();
599:                 DefaultPort targetPort = (DefaultPort)e.getTarget();
600:                
601:                 DefaultGraphCell sourceCell = (DefaultGraphCell) sourcePort.getParent();
602:                 DefaultGraphCell targetCell = (DefaultGraphCell) targetPort.getParent();
603:                
604:                 if(sourceCell == cell2 && targetCell == cell1 ||
605:                 sourceCell == cell1 && targetCell == cell2) {
606:                 Rectangle rect = gframe.getGraph().getCellBounds(o);
607:                 ComponentOperator desktop = ComponentOperator.createOperator(gframe.getGraph());
608:                 desktop.clickMouse((int) rect.getCenterX(), (int) rect.getCenterY(), 1);
609:                 Util.wait(2000);
610:                 break;
611:                 }
612:                 }
613:                
614:                 }
615:                 */
616:            }
617:
618:            /**
619:             * Find Container consist Table with given tableName
620:             */
621:            private Container findTableFrame(String tableName) {
622:                java.awt.Container container = new JTableOperator(this ,
623:                        new QueryBuilderTableChooser(tableName)).getParent();
624:                while (!(container instanceof  QBNodeComponent)) {
625:                    container = container.getParent();
626:                    System.out.println("TRACE: findTableFrame: "
627:                            + container.getClass().getName());
628:                }
629:                return container;
630:            }
631:
632:            /**
633:             * This internal class handles a frame with a "graphical table"
634:             * on graphical diagram.
635:             */
636:            public class TableFrameOperator extends
637:                    /*JComponentOperator*/ContainerOperator {
638:                JTableOperator table = null;
639:                String tableName;
640:
641:                /**
642:                 * Creates new instance of this class.
643:                 * @param tableName a name of database table
644:                 */
645:                public TableFrameOperator(String tableName) {
646:                    super (findTableFrame(tableName));
647:                    //super(QueryBuilderOperator.this, new TableFrameChooser(tableName));
648:                    this .tableName = tableName;
649:                    //super(QueryBuilderOperator.this, tableName);
650:                }
651:
652:                /*
653:                public TableFrameOperator(ContainerOperator cont) {
654:                    super(cont, new TableFrameChooser());
655:                }
656:                 */
657:
658:                public String getTitle() {
659:                    return tableName;
660:                }
661:
662:                public ContainerOperator getTitleOperator() {
663:                    Container cont = this .getTable().getParent();
664:                    cont = cont.getParent();
665:                    //cont = cont.getParent();
666:                    return new ContainerOperator(cont);
667:                }
668:
669:                /**
670:                 * Returns an object JTableOperator, related to a database table,
671:                 * included into graphical frame.
672:                 * @return an object JTableOperator
673:                 */
674:                public JTableOperator getTable() {
675:                    if (table == null) {
676:                        table = new JTableOperator(this ,
677:                                new QueryBuilderTableChooser());
678:                        this .getQueueTool().waitEmpty(100);
679:                    }
680:                    return (table);
681:                }
682:
683:                /**
684:                 * Reversible selection changing of a single field of "graphical table".
685:                 * @param fieldName a name of table field
686:                 */
687:                public void changeFieldSelection(String fieldName) {
688:                    System.out.println(fieldName);
689:                    System.out.println(getTable().findCell(fieldName, 0));
690:                    int row = getTable().findCell(fieldName, 0).y;
691:                    if (row == -1) {
692:                        throw (new JemmyException("Can not find \"" + fieldName
693:                                + "\" in \"\" table"));
694:                    }
695:                    getTable().clickOnCell(row, 0);
696:                }
697:
698:                /**
699:                 *   Chooser for Table in Graph View Frame
700:                 *
701:                 */
702:                public class QueryBuilderTableChooser implements 
703:                        ComponentChooser {
704:
705:                    public boolean checkComponent(Component comp) {
706:                        boolean res = comp instanceof  QueryBuilderTable;
707:                        if (res) {
708:                            String firstValue = ((QueryBuilderTable) comp)
709:                                    .getValueAt(0, 2).toString();
710:                            String secondValue = ((QueryBuilderTable) comp)
711:                                    .getValueAt(1, 2).toString();
712:                            //System.out.println("TRACE: QueryBuilderTableChooser: firstValue = "+
713:                            //        ((QueryBuilderTable)comp).getValueAt(0, 2));
714:                            //System.out.println("TRACE: QueryBuilderTableChooser: secondValue = " +secondValue);
715:                            boolean firstFound = false;
716:                            boolean secondFound = false;
717:                            JTableOperator inputTable = QueryBuilderOperator.this 
718:                                    .getInputTable();
719:                            int rowCout = inputTable.getRowCount();
720:                            for (int i = 0; i < rowCout; i++) {
721:                                if ((inputTable.getValueAt(i, 0).toString()
722:                                        .equals(firstValue))
723:                                        && (inputTable
724:                                                .getValueAt(i, 2)
725:                                                .toString()
726:                                                .indexOf(
727:                                                        TableFrameOperator.this .tableName) != -1)) {
728:                                    firstFound = true;
729:                                    break;
730:                                }
731:                            }
732:                            for (int i = 0; i < rowCout; i++) {
733:                                if ((inputTable.getValueAt(i, 0).toString()
734:                                        .equals(secondValue))
735:                                        && (inputTable
736:                                                .getValueAt(i, 2)
737:                                                .toString()
738:                                                .indexOf(
739:                                                        TableFrameOperator.this .tableName) != -1)) {
740:                                    secondFound = true;
741:                                    break;
742:                                }
743:                            }
744:                            return firstFound && secondFound;
745:                        }
746:                        return false;
747:                    }
748:
749:                    public String getDescription() {
750:                        return "Chooser for QueryBuilderTable";
751:                    }
752:
753:                }
754:            }
755:
756:            public class QueryBuilderTableChooser implements  ComponentChooser {
757:                String tableName;
758:
759:                public QueryBuilderTableChooser(String tableName) {
760:                    this .tableName = tableName;
761:                }
762:
763:                public boolean checkComponent(Component comp) {
764:                    boolean res = comp instanceof  QueryBuilderTable;
765:                    if (res) {
766:                        String firstValue = ((QueryBuilderTable) comp)
767:                                .getValueAt(0, 2).toString();
768:                        String secondValue = ((QueryBuilderTable) comp)
769:                                .getValueAt(1, 2).toString();
770:                        //System.out.println("TRACE: QueryBuilderTableChooser: firstValue = "+
771:                        //        ((QueryBuilderTable)comp).getValueAt(0, 2));
772:                        //System.out.println("TRACE: QueryBuilderTableChooser: secondValue = " +secondValue);
773:                        boolean firstFound = false;
774:                        boolean secondFound = false;
775:                        JTableOperator inputTable = QueryBuilderOperator.this 
776:                                .getInputTable();
777:                        int rowCout = inputTable.getRowCount();
778:                        for (int i = 0; i < rowCout; i++) {
779:                            if ((inputTable.getValueAt(i, 0).toString()
780:                                    .equals(firstValue))
781:                                    && (inputTable.getValueAt(i, 2).toString()
782:                                            .indexOf(tableName) != -1)) {
783:                                firstFound = true;
784:                                break;
785:                            }
786:                        }
787:                        for (int i = 0; i < rowCout; i++) {
788:                            if ((inputTable.getValueAt(i, 0).toString()
789:                                    .equals(secondValue))
790:                                    && (inputTable.getValueAt(i, 2).toString()
791:                                            .indexOf(tableName) != -1)) {
792:                                secondFound = true;
793:                                break;
794:                            }
795:                        }
796:                        return firstFound && secondFound;
797:                    }
798:                    return false;
799:                }
800:
801:                public String getDescription() {
802:                    return "Chooser for QueryBuilderTable";
803:                }
804:
805:            }
806:
807:            /**
808:             * TableFrameChooser
809:             * @deprecated TODO: Need to choose correct table name
810:             */
811:            public class TableFrameChooser implements  ComponentChooser {
812:                String tableName;
813:
814:                public TableFrameChooser(String tableName) {
815:                    this .tableName = tableName;
816:                }
817:
818:                public boolean checkComponent(Component comp) {
819:                    if (comp instanceof  QueryBuilderPane) {
820:                        return true;
821:                    }
822:                    return false;
823:                }
824:
825:                public String getDescription() {
826:                    return "TableFrameChooser";
827:                }
828:
829:            }
830:
831:            /**
832:             *
833:             *
834:             */
835:            public class QueryBuilderPaneOperator extends ContainerOperator {
836:                public QueryBuilderPaneOperator() {
837:                    super (QueryBuilderOperator.this ,
838:                            new QueryBuilderPaneChooser());
839:                }
840:            }
841:
842:            public class QueryBuilderPaneChooser implements  ComponentChooser {
843:                public boolean checkComponent(Component comp) {
844:                    return comp instanceof  QueryBuilderPane;
845:                }
846:
847:                public String getDescription() {
848:                    return "QueryBuilderPane Component";
849:                }
850:            }
851:
852:            /**
853:             * @deprecated
854:             */
855:            public class QueryBuilderGraphFrameOperator extends
856:                    ContainerOperator {
857:                public QueryBuilderGraphFrameOperator() {
858:                    super (QueryBuilderOperator.this ,
859:                            new QueryBuilderGraphFrameChooser());
860:                }
861:            }
862:
863:            /**
864:             *
865:             */
866:            public class QueryBuilderGraphFrameChooser implements 
867:                    ComponentChooser {
868:                public boolean checkComponent(Component comp) {
869:                    return (comp instanceof  QueryBuilderGraphFrame);
870:                }
871:
872:                public String getDescription() {
873:                    return (QueryBuilderGraphFrame.class.getName());
874:                }
875:            }
876:
877:            public class InputTableOperator extends JTableOperator {
878:                public InputTableOperator() {
879:                    super (QueryBuilderOperator.this , new Operator.Finder(
880:                            QueryBuilderInputTable.class));
881:                }
882:
883:            }
884:
885:            /**
886:             * Looking for QueryBuilderInputTable by searching its instances and choosing one
887:             * which contains tableName Tabke
888:             */
889:            public static class QueryBuilderInputTableChooser implements 
890:                    ComponentChooser {
891:                String tableName;
892:
893:                /**
894:                 *
895:                 * @param tableName Name of the Table in QueryBuilderInputTable
896:                 */
897:                public QueryBuilderInputTableChooser(String tableName) {
898:                    this .tableName = tableName;
899:                }
900:
901:                public boolean checkComponent(Component comp) {
902:                    if (comp instanceof  QueryBuilderInputTable) {
903:                        JTableOperator table = new JTableOperator(
904:                                (QueryBuilderInputTable) comp);
905:                        //System.out.println("TRACE: QueryBuilderInputTableChooser table = "+ table.getValueAt(0, 2).toString());
906:                        if (table.getValueAt(0, 2).toString()
907:                                .indexOf(tableName) != -1)
908:                            return true;
909:                    }
910:                    return false;
911:                }
912:
913:                public String getDescription() {
914:                    return "QueryInputTable with name: " + tableName;
915:                }
916:
917:            }
918:
919:            /**
920:             * TODO: Doesn't work properly, not used anymore
921:             * @deprecated
922:             */
923:            public static class QueryBuilderChooser implements  ComponentChooser {
924:                private String tabId = null;
925:
926:                public QueryBuilderChooser() {
927:                }
928:
929:                public QueryBuilderChooser(String _tabId) {
930:                    tabId = _tabId;
931:                }
932:
933:                public boolean checkComponent(Component comp) {
934:                    boolean res = comp instanceof  QueryBuilder;
935:                    if (tabId != null && res) {
936:                        String name = new JTableOperator(new ContainerOperator(
937:                                ContainerOperator.findContainerUnder(comp)),
938:                                new QueryBuilderInputTableChooser(tabId))
939:                                .getValueAt(0, 2).toString();
940:                        if (name.equalsIgnoreCase(tabId)) {
941:                            return true;
942:                        }
943:                        return false;
944:                    } else {
945:                        return res;
946:                    }
947:                }
948:
949:                public String getDescription() {
950:                    return (QueryBuilder.class.getName());
951:                }
952:            }
953:
954:            /**
955:             * Finds in a bundle file and returns an actual text of control component.
956:             * @param p_text string-key corresponding to required control component.
957:             * @return actual text of control component
958:             * @deprecated No Bundle present
959:             */
960:            public static String getBundleString(String p_text) {
961:                System.out.println("Getting bundle for " + p_text);
962:                try {
963:                    return Bundle
964:                            .getStringTrimmed(
965:                                    "com.sun.rave.dataconnectivity.querybuilder.Bundle",
966:                                    p_text);
967:                } catch (JemmyException e) {
968:                }
969:                return null;
970:            }
971:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.