Source Code Cross Referenced for PartTester.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » 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 Eclipse » ui workbench » org.eclipse.ui.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal;
011:
012:        import org.eclipse.core.runtime.Assert;
013:        import org.eclipse.ui.IEditorInput;
014:        import org.eclipse.ui.IEditorPart;
015:        import org.eclipse.ui.IPersistableElement;
016:        import org.eclipse.ui.IPropertyListener;
017:        import org.eclipse.ui.IViewPart;
018:        import org.eclipse.ui.IWorkbenchPart;
019:        import org.eclipse.ui.IWorkbenchPart2;
020:
021:        public class PartTester {
022:            private PartTester() {
023:            }
024:
025:            /**
026:             * Sanity-check the public interface of the editor. This is called on every editor after it
027:             * is fully initiallized, but before it is actually connected to the editor reference or the
028:             * layout. Calls as much of the editor's public interface as possible to test for exceptions,
029:             * and tests the return values for glaring faults. This does not need to be an exhaustive conformance
030:             * test, as it is called every time an editor is opened and it needs to be efficient.
031:             * The part should be unmodified when the method exits. 
032:             *
033:             * @param part
034:             */
035:            public static void testEditor(IEditorPart part) throws Exception {
036:                testWorkbenchPart(part);
037:
038:                Assert
039:                        .isTrue(part.getEditorSite() == part.getSite(),
040:                                "The part's editor site must be the same as the part's site"); //$NON-NLS-1$
041:                IEditorInput input = part.getEditorInput();
042:                Assert.isNotNull(input, "The editor input must be non-null"); //$NON-NLS-1$
043:                testEditorInput(input);
044:
045:                part.isDirty();
046:                part.isSaveAsAllowed();
047:                part.isSaveOnCloseNeeded();
048:            }
049:
050:            public static void testEditorInput(IEditorInput input)
051:                    throws Exception {
052:                input.getAdapter(Object.class);
053:
054:                // Don't test input.getImageDescriptor() -- the workbench never uses that
055:                // method and most editor inputs would fail the test. It should really be
056:                // deprecated.
057:
058:                Assert.isNotNull(input.getName(),
059:                        "The editor input must have a non-null name"); //$NON-NLS-1$
060:                Assert.isNotNull(input.getToolTipText(),
061:                        "The editor input must have a non-null tool tip"); //$NON-NLS-1$
062:
063:                // Persistable element may be null
064:                IPersistableElement persistableElement = input.getPersistable();
065:                if (persistableElement != null) {
066:                    Assert
067:                            .isNotNull(persistableElement.getFactoryId(),
068:                                    "The persistable element for the editor input must have a non-null factory id"); //$NON-NLS-1$
069:                }
070:            }
071:
072:            /**
073:             * Sanity-checks a workbench part. Excercises the public interface and tests for any
074:             * obviously bogus return values. The part should be unmodified when the method exits.
075:             *
076:             * @param part
077:             * @throws Exception
078:             */
079:            private static void testWorkbenchPart(IWorkbenchPart part)
080:                    throws Exception {
081:                IPropertyListener testListener = new IPropertyListener() {
082:                    public void propertyChanged(Object source, int propId) {
083:
084:                    }
085:                };
086:
087:                // Test addPropertyListener
088:                part.addPropertyListener(testListener);
089:
090:                // Test removePropertyListener
091:                part.removePropertyListener(testListener);
092:
093:                // Test equals
094:                Assert.isTrue(part.equals(part),
095:                        "A part must be equal to itself"); //$NON-NLS-1$
096:                Assert.isTrue(!part.equals(new Integer(32)),
097:                        "A part must have a meaningful equals method"); //$NON-NLS-1$
098:
099:                // Test getAdapter   
100:                Object partAdapter = part.getAdapter(part.getClass());
101:                Assert.isTrue(partAdapter == null || partAdapter == part,
102:                        "A part must adapter to itself or return null"); //$NON-NLS-1$
103:
104:                // Test getTitle
105:                Assert.isNotNull(part.getTitle(),
106:                        "A part's title must be non-null"); //$NON-NLS-1$
107:
108:                // Test getTitleImage
109:                Assert.isNotNull(part.getTitleImage(),
110:                        "A part's title image must be non-null"); //$NON-NLS-1$
111:
112:                // Test getTitleToolTip
113:                Assert.isNotNull(part.getTitleToolTip(),
114:                        "A part's title tool tip must be non-null"); //$NON-NLS-1$
115:
116:                // Test toString
117:                Assert
118:                        .isNotNull(part.toString(),
119:                                "A part's toString method must return a non-null value"); //$NON-NLS-1$
120:
121:                // Compute hashCode
122:                part.hashCode();
123:
124:                if (part instanceof  IWorkbenchPart2) {
125:                    testWorkbenchPart2((IWorkbenchPart2) part);
126:                }
127:            }
128:
129:            private static void testWorkbenchPart2(IWorkbenchPart2 part)
130:                    throws Exception {
131:                Assert.isNotNull(part.getContentDescription(),
132:                        "A part must return a non-null content description"); //$NON-NLS-1$
133:                Assert.isNotNull(part.getPartName(),
134:                        "A part must return a non-null part name"); //$NON-NLS-1$
135:            }
136:
137:            /**
138:             * Sanity-check the public interface of a view. This is called on every view after it
139:             * is fully initiallized, but before it is actually connected to the part reference or the
140:             * layout. Calls as much of the part's public interface as possible without modifying the part 
141:             * to test for exceptions and check the return values for glaring faults. This does not need 
142:             * to be an exhaustive conformance test, as it is called every time an editor is opened and 
143:             * it needs to be efficient. 
144:             *
145:             * @param part
146:             */
147:            public static void testView(IViewPart part) throws Exception {
148:                Assert.isTrue(part.getSite() == part.getViewSite(),
149:                        "A part's site must be the same as a part's view site"); //$NON-NLS-1$
150:                testWorkbenchPart(part);
151:            }
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.