Source Code Cross Referenced for MockPluginView.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » ui » tests » model » 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 » jdt » org.eclipse.jdt.ui.tests.model 
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.jdt.ui.tests.model;
011:
012:        import java.io.ByteArrayInputStream;
013:        import java.io.InputStream;
014:
015:        import org.eclipse.core.runtime.CoreException;
016:        import org.eclipse.core.runtime.IPath;
017:        import org.eclipse.core.runtime.IProgressMonitor;
018:        import org.eclipse.core.runtime.NullProgressMonitor;
019:
020:        import org.eclipse.core.resources.IProject;
021:        import org.eclipse.core.resources.IResource;
022:        import org.eclipse.core.resources.IStorage;
023:        import org.eclipse.core.resources.mapping.ResourceMapping;
024:        import org.eclipse.core.resources.mapping.ResourceMappingContext;
025:        import org.eclipse.core.resources.mapping.ResourceTraversal;
026:
027:        import org.eclipse.swt.SWT;
028:        import org.eclipse.swt.widgets.Composite;
029:
030:        import org.eclipse.jface.viewers.ITreeContentProvider;
031:
032:        import org.eclipse.ui.navigator.CommonViewer;
033:        import org.eclipse.ui.navigator.INavigatorContentExtension;
034:        import org.eclipse.ui.navigator.INavigatorContentServiceListener;
035:        import org.eclipse.ui.part.ViewPart;
036:
037:        import org.eclipse.team.core.diff.IDiff;
038:        import org.eclipse.team.core.diff.provider.ThreeWayDiff;
039:        import org.eclipse.team.core.history.IFileRevision;
040:        import org.eclipse.team.core.history.provider.FileRevision;
041:        import org.eclipse.team.core.mapping.ISynchronizationContext;
042:        import org.eclipse.team.core.mapping.provider.ResourceDiff;
043:        import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
044:        import org.eclipse.team.core.mapping.provider.SynchronizationContext;
045:        import org.eclipse.team.core.mapping.provider.SynchronizationScopeManager;
046:
047:        import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
048:
049:        import org.eclipse.jdt.core.IJavaProject;
050:
051:        public class MockPluginView extends ViewPart implements 
052:                INavigatorContentServiceListener {
053:
054:            private static final String VIEWER_ID = "org.eclipse.jdt.tests.ui.model.mockViewer";
055:            private static final String JAVA_CONTENT_PROVIDER_ID = "org.eclipse.jdt.ui.javaModelContent";
056:
057:            private CommonViewer fViewer;
058:            private INavigatorContentExtension fExtension;
059:            private ISynchronizationContext fContext;
060:
061:            public MockPluginView() {
062:                // Nothing to do
063:            }
064:
065:            public void createPartControl(Composite parent) {
066:                fViewer = new CommonViewer(VIEWER_ID, parent, SWT.MULTI
067:                        | SWT.H_SCROLL | SWT.V_SCROLL);
068:                // Only enable the Java model content
069:                fViewer.getNavigatorContentService().bindExtensions(
070:                        new String[] { JAVA_CONTENT_PROVIDER_ID }, true);
071:                fViewer
072:                        .getNavigatorContentService()
073:                        .getActivationService()
074:                        .activateExtensions(
075:                                new String[] { JAVA_CONTENT_PROVIDER_ID }, true);
076:                fViewer.getNavigatorContentService().addListener(this );
077:                if (fContext != null)
078:                    setInput(fContext);
079:            }
080:
081:            public void setFocus() {
082:                // Nothing to do
083:            }
084:
085:            public void setInput(Object input) {
086:                fViewer.setInput(input);
087:            }
088:
089:            public ITreeContentProvider getContentProvider() {
090:                return (ITreeContentProvider) fViewer.getContentProvider();
091:            }
092:
093:            public void onLoad(INavigatorContentExtension anExtension) {
094:                this .fExtension = anExtension;
095:                setContext(fContext);
096:            }
097:
098:            public void setProject(IJavaProject project) throws CoreException {
099:                ISynchronizationContext context = createContext(project);
100:                setContext(context);
101:            }
102:
103:            private void setContext(ISynchronizationContext context) {
104:                if (fContext != context) {
105:                    if (fContext != null) {
106:                        fContext.dispose();
107:                    }
108:                    fContext = context;
109:                }
110:                if (fExtension != null) {
111:                    fExtension
112:                            .getStateModel()
113:                            .setProperty(
114:                                    ITeamContentProviderManager.P_SYNCHRONIZATION_SCOPE,
115:                                    context.getScope());
116:                    fExtension
117:                            .getStateModel()
118:                            .setProperty(
119:                                    ITeamContentProviderManager.P_SYNCHRONIZATION_CONTEXT,
120:                                    context);
121:                }
122:                setInput(fContext);
123:            }
124:
125:            public void dispose() {
126:                super .dispose();
127:                if (fContext != null) {
128:                    fContext.dispose();
129:                }
130:            }
131:
132:            private ISynchronizationContext createContext(IJavaProject project)
133:                    throws CoreException {
134:                ResourceDiffTree tree = new ResourceDiffTree();
135:                SynchronizationScopeManager manager = new SynchronizationScopeManager(
136:                        "Java Model Tests", getResourceMappings(project),
137:                        ResourceMappingContext.LOCAL_CONTEXT, true);
138:                manager.initialize(new NullProgressMonitor());
139:                SynchronizationContext context = new SynchronizationContext(
140:                        manager, ISynchronizationContext.THREE_WAY, tree) {
141:                    public void refresh(ResourceTraversal[] traversals,
142:                            int flags, IProgressMonitor monitor)
143:                            throws CoreException {
144:                        // Nothing to do
145:                    }
146:                };
147:                return context;
148:            }
149:
150:            private ResourceMapping[] getResourceMappings(IJavaProject project) {
151:                ResourceMapping mapping = (ResourceMapping) project
152:                        .getResource().getAdapter(ResourceMapping.class);
153:                return new ResourceMapping[] { mapping };
154:            }
155:
156:            private IResource getResource(IProject project, String path) {
157:                if (path.endsWith("/"))
158:                    return project.getFolder(path);
159:                return project.getFile(path);
160:            }
161:
162:            public IDiff createOutgoingDeletion(IProject project, String path) {
163:                final IResource resource = getResource(project, path);
164:                ResourceDiff diff = new ResourceDiff(resource, IDiff.REMOVE, 0,
165:                        new FileRevision() {
166:                            public String getName() {
167:                                return resource.getName();
168:                            }
169:
170:                            public IStorage getStorage(IProgressMonitor monitor)
171:                                    throws CoreException {
172:                                return new IStorage() {
173:                                    public Object getAdapter(Class adapter) {
174:                                        return null;
175:                                    }
176:
177:                                    public boolean isReadOnly() {
178:                                        return true;
179:                                    }
180:
181:                                    public String getName() {
182:                                        return resource.getName();
183:                                    }
184:
185:                                    public IPath getFullPath() {
186:                                        return resource.getFullPath();
187:                                    }
188:
189:                                    public InputStream getContents()
190:                                            throws CoreException {
191:                                        return new ByteArrayInputStream(""
192:                                                .getBytes());
193:                                    }
194:                                };
195:                            }
196:
197:                            public boolean isPropertyMissing() {
198:                                return false;
199:                            }
200:
201:                            public IFileRevision withAllProperties(
202:                                    IProgressMonitor monitor)
203:                                    throws CoreException {
204:                                return this ;
205:                            }
206:                        }, null);
207:                return new ThreeWayDiff(diff, null);
208:            }
209:
210:            public void addOutgoingDeletion(IProject project, String path) {
211:                IDiff diff = createOutgoingDeletion(project, path);
212:                add(diff);
213:            }
214:
215:            public void addIncomingAddition(IProject project, String path) {
216:                IDiff diff = createIncomingAddition(project, path);
217:                add(diff);
218:            }
219:
220:            private IDiff createIncomingAddition(IProject project, String path) {
221:                final IResource resource = getResource(project, path);
222:                ResourceDiff diff = new ResourceDiff(resource, IDiff.ADD, 0,
223:                        new FileRevision() {
224:                            public String getName() {
225:                                return resource.getName();
226:                            }
227:
228:                            public IStorage getStorage(IProgressMonitor monitor)
229:                                    throws CoreException {
230:                                return new IStorage() {
231:                                    public Object getAdapter(Class adapter) {
232:                                        return null;
233:                                    }
234:
235:                                    public boolean isReadOnly() {
236:                                        return true;
237:                                    }
238:
239:                                    public String getName() {
240:                                        return resource.getName();
241:                                    }
242:
243:                                    public IPath getFullPath() {
244:                                        return resource.getFullPath();
245:                                    }
246:
247:                                    public InputStream getContents()
248:                                            throws CoreException {
249:                                        return new ByteArrayInputStream(""
250:                                                .getBytes());
251:                                    }
252:                                };
253:                            }
254:
255:                            public boolean isPropertyMissing() {
256:                                return false;
257:                            }
258:
259:                            public IFileRevision withAllProperties(
260:                                    IProgressMonitor monitor)
261:                                    throws CoreException {
262:                                return this ;
263:                            }
264:                        }, null);
265:                return new ThreeWayDiff(null, diff);
266:            }
267:
268:            private void add(IDiff diff) {
269:                ((ResourceDiffTree) fContext.getDiffTree()).add(diff);
270:            }
271:
272:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.