Source Code Cross Referenced for UMLPaletteOperator.java in  » IDE-Netbeans » uml » org » netbeans » test » umllib » 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.umllib 
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.umllib;
043:
044:        import java.awt.Component;
045:        import java.awt.Container;
046:        import javax.swing.JList;
047:        import javax.swing.ListModel;
048:        import org.netbeans.jellytools.TopComponentOperator;
049:        import org.netbeans.jemmy.ComponentChooser;
050:        import org.netbeans.jemmy.EventTool;
051:        import org.netbeans.jemmy.TimeoutExpiredException;
052:        import org.netbeans.jemmy.operators.ContainerOperator;
053:        import org.netbeans.jemmy.operators.JListOperator;
054:        import org.netbeans.jemmy.operators.JToggleButtonOperator;
055:        import org.netbeans.test.umllib.exceptions.NotFoundException;
056:        import org.netbeans.test.umllib.exceptions.UMLCommonException;
057:        import org.netbeans.test.umllib.util.LibProperties;
058:
059:        public class UMLPaletteOperator extends TopComponentOperator {
060:
061:            public final static String PALETTE_NAME = "Palette";
062:
063:            private static String debug_info;
064:
065:            private EventTool eventTool = new EventTool();
066:
067:            public UMLPaletteOperator() {
068:                super (PALETTE_NAME);
069:                waitComponentVisible(true);
070:            }
071:
072:            /**
073:             * 
074:             * @param toolName 
075:             * @throws qa.uml.exceptions.NotFoundException 
076:             */
077:            public void selectTool(String toolName) throws NotFoundException {
078:                debug_info = "Select Tool Starts;\n";
079:                makeComponentVisible();
080:                waitComponentVisible(true);
081:                //
082:                try {
083:                    Thread.sleep(100);
084:                } catch (Exception ex) {
085:                }
086:                //
087:                ComponentChooser listChooser = new JListByItemChooser(toolName);
088:                Component comp = waitSubComponent(listChooser);
089:                if (comp == null) {
090:                    throw new NotFoundException("The element with name "
091:                            + toolName + " was not found on UML palette");
092:                }
093:                Container cont = comp.getParent();
094:                JToggleButtonOperator btn = new JToggleButtonOperator(
095:                        new ContainerOperator(cont));
096:                JListOperator listOperator = new JListOperator((JList) comp);
097:                eventTool.waitNoEvent(500);
098:                if (!btn.isSelected()) {
099:                    btn.pushNoBlock();
100:                    btn.waitSelected(true);
101:                }
102:                try {
103:                    Thread.sleep(100);
104:                } catch (Exception ex) {
105:                }
106:                //refresh
107:                listOperator = new JListOperator((JList) comp);
108:                int itemIndex = listOperator
109:                        .findItemIndex(new PaletteListItemChooser(toolName));
110:                try {
111:                    listOperator.scrollToItem(itemIndex);
112:                } catch (TimeoutExpiredException ex) {
113:                    //sometimes scrolling generate exceptions without visible reason
114:                    //may be thhid check will help
115:                    listOperator = new JListOperator((JList) comp);//refresh list operator
116:                    if (((JList) (listOperator.getSource()))
117:                            .getLastVisibleIndex() < itemIndex
118:                            || ((JList) (listOperator.getSource()))
119:                                    .getFirstVisibleIndex() > itemIndex)
120:                        throw new UMLCommonException(
121:                                "Scrolling, current index: "
122:                                        + itemIndex
123:                                        + "; min: "
124:                                        + ((JList) (listOperator.getSource()))
125:                                                .getFirstVisibleIndex()
126:                                        + "; max: "
127:                                        + ((JList) (listOperator.getSource()))
128:                                                .getLastVisibleIndex());
129:                    //else all is good and we can click
130:                }
131:                listOperator.getTimeouts().setTimeout(
132:                        "JScrollBarOperator.WholeScrollTimeout", 500);
133:                try {
134:                    Thread.sleep(100);
135:                } catch (Exception ex) {
136:                }
137:                if (listOperator.getSelectedIndex() != itemIndex) {
138:                    listOperator.clickOnItem(itemIndex, 1);
139:                    listOperator.waitItemSelection(itemIndex, true);
140:                    try {
141:                        Thread.sleep(100);
142:                    } catch (Exception ex) {
143:                    }
144:                }
145:                listOperator.getTimeouts().setTimeout(
146:                        "JScrollBarOperator.WholeScrollTimeout", 30000);
147:                //wait again with waiter
148:                waitSelection(toolName, true);
149:            }
150:
151:            /**
152:             * 
153:             * @param type 
154:             * @throws qa.uml.exceptions.NotFoundException 
155:             */
156:            public void selectToolByType(Enum type) throws NotFoundException {
157:                selectTool(getToolNameByElementType(type));
158:            }
159:
160:            /**
161:             * @return 
162:             */
163:            public String getSelectedItemname() {
164:                JList lst = null;
165:                JListWithSelectionChooser tmp = new JListWithSelectionChooser();
166:                lst = (JList) findSubComponent(tmp);
167:                Object sel = null;
168:                if (lst != null)
169:                    sel = lst.getSelectedValue();
170:                return (sel != null) ? (sel.toString()) : ("null");
171:            }
172:
173:            /**
174:             * 
175:             * @param elementType 
176:             * @return 
177:             */
178:            public String getToolNameByElementType(Enum elementType) {
179:                return LibProperties.getCurrentToolName(elementType);
180:            }
181:
182:            /**
183:             * 
184:             * @param groupName 
185:             */
186:            public void expandGroup(String groupName) {
187:                makeComponentVisible();
188:                JToggleButtonOperator groupBtn = new JToggleButtonOperator(
189:                        this , groupName);
190:                if (!groupBtn.isSelected()) {
191:                    groupBtn.pushNoBlock();
192:                    groupBtn.waitSelected(true);
193:                }
194:            }
195:
196:            /**
197:             * 
198:             * @param groupName 
199:             */
200:            public void collapseGroup(String groupName) {
201:                makeComponentVisible();
202:                JToggleButtonOperator groupBtn = new JToggleButtonOperator(
203:                        this , groupName);
204:                if (groupBtn.isSelected()) {
205:                    groupBtn.pushNoBlock();
206:                    groupBtn.waitSelected(false);
207:                }
208:            }
209:
210:            private class PaletteListItemChooser implements 
211:                    JListOperator.ListItemChooser {
212:                String itemLabel;
213:
214:                public PaletteListItemChooser(String itemLabel) {
215:                    this .itemLabel = itemLabel;
216:                }
217:
218:                public boolean checkItem(JListOperator oper, int index) {
219:                    Object obj = oper.getModel().getElementAt(index);
220:                    return itemLabel.equals(obj.toString());
221:
222:                    //FilterNode node = (FilterNode)obj;
223:                    //getOutput().printError("chooser:"+node.getDisplayName());
224:                    //return (node.getDisplayName().equals(itemLabel));				     
225:                }
226:
227:                public String getDescription() {
228:                    return ("Item equal to \"" + itemLabel + "\" string");
229:                }
230:            }
231:
232:            class JListByItemChooser implements  ComponentChooser {
233:                String itemName = null;
234:
235:                /**
236:                 * 
237:                 * @param itemName 
238:                 */
239:                JListByItemChooser(String itemName) {
240:                    this .itemName = itemName.trim();
241:                    System.out.println("   Item Name = \"" + itemName + "\"");
242:                }
243:
244:                /*
245:                 * (non-Javadoc)
246:                 *
247:                 * @see org.netbeans.jemmy.ComponentChooser#checkComponent(java.awt.Component)
248:                 */
249:                /**
250:                 * 
251:                 * @param comp 
252:                 * @return 
253:                 */
254:                public boolean checkComponent(Component comp) {
255:
256:                    if (comp instanceof  JList) {
257:                        JList list = (JList) comp;
258:                        ListModel model = list.getModel();
259:                        for (int i = 0; i < model.getSize(); i++) {
260:                            Object obj = model.getElementAt(i);
261:
262:                            System.out.println("   Elem = \"" + obj.toString()
263:                                    + "\"");
264:                            if (itemName.equals(obj.toString())) {
265:                                return true;
266:                            }
267:                            /*
268:                            if (obj instanceof FilterNode){
269:                                FilterNode node = (FilterNode)obj;
270:                                //getOutput().printError("display:|"+node.getDisplayName()+ "|  "+obj+" index"+i+"search:"+itemName);                            
271:                                if (node.getDisplayName().trim().equals(itemName)){                                
272:                                    return true;
273:                                }                        
274:                            }
275:                             */
276:                        }
277:                    }
278:                    return false;
279:                }
280:
281:                /**
282:                 * 
283:                 * @return 
284:                 */
285:                public String getDescription() {
286:                    return "Tool list by tool with name \"" + itemName
287:                            + "\" chooser";
288:                }
289:            }
290:
291:            class JListWithSelectionChooser implements  ComponentChooser {
292:                /**
293:                 */
294:                JListWithSelectionChooser() {
295:                }
296:
297:                /*
298:                 * (non-Javadoc)
299:                 *
300:                 * @see org.netbeans.jemmy.ComponentChooser#checkComponent(java.awt.Component)
301:                 */
302:                /**
303:                 * 
304:                 * @param comp 
305:                 * @return 
306:                 */
307:                public boolean checkComponent(Component comp) {
308:
309:                    if (comp instanceof  JList) {
310:                        JList list = (JList) comp;
311:                        if (list.getSelectedIndices().length > 0)
312:                            return true;
313:                    }
314:
315:                    return false;
316:                }
317:
318:                /**
319:                 * 
320:                 * @return 
321:                 */
322:                public String getDescription() {
323:                    return "Tool list which have selected elements";
324:                }
325:            }
326:
327:            /**
328:             * wait tool to be selected/deselected
329:             * do not open/close, scroll lists or make palette visible
330:             * @param toolName 
331:             * @param selected 
332:             */
333:            public void waitSelection(String toolName, boolean selected) {
334:                ComponentChooser listChooser = new JListByItemChooser(toolName);
335:                Component comp = waitSubComponent(listChooser);
336:                if (comp == null) {
337:                    throw new NotFoundException("The element with name "
338:                            + toolName + " was not found on UML palette");
339:                }
340:                Container cont = comp.getParent();
341:                JToggleButtonOperator btn = new JToggleButtonOperator(
342:                        new ContainerOperator(cont));
343:                JListOperator listOperator = new JListOperator((JList) comp);
344:                eventTool.waitNoEvent(500);
345:                int itemIndex = listOperator
346:                        .findItemIndex(new PaletteListItemChooser(toolName));
347:                listOperator.waitItemSelection(itemIndex, selected);
348:            }
349:
350:            /**
351:             * 
352:             * @param type 
353:             * @param selected 
354:             */
355:            public void waitSelection(Enum type, boolean selected) {
356:                waitSelection(getToolNameByElementType(type), selected);
357:            }
358:
359:            public static String getDebugInfo() {
360:                return debug_info;
361:            }
362:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.