Source Code Cross Referenced for DiagramToolbarOperator.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:        /*
043:         * UMLDiagramToolbarOperator.java
044:         *
045:         */
046:
047:        package org.netbeans.test.umllib;
048:
049:        import java.awt.Component;
050:        import java.awt.Container;
051:        import java.io.PrintStream;
052:        import java.io.PrintWriter;
053:        import java.io.StringWriter;
054:        import javax.swing.AbstractButton;
055:        import javax.swing.JButton;
056:        import javax.swing.JToggleButton;
057:        import org.netbeans.jemmy.ComponentChooser;
058:        import org.netbeans.jemmy.operators.AbstractButtonOperator;
059:        import org.netbeans.jemmy.operators.JButtonOperator;
060:        import org.netbeans.jemmy.operators.JToggleButtonOperator;
061:        import org.netbeans.jemmy.util.Dumper;
062:        import org.netbeans.test.umllib.exceptions.NotFoundException;
063:
064:        /**
065:         * This class handles all toolbars now. 
066:         * Later them must be splitted for palettes
067:         * @author Alexei Mokeev
068:         * @see qa.uml.util.LibProperties
069:         */
070:        public class DiagramToolbarOperator {
071:            private Component mSource = null;
072:
073:            public static final String PRINT_PREVIEW_DIAGRAM_TOOL = "<html>Print Preview the active diagram (Ctrl+Shift+Z)</html>";
074:            public static final String EXPORT_AS_IMAGE_TOOL = "<html>Export as Image (Ctrl+Shift+X)</html>";
075:            public static final String SELECT_TOOL = "<html>Select (Ctrl+Shift+S)</html>";
076:            public static final String PAN_TOOL = "<html>Pan (Ctrl+Alt+Shift+P)</html>";
077:            public static final String ZOOM_WITH_MARQUEE_TOOL = "<html>Zoom with Marquee (Ctrl+Alt+Shift+Z)</html>";
078:            public static final String ZOOM_INTERACTIVELY_TOOL = "<html>Zoom Interactively (Ctrl+Alt+Shift+I)</html>";
079:            public static final String NAVIGATE_LINK_TOOL = "<html>Navigate Link (Ctrl+Alt+Shift+L)</html>";
080:            public static final String OVERVIEW_WINDOW_TOOL = "<html>Overview Window (F8)</html>";
081:            public static final String DIAGRAM_SYNCHRONIZATION_TOOL = "<html>Diagram Synchronization (Ctrl+Alt+Shift+R)</html>";
082:            public static final String SHOW_FRIENDLY_NAMES_TOOL = "<html>Show Friendly Names</html>";
083:            public static final String RELATIONSHIP_DISCOVERY_TOOL = "<html>Relationship Discovery (Ctrl+Alt+Shift+H)</html>";
084:            public static final String FIT_TO_WINDOW_TOOL = "<html>Fit to Window (Ctrl+Shift+F)</html>";
085:            public static final String ZOOM_IN_TOOL = "<html>Zoom In (Alt+)</html>";
086:            public static final String ZOOM_OUT_TOOL = "<html>Zoom Out (Alt-)</html>";
087:            public static final String MOVE_FORWARD_TOOL = "<html>Move Forward (Ctrl+Alt+Shift+U)</html>";
088:            public static final String MOVE_TO_FRONT_TOOL = "<html>Move to Front (Ctrl+Alt+Shift+F)</html>";
089:            public static final String MOVE_BACKWARD_TOOL = "<html>Move Backward (Ctrl+Alt+Shift+D)</html>";
090:            public static final String MOVE_TO_BACK_TOOL = "<html>Move to Back (Ctrl+Alt+Shift+B)</html>";
091:            public static final String HIERARCHICAL_LAYOUT_TOOL = "<html>Hierarchical Layout (Ctrl+Shift+K)</html>";
092:            public static final String ORTHOGONAL_LAYOUT_TOOL = "<html>Orthogonal Layout (Ctrl+Shift+B)</html>";
093:            public static final String SYMMETRIC_LAYOUT_TOOL = "<html>Symmetric Layout (Ctrl+Shift+Y)</html>";
094:            public static final String SEQUENCE_LAYOUT_TOOL = "<html>Sequence Diagram Layout</html>";
095:            public static final String INCREMENTAL_LAYOUT_TOOL = "<html>Incremental Layout (Ctrl+Shift+I)</html>";
096:
097:            private String defaultToolTooltip = SELECT_TOOL;
098:
099:            /**
100:             * Creates a new instance of DiagramToolbarOperator
101:             * @param diagramOperator 
102:             */
103:            public DiagramToolbarOperator(DiagramOperator diagramOperator) {
104:                this .mSource = diagramOperator.getSource();
105:            }
106:
107:            /**
108:             * 
109:             * @param source 
110:             */
111:            public DiagramToolbarOperator(Component source) {
112:                this .mSource = source;
113:            }
114:
115:            /**
116:             * 
117:             * @param buttonTooltip 
118:             * @throws qa.uml.exceptions.NotFoundException 
119:             */
120:            public void selectTool(String buttonTooltip)
121:                    throws NotFoundException {
122:                //new MouseRobotDriver(new Timeout("",10)).clickMouse(btn, btn.getCenterXForClick(), btn.getCenterYForClick(), 1, InputEvent.BUTTON1_MASK, 0, new Timeout("",10));
123:                getAnyButtonByTooltip(buttonTooltip).doClick();
124:                try {
125:                    Thread.sleep(100);
126:                } catch (Exception ex) {
127:                }
128:            }
129:
130:            /**
131:             * 
132:             * @param buttonTooltip 
133:             * @throws qa.uml.exceptions.NotFoundException 
134:             */
135:            public void selectToolNoBlock(String buttonTooltip)
136:                    throws NotFoundException {
137:                getAnyButtonByTooltip(buttonTooltip).pushNoBlock();
138:                //new MouseRobotDriver(new Timeout("",10)).clickMouse(btn, btn.getCenterXForClick(), btn.getCenterYForClick(), 1, InputEvent.BUTTON1_MASK, 0, new Timeout("",10));
139:                try {
140:                    Thread.sleep(100);
141:                } catch (Exception ex) {
142:                }
143:            }
144:
145:            public AbstractButtonOperator getAnyButtonByTooltip(
146:                    String buttonTooltip) throws NotFoundException {
147:                ToolbarButtonChooser tch = new ToolbarButtonChooser(
148:                        buttonTooltip);
149:                AbstractButton button = AbstractButtonOperator
150:                        .findAbstractButton((Container) mSource, tch);
151:                if (button == null) {
152:                    StringWriter sr = new StringWriter();
153:                    PrintWriter pr = new PrintWriter(sr);
154:                    Dumper.dumpComponent(mSource, pr);
155:                    pr.flush();
156:                    throw new NotFoundException(tch.tt + "Toolbar button \""
157:                            + buttonTooltip + "\" was not found on toolbar\n"
158:                            + sr.getBuffer().toString());
159:                }
160:                return new AbstractButtonOperator(button);
161:            }
162:
163:            /**
164:             * default tool selection/clicking, usually "select tool"
165:             */
166:            public void selectDefault() {
167:                selectTool(defaultToolTooltip);
168:            }
169:
170:            /**
171:             * 
172:             * @param buttonTooltip 
173:             * @throws qa.uml.exceptions.NotFoundException 
174:             * @return 
175:             */
176:            public JButton getButtonByTooltip(String buttonTooltip)
177:                    throws NotFoundException {
178:                JButton button = JButtonOperator.findJButton(
179:                        (Container) mSource, new ToolbarButtonChooser(
180:                                buttonTooltip));
181:                if (button == null) {
182:                    throw new NotFoundException("Toolbar button \""
183:                            + buttonTooltip + "\" was not found on toolbar");
184:                }
185:                return button;
186:            }
187:
188:            /**
189:             * 
190:             * @param buttonTooltip 
191:             * @throws qa.uml.exceptions.NotFoundException 
192:             * @return 
193:             */
194:            public JToggleButton getToggleButtonByTooltip(String buttonTooltip)
195:                    throws NotFoundException {
196:                JToggleButton button = JToggleButtonOperator.findJToggleButton(
197:                        (Container) mSource, new ToolbarToggleButtonChooser(
198:                                buttonTooltip));
199:                if (button == null) {
200:                    throw new NotFoundException("Toolbar button \""
201:                            + buttonTooltip + "\" was not found on toolbar");
202:                }
203:                return button;
204:            }
205:
206:            class ToolbarToggleButtonChooser implements  ComponentChooser {
207:                PrintStream p = null;
208:
209:                /**
210:                 * 
211:                 * @param str 
212:                 */
213:                ToolbarToggleButtonChooser(String str) {
214:                    myStr = str;
215:                }
216:
217:                /**
218:                 * 
219:                 * @param arg0 
220:                 * @return 
221:                 */
222:                public boolean checkComponent(java.awt.Component arg0) {
223:                    if (arg0 instanceof  JToggleButton) {
224:
225:                        JToggleButton button = (JToggleButton) arg0;
226:                        String tooltip = button.getToolTipText();
227:                        if ((tooltip != null) && tooltip.startsWith(myStr)) {
228:                            return true;
229:                        }
230:                    }
231:                    return false;
232:                }
233:
234:                /**
235:                 * 
236:                 * @return 
237:                 */
238:                public String getDescription() {
239:                    return "Chooser for ToggleButton on diagram pane";
240:                }
241:
242:                private String myStr;
243:            }
244:
245:            class ToolbarButtonChooser implements  ComponentChooser {
246:                PrintStream p = null;
247:
248:                public String tt = "";
249:
250:                /**
251:                 * 
252:                 * @param str 
253:                 */
254:                ToolbarButtonChooser(String str) {
255:                    myStr = str;
256:                    tt = "";
257:                }
258:
259:                /**
260:                 * 
261:                 * @param arg0 
262:                 * @return 
263:                 */
264:                public boolean checkComponent(java.awt.Component arg0) {
265:                    if (arg0 instanceof  AbstractButton) {
266:
267:                        AbstractButton button = (AbstractButton) arg0;
268:                        String tooltip = button.getToolTipText();
269:                        tt += "[" + tooltip + "];\n";
270:                        if ((tooltip != null) && tooltip.startsWith(myStr)) {
271:                            return true;
272:                        }
273:                    }
274:                    return false;
275:                }
276:
277:                /**
278:                 * 
279:                 * @return 
280:                 */
281:                public String getDescription() {
282:                    return "Chooser for Button on diagram pane";
283:                }
284:
285:                private String myStr;
286:            }
287:
288:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.