Source Code Cross Referenced for DiffOperator.java in  » IDE-Netbeans » jellytools » org » netbeans » jellytools » modules » javacvs » 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 » jellytools » org.netbeans.jellytools.modules.javacvs 
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-2006 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:        package org.netbeans.jellytools.modules.javacvs;
042:
043:        import java.awt.Component;
044:        import javax.swing.JComponent;
045:        import org.netbeans.jellytools.Bundle;
046:        import org.netbeans.jellytools.TopComponentOperator;
047:        import org.netbeans.jellytools.actions.Action;
048:        import org.netbeans.jemmy.ComponentChooser;
049:        import org.netbeans.jemmy.operators.JButtonOperator;
050:        import org.netbeans.jemmy.operators.JComboBoxOperator;
051:        import org.netbeans.jemmy.operators.JPopupMenuOperator;
052:        import org.netbeans.jemmy.operators.JTableOperator;
053:        import org.netbeans.jemmy.operators.JToggleButtonOperator;
054:        import org.netbeans.jemmy.operators.Operator;
055:
056:        /**
057:         * Class implementing all necessary methods for handling "Diff" view.
058:         * <br>
059:         * Usage:<br>
060:         * <pre>
061:         *      DiffOperator diffOper = new DiffOperator("MyClass.java");
062:         *      diffOper.next();
063:         *      diffOper.previous();
064:         *      diffOper.checkRemote(true);
065:         *      diffOper.checkLocal(true);
066:         *      diffOper.checkRemoteLocal(true);
067:         *      diffOper.refresh();
068:         *      diffOper.update();
069:         *      CommitOperator co = diffOper.commit();
070:         *      diffOper.selectFile("form");
071:         * </pre>
072:         * 
073:         * @author Jiri.Skrivanek@sun.com
074:         * @see CommitOperator
075:         * @see org.netbeans.jellytools.modules.javacvs.actions.DiffAction
076:         */
077:        public class DiffOperator extends TopComponentOperator {
078:
079:            /** Waits for Diff TopComponent with specified file name.
080:             * @param name name of 'diffed' file
081:             */
082:            public DiffOperator(String name) {
083:                super (waitTopComponent(null, name, 0, new DiffSubchooser()));
084:            }
085:
086:            /** Waits for first open Diff TopComponent. */
087:            public DiffOperator() {
088:                this (null);
089:            }
090:
091:            private JButtonOperator _btNext;
092:            private JButtonOperator _btPrevious;
093:            private JToggleButtonOperator _tbRemoveLocal;
094:            private JToggleButtonOperator _tbLocal;
095:            private JToggleButtonOperator _tbRemote;
096:            private JButtonOperator _btRefresh;
097:            private JButtonOperator _btUpdate;
098:            private JButtonOperator _btCommit;
099:            private JComboBoxOperator _cbFiles;
100:
101:            //******************************
102:            // Subcomponents definition part
103:            //******************************
104:
105:            /** Tries to find Go to Next Difference JButton in diff view.
106:             * @return JButtonOperator
107:             */
108:            public JButtonOperator btNext() {
109:                if (_btNext == null) {
110:                    String tooltip = Bundle
111:                            .getString(
112:                                    "org.netbeans.modules.versioning.system.cvss.ui.actions.diff.Bundle",
113:                                    "CTL_DiffPanel_Next_Tooltip");
114:                    _btNext = new JButtonOperator(this , new TooltipChooser(
115:                            tooltip, getComparator()));
116:                }
117:                return _btNext;
118:            }
119:
120:            /** Tries to find Go to Previous Difference JButton in diff view.
121:             * @return JButtonOperator
122:             */
123:            public JButtonOperator btPrevious() {
124:                if (_btPrevious == null) {
125:                    String tooltip = Bundle
126:                            .getString(
127:                                    "org.netbeans.modules.versioning.system.cvss.ui.actions.diff.Bundle",
128:                                    "CTL_DiffPanel_Prev_Tooltip");
129:                    _btPrevious = new JButtonOperator(this , new TooltipChooser(
130:                            tooltip, getComparator()));
131:                }
132:                return _btPrevious;
133:            }
134:
135:            /** Tries to find "Remove vs Local" JToggleButton in diff view.
136:             * @return JToggleButtonOperator
137:             */
138:            public JToggleButtonOperator tbRemoteLocal() {
139:                if (_tbRemoveLocal == null) {
140:                    _tbRemoveLocal = new JToggleButtonOperator(
141:                            this ,
142:                            Bundle
143:                                    .getStringTrimmed(
144:                                            "org.netbeans.modules.versioning.system.cvss.ui.actions.diff.Bundle",
145:                                            "CTL_DiffPanel_All"));
146:                }
147:                return _tbRemoveLocal;
148:            }
149:
150:            /** Tries to find "Local" JToggleButton in diff view.
151:             * @return JToggleButtonOperator
152:             */
153:            public JToggleButtonOperator tbLocal() {
154:                if (_tbLocal == null) {
155:                    Operator.StringComparator oldComparator = Operator
156:                            .getDefaultStringComparator();
157:                    Operator.DefaultStringComparator comparator = new Operator.DefaultStringComparator(
158:                            true, true);
159:                    try {
160:                        this .setComparator(comparator);
161:                        _tbLocal = new JToggleButtonOperator(
162:                                this ,
163:                                Bundle
164:                                        .getStringTrimmed(
165:                                                "org.netbeans.modules.versioning.system.cvss.ui.actions.diff.Bundle",
166:                                                "CTL_DiffPanel_Local"));
167:                    } finally {
168:                        this .setComparator(oldComparator);
169:                    }
170:                }
171:                return _tbLocal;
172:            }
173:
174:            /** Tries to find "Remote" JToggleButton in diff view.
175:             * @return JToggleButtonOperator
176:             */
177:            public JToggleButtonOperator tbRemote() {
178:                if (_tbRemote == null) {
179:                    Operator.StringComparator oldComparator = Operator
180:                            .getDefaultStringComparator();
181:                    Operator.DefaultStringComparator comparator = new Operator.DefaultStringComparator(
182:                            true, true);
183:                    try {
184:                        this .setComparator(comparator);
185:                        _tbRemote = new JToggleButtonOperator(
186:                                this ,
187:                                Bundle
188:                                        .getStringTrimmed(
189:                                                "org.netbeans.modules.versioning.system.cvss.ui.actions.diff.Bundle",
190:                                                "CTL_DiffPanel_Remote"));
191:                    } finally {
192:                        this .setComparator(oldComparator);
193:                    }
194:                }
195:                return _tbRemote;
196:            }
197:
198:            /** Tries to find Refresh Diff JButton in diff view.
199:             * @return JButtonOperator
200:             */
201:            public JButtonOperator btRefresh() {
202:                if (_btRefresh == null) {
203:                    _btRefresh = new JButtonOperator(
204:                            this ,
205:                            new TooltipChooser(
206:                                    Bundle
207:                                            .getString(
208:                                                    "org.netbeans.modules.versioning.system.cvss.ui.actions.diff.Bundle",
209:                                                    "MSG_RefreshDiff_Tooltip"),
210:                                    this .getComparator()));
211:                }
212:                return _btRefresh;
213:            }
214:
215:            /** Tries to find Update JButton in diff view.
216:             * @return JButtonOperator
217:             */
218:            public JButtonOperator btUpdate() {
219:                if (_btUpdate == null) {
220:                    _btUpdate = new JButtonOperator(
221:                            this ,
222:                            new TooltipChooser(
223:                                    Bundle
224:                                            .getStringTrimmed(
225:                                                    "org.netbeans.modules.versioning.system.cvss.ui.actions.diff.Bundle",
226:                                                    "MSG_UpdateDiff_Tooltip"),
227:                                    this .getComparator()));
228:                }
229:                return _btUpdate;
230:            }
231:
232:            /** Tries to find Commit JButton in diff view.
233:             * @return JButtonOperator
234:             */
235:            public JButtonOperator btCommit() {
236:                if (_btCommit == null) {
237:                    _btCommit = new JButtonOperator(
238:                            this ,
239:                            new TooltipChooser(
240:                                    Bundle
241:                                            .getStringTrimmed(
242:                                                    "org.netbeans.modules.versioning.system.cvss.ui.actions.diff.Bundle",
243:                                                    "MSG_CommitDiff_Tooltip"),
244:                                    this .getComparator()));
245:                }
246:                return _btCommit;
247:            }
248:
249:            /** Tries to find files JComboBoxOperator in diff view.
250:             * @return JComboBoxOperator
251:             */
252:            public JComboBoxOperator cbFiles() {
253:                if (_cbFiles == null) {
254:                    _cbFiles = new JComboBoxOperator(this );
255:                }
256:                return _cbFiles;
257:            }
258:
259:            //****************************************
260:            // Low-level functionality definition part
261:            //****************************************
262:
263:            /** clicks on Go to Next Difference JButton
264:             */
265:            public void next() {
266:                btNext().push();
267:            }
268:
269:            /** clicks on Go to Previous Difference JButton
270:             */
271:            public void previous() {
272:                btPrevious().push();
273:            }
274:
275:            /** checks or unchecks given JToggleButton
276:             * @param state boolean requested state
277:             */
278:            public void checkRemoteLocal(boolean state) {
279:                if (tbRemoteLocal().isSelected() != state) {
280:                    tbRemoteLocal().push();
281:                }
282:            }
283:
284:            /** checks or unchecks given JToggleButton
285:             * @param state boolean requested state
286:             */
287:            public void checkLocal(boolean state) {
288:                if (tbLocal().isSelected() != state) {
289:                    tbLocal().push();
290:                }
291:            }
292:
293:            /** checks or unchecks given JToggleButton
294:             * @param state boolean requested state
295:             */
296:            public void checkRemote(boolean state) {
297:                if (tbRemote().isSelected() != state) {
298:                    tbRemote().push();
299:                }
300:            }
301:
302:            /** clicks on Refresh Diff JButton
303:             */
304:            public void refresh() {
305:                btRefresh().push();
306:            }
307:
308:            /** clicks on Update JButton
309:             */
310:            public void update() {
311:                btUpdate().push();
312:            }
313:
314:            /** clicks on Commit JButton and returns CommitOperator.
315:             * @return CommitOperator instance
316:             */
317:            public CommitOperator commit() {
318:                btCommit().pushNoBlock();
319:                return new CommitOperator();
320:            }
321:
322:            /** Selects specified file in combo box.
323:             * @param name file name to be selected
324:             */
325:            public void selectFile(String name) {
326:                cbFiles().selectItem(name);
327:            }
328:
329:            /** Selects index-th file in combo box.
330:             * @param index index of file to be selected
331:             */
332:            public void selectFile(int index) {
333:                cbFiles().selectItem(index);
334:            }
335:
336:            //*****************************************
337:            // High-level functionality definition part
338:            //*****************************************
339:
340:            /** Performs verification of VersioningOperator by accessing all its components.
341:             */
342:            public void verify() {
343:                btNext();
344:                btPrevious();
345:                tbRemoteLocal();
346:                tbLocal();
347:                tbRemote();
348:                btRefresh();
349:                btUpdate();
350:                btCommit();
351:                cbFiles();
352:            }
353:
354:            /** SubChooser to determine TopComponent is instance of
355:             * org.netbeans.modules.versioning.system.cvss.ui.actions.diff.DiffExecutor$DiffTopComponent
356:             * Used in constructor.
357:             */
358:            private static final class DiffSubchooser implements 
359:                    ComponentChooser {
360:                public boolean checkComponent(Component comp) {
361:                    return comp.getClass().getName().endsWith(
362:                            "DiffTopComponent"); // NOI18N
363:                }
364:
365:                public String getDescription() {
366:                    return "org.netbeans.modules.versioning.system.cvss.ui.actions.diff.DiffExecutor$DiffTopComponent"; // NOI18N
367:                }
368:            }
369:
370:            /** Chooser which can be used to find a component with given tooltip,
371:             * for example a button.
372:             */
373:            private static class TooltipChooser implements  ComponentChooser {
374:                private String buttonTooltip;
375:                private StringComparator comparator;
376:
377:                public TooltipChooser(String buttonTooltip,
378:                        StringComparator comparator) {
379:                    this .buttonTooltip = buttonTooltip;
380:                    this .comparator = comparator;
381:                }
382:
383:                public boolean checkComponent(Component comp) {
384:                    return comparator.equals(((JComponent) comp)
385:                            .getToolTipText(), buttonTooltip);
386:                }
387:
388:                public String getDescription() {
389:                    return "Button with tooltip \"" + buttonTooltip + "\".";
390:                }
391:            }
392:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.