Source Code Cross Referenced for EJBCreator.java in  » IDE-Netbeans » uml » org » netbeans » test » uml » ejb » utils » 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 » uml » org.netbeans.test.uml.ejb.utils 
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.test.uml.ejb.utils;
043:
044:        import java.awt.Component;
045:        import java.util.ArrayList;
046:        import java.util.Date;
047:        import javax.swing.JComboBox;
048:        import javax.swing.JDialog;
049:        import javax.swing.JTextArea;
050:        import org.netbeans.jellytools.MainWindowOperator;
051:        import org.netbeans.jellytools.ProjectsTabOperator;
052:        import org.netbeans.jellytools.nodes.Node;
053:        import org.netbeans.jellytools.nodes.ProjectRootNode;
054:        import org.netbeans.jemmy.ComponentChooser;
055:        import org.netbeans.jemmy.EventTool;
056:        import org.netbeans.jemmy.Timeout;
057:        import org.netbeans.jemmy.TimeoutExpiredException;
058:        import org.netbeans.jemmy.drivers.DriverManager;
059:        import org.netbeans.jemmy.drivers.input.KeyEventDriver;
060:        import org.netbeans.jemmy.drivers.input.KeyRobotDriver;
061:        import org.netbeans.jemmy.operators.JButtonOperator;
062:        import org.netbeans.jemmy.operators.JCheckBoxOperator;
063:        import org.netbeans.jemmy.operators.JComboBoxOperator;
064:        import org.netbeans.jemmy.operators.JDialogOperator;
065:        import org.netbeans.jemmy.operators.JLabelOperator;
066:        import org.netbeans.jemmy.operators.JTextAreaOperator;
067:        import org.netbeans.jemmy.operators.JTextComponentOperator;
068:        import org.netbeans.test.umllib.DiagramOperator;
069:        import org.netbeans.test.umllib.exceptions.KnownBugException;
070:        import org.netbeans.test.umllib.exceptions.UMLCommonException;
071:
072:        public class EJBCreator {
073:
074:            public final static String EJB_1 = "EJB1.1";
075:            public final static String EJB_2 = "EJB2.0";
076:
077:            public final static String BMP = "BeanManaged";
078:            public final static String CMP = "ContainerManaged";
079:            public final static String MDB = "MessageDriven";
080:            public final static String SESSION_STATELESS = "StatelessSession";
081:            public final static String SESSION_STATEFUL = "StatefulSession";
082:
083:            public final String APPLY_PATTERN_MENU = "Apply Design Pattern...";
084:            public final String PATTERN_WIZARD_FIRST_STEP_TTL = "Design Pattern Apply Wizard";
085:            public final String PATTERN_WIZARD_TTL = "Design Pattern Wizard";
086:
087:            private final String NEXT_BTN = "Next";
088:            private final String FINISH_BTN = "Finish";
089:
090:            private ArrayList<Pair> pairs = null;
091:            private EventTool eventTool = new EventTool();
092:            private String projectName = null;
093:
094:            private static boolean reported_85870 = false;
095:
096:            /** Creates a new instance of BasicEJBPatternVerifier */
097:            public EJBCreator(String project) {
098:                this .projectName = project;
099:            }
100:
101:            public DiagramOperator create(String invocationPath,
102:                    String ejbType, String ejbName, String namespace,
103:                    boolean createDiagram, String diagramName) {
104:                eventTool.waitNoEvent(1000);
105:                openDesignPatternWizard(invocationPath);
106:
107:                eventTool.waitNoEvent(1000);
108:                handleStartPage();
109:
110:                eventTool.waitNoEvent(1000);
111:                handleSelectPattern(ejbType, ejbName);
112:
113:                eventTool.waitNoEvent(1000);
114:                handleSelectTargetScope(namespace);
115:
116:                eventTool.waitNoEvent(1000);
117:                handleChooseParticipants(pairs);
118:
119:                eventTool.waitNoEvent(1000);
120:                handleSetOptions(createDiagram, diagramName);
121:
122:                eventTool.waitNoEvent(1000);
123:                finishWizard();
124:                //
125:                eventTool.waitNoEvent(3000);
126:                //
127:                DiagramOperator dia = null;
128:                try {
129:                    dia = new DiagramOperator(diagramName);
130:                } catch (TimeoutExpiredException ex) {
131:                    //1st dialog
132:                    JDialog dlg = JDialogOperator.findJDialog(
133:                            "Invalid Property", true, true);
134:                    if (dlg != null) {
135:                        JTextArea lbl = JTextAreaOperator
136:                                .findJTextArea(
137:                                        dlg,
138:                                        "The operations of an interface must be abstract. The Abstract property for this operation will be set back to True.",
139:                                        false, false);
140:                        if (lbl != null) {
141:                            if (!reported_85870) {
142:                                reported_85870 = true;
143:                                new Thread(new TerminationDialogHandler())
144:                                        .start();
145:                                throw new KnownBugException(85870,
146:                                        "Unexpected \"Invalid Property\" dialogs on pattern application");
147:                            } else
148:                                throw new KnownBugException(
149:                                        85870,
150:                                        "Too long application and a lot of Unexpected \"Invalid Property\" dialogs on pattern application");
151:                        } else {
152:                            throw new UMLCommonException(
153:                                    "Unknown Invalid property dialog.");
154:                        }
155:                    } else {
156:                        throw ex;
157:                    }
158:                }
159:                return dia;
160:            }
161:
162:            protected void openDesignPatternWizard(String pathToInvokationPoint) {
163:                ProjectsTabOperator pto = ProjectsTabOperator.invoke();
164:                ProjectRootNode root = new ProjectRootNode(pto.tree(),
165:                        projectName);
166:
167:                Node node = new Node(root, pathToInvokationPoint);
168:                node.performPopupActionNoBlock(APPLY_PATTERN_MENU);
169:
170:                new JDialogOperator(PATTERN_WIZARD_FIRST_STEP_TTL);
171:            }
172:
173:            protected void handleStartPage() {
174:                JDialogOperator dlg = new JDialogOperator(
175:                        PATTERN_WIZARD_FIRST_STEP_TTL);
176:                new JButtonOperator(dlg, NEXT_BTN).push();
177:            }
178:
179:            protected void handleSelectPattern(String ejbType, String ejbName) {
180:                JDialogOperator dlg = new JDialogOperator(PATTERN_WIZARD_TTL);
181:                JComboBoxOperator cbProject = new JComboBoxOperator(dlg, 0);
182:                cbProject.selectItem(ejbType);
183:                eventTool.waitNoEvent(1000);
184:                JComboBoxOperator cbEJB = new JComboBoxOperator(dlg, 1);
185:                cbEJB.selectItem(ejbName);
186:                eventTool.waitNoEvent(1000);
187:
188:                new JButtonOperator(dlg, NEXT_BTN).push();
189:            }
190:
191:            protected void handleSelectTargetScope(String namespace) {
192:                JDialogOperator dlg = new JDialogOperator(PATTERN_WIZARD_TTL);
193:                if (namespace != null) {
194:                    //JComboBoxOperator cbNamespace = new JComboBoxOperator(dlg, 1);
195:                    JLabelOperator nspLbl = new JLabelOperator(dlg,
196:                            "Namespace:");
197:                    JComboBoxOperator cbNamespace = new JComboBoxOperator(
198:                            (JComboBox) (nspLbl.getLabelFor()));
199:                    cbNamespace.selectItem(namespace);
200:                    cbNamespace.waitItemSelected(namespace);
201:                    eventTool.waitNoEvent(1000);
202:                }
203:                new JButtonOperator(dlg, NEXT_BTN).push();
204:            }
205:
206:            protected void handleChooseParticipants(ArrayList<Pair> pairs) {
207:                if (pairs != null) {
208:                    //to be implemented in the descendants or later
209:                }
210:                JDialogOperator dlg = new JDialogOperator(PATTERN_WIZARD_TTL);
211:                new JButtonOperator(dlg, NEXT_BTN).push();
212:            }
213:
214:            protected void handleSetOptions(boolean createDiagram,
215:                    String diagramName) {
216:                JDialogOperator dlg = new JDialogOperator(PATTERN_WIZARD_TTL);
217:
218:                new JCheckBoxOperator(dlg).clickMouse();
219:                new JCheckBoxOperator(dlg).waitSelected(true);
220:                eventTool.waitNoEvent(1000);
221:                DriverManager.setKeyDriver(new KeyEventDriver());
222:                new JTextComponentOperator(dlg, 1).clearText();
223:                new JTextComponentOperator(dlg, 1).waitText("");
224:                new JTextComponentOperator(dlg, 1).typeText(diagramName);
225:                eventTool.waitNoEvent(1000);
226:                DriverManager.setKeyDriver(new KeyRobotDriver(new Timeout(
227:                        "autoDelay", 50)));
228:                new JButtonOperator(dlg, NEXT_BTN).push();
229:                JComboBox g;
230:            }
231:
232:            protected void finishWizard() {
233:                JDialogOperator dlg = new JDialogOperator(
234:                        PATTERN_WIZARD_FIRST_STEP_TTL);
235:                new JButtonOperator(dlg, FINISH_BTN).push();
236:                dlg.waitClosed();
237:            }
238:
239:            //***************************************************************
240:            //WORKAROUND FOR 85870
241:            //***************************************************************
242:            /**
243:             * class works until MainWindow is showing and wait for different times of dialogs
244:             */
245:            static private class TerminationDialogHandler implements  Runnable {
246:                private long startTime;
247:                private long timeout;
248:                private long prevTime;
249:                //
250:                private int lastBtnIndex = 0;
251:                protected JDialogOperator tDlg = null;
252:                //
253:                private String dialogTitle;
254:                private String buttonTitle[];
255:                //
256:                final private long EXEC_TIMEOUT = 60 * 60 * 6 * 1000;//6 hours to exit thread
257:                final private long DEFAULT_TIMEOUT = 60 * 1000;//wait 60 seconds and close unused dialog
258:                //
259:                final static public String DIALOG_TITLE_85870 = "Invalid Property";
260:                final static public String BUTTON_TITLE_85870 = "OK";
261:                final static public String TEXT_85870 = "The operations of an interface must be abstract. The Abstract property for this operation will be set back to True.";
262:
263:                TerminationDialogHandler() {
264:                    startTime = new Date().getTime();
265:                }
266:
267:                public void run() {
268:                    MainWindowOperator mw = null;
269:                    while (true) {
270:                        //try dialog every 2 second
271:                        try {
272:                            Thread.sleep(2000);
273:                        } catch (Exception ex) {
274:                        }
275:                        ;
276:                        mw = MainWindowOperator.getDefault();
277:                        if (!(mw != null && mw.isShowing() && mw.isVisible())) {
278:                            break;
279:                        }
280:                        if ((new Date().getTime() - startTime) > EXEC_TIMEOUT) {
281:                            break;
282:                        }
283:                        //check if dialog was found before and still exists
284:                        tDlg = null;
285:                        //try to find dialog
286:                        try {
287:                            tDlg = new JDialogOperator(
288:                                    new ChooseDialogByTitleAndButtonAndText(
289:                                            DIALOG_TITLE_85870,
290:                                            BUTTON_TITLE_85870, TEXT_85870));
291:                            new JButtonOperator(tDlg, BUTTON_TITLE_85870)
292:                                    .push();
293:                            tDlg.waitClosed();
294:                        } catch (Exception ex) {
295:                            //no dialog
296:                        }
297:                    }
298:                }
299:            }
300:
301:            /**
302:             * choose JDialog with appropriate exaqct title and appropriate exact button within
303:             */
304:            static private class ChooseDialogByTitleAndButtonAndText implements 
305:                    ComponentChooser {
306:                private String title;
307:                private String btn;
308:                private String txt;
309:
310:                ChooseDialogByTitleAndButtonAndText(String ttl, String bt,
311:                        String text) {
312:                    title = ttl;
313:                    btn = bt;
314:                    txt = text;
315:                }
316:
317:                public String getDescription() {
318:                    return "find dialog with " + title + " title";
319:                }
320:
321:                public boolean checkComponent(Component component) {
322:                    if (component instanceof  java.awt.Dialog) {
323:                        if (((java.awt.Dialog) component).getTitle().equals(
324:                                title)) {
325:                            return JButtonOperator.findJButton(
326:                                    (java.awt.Dialog) component, btn, true,
327:                                    true) != null
328:                                    && JTextAreaOperator.findJTextArea(
329:                                            (java.awt.Dialog) component, txt,
330:                                            true, true) != null;
331:                        }
332:                    }
333:                    return false;
334:                }
335:            }
336:
337:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.