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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 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.texteditor.quickdiff;
011:
012:        import java.util.Collections;
013:        import java.util.Iterator;
014:        import java.util.List;
015:        import java.util.ListIterator;
016:
017:        import org.eclipse.core.runtime.Assert;
018:
019:        import org.eclipse.jface.text.source.IAnnotationModel;
020:
021:        import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
022:        import org.eclipse.ui.internal.texteditor.quickdiff.DocumentLineDiffer;
023:        import org.eclipse.ui.internal.texteditor.quickdiff.QuickDiffExtensionsRegistry;
024:        import org.eclipse.ui.texteditor.ITextEditor;
025:
026:        /**
027:         * Access class for the quick diff reference provider extension point.
028:         * <p>
029:         * This class may be instantiated, it is not intended to be subclassed.
030:         * </p>
031:         * @since 3.0
032:         */
033:        public class QuickDiff {
034:
035:            /**
036:             * Creates a new instance.
037:             */
038:            public QuickDiff() {
039:            }
040:
041:            /**
042:             * Returns the descriptor of the "last saved version" reference provider.
043:             * <p>
044:             * Clients should not cache this value because it can change when plug-ins get dynamically added or removed.
045:             * </p>
046:             *
047:             * @return the descriptor of "last saved version" reference provider or <code>null</code> if none
048:             */
049:            public ReferenceProviderDescriptor getDefaultProvider() {
050:                QuickDiffExtensionsRegistry registry = TextEditorPlugin
051:                        .getDefault().getQuickDiffExtensionRegistry();
052:                if (registry != null)
053:                    return registry.getDefaultProvider();
054:
055:                return null;
056:            }
057:
058:            /**
059:             * Returns a non-modifiable list of <code>ReferenceProviderDescriptor</code> describing all extension
060:             * to the <code>quickDiffReferenceProvider</code> extension point.
061:             * <p>
062:             * Clients should not cache this list because it can change when plug-ins get dynamically added or removed.
063:             * </p>
064:             *
065:             * @return the non-modifiable list of extensions to the <code>quickDiffReferenceProvider</code> extension point.
066:             */
067:            public List getReferenceProviderDescriptors() {
068:                QuickDiffExtensionsRegistry registry = TextEditorPlugin
069:                        .getDefault().getQuickDiffExtensionRegistry();
070:                if (registry != null)
071:                    return registry.getReferenceProviderDescriptors();
072:
073:                return Collections.EMPTY_LIST;
074:            }
075:
076:            /**
077:             * Returns the quick diff reference provider registered under <code>id</code>, or the default
078:             * reference provider. The returned provider gets its editor set to <code>editor</code>. If neither
079:             * the requested provider nor the default provider return <code>true</code> from <code>isEnabled</code> after
080:             * having the editor set, <code>null</code> is returned.
081:             * <p>
082:             * Clients should not cache this value because it can change when plug-ins get dynamically added or removed.
083:             * </p>
084:             *
085:             * @param editor the editor to be installed with the returned provider
086:             * @param id the id as specified in the <code>plugin.xml</code> that installs the reference provider
087:             * @return the reference provider registered under <code>id</code>, or the default reference provider, or <code>null</code>
088:             */
089:            public IQuickDiffReferenceProvider getReferenceProviderOrDefault(
090:                    ITextEditor editor, String id) {
091:                Assert.isNotNull(editor);
092:                Assert.isNotNull(id);
093:
094:                List descs = getReferenceProviderDescriptors();
095:                // try to fetch preferred provider; load if needed
096:                for (Iterator iter = descs.iterator(); iter.hasNext();) {
097:                    ReferenceProviderDescriptor desc = (ReferenceProviderDescriptor) iter
098:                            .next();
099:                    if (desc.getId().equals(id)) {
100:                        IQuickDiffReferenceProvider provider = desc
101:                                .createProvider();
102:                        if (provider != null) {
103:                            provider.setActiveEditor(editor);
104:                            if (provider.isEnabled())
105:                                return provider;
106:                            provider.dispose();
107:                            provider = null;
108:                        }
109:                    }
110:                }
111:
112:                for (ListIterator iter = descs.listIterator(descs.size()); iter
113:                        .hasPrevious();) {
114:                    ReferenceProviderDescriptor desc = (ReferenceProviderDescriptor) iter
115:                            .previous();
116:                    IQuickDiffReferenceProvider provider = desc
117:                            .createProvider();
118:                    if (provider != null) {
119:                        provider.setActiveEditor(editor);
120:                        if (provider.isEnabled())
121:                            return provider;
122:                        provider.dispose();
123:                        provider = null;
124:                    }
125:                }
126:
127:                return null;
128:            }
129:
130:            /**
131:             * Creates a new line differ annotation model with its reference provider set to the reference provider
132:             * obtained by calling <code>getReferenceProviderOrDefault(editor, id)</code>.
133:             *
134:             * @param editor the editor to be installed with the returned provider
135:             * @param id the id as specified in the <code>plugin.xml</code> that installs the reference provider
136:             * @return a quick diff annotation model
137:             */
138:            public IAnnotationModel createQuickDiffAnnotationModel(
139:                    ITextEditor editor, String id) {
140:                IQuickDiffReferenceProvider provider = getReferenceProviderOrDefault(
141:                        editor, id);
142:                if (provider != null) {
143:                    DocumentLineDiffer differ = new DocumentLineDiffer();
144:                    differ.setReferenceProvider(provider);
145:                    return differ;
146:                }
147:                return null;
148:            }
149:
150:            /**
151:             * Returns the identifier of the quick diff provider installed with the given diff annotation
152:             * model, or the empty string if it is not a diff annotation model or has no configured diff
153:             * provider.
154:             * 
155:             * @param differ a diff annotation model
156:             * @return the reference provider id, or the empty string for none
157:             * @since 3.2
158:             */
159:            public Object getConfiguredQuickDiffProvider(IAnnotationModel differ) {
160:                if (differ instanceof  DocumentLineDiffer) {
161:                    DocumentLineDiffer lineDiffer = (DocumentLineDiffer) differ;
162:                    IQuickDiffReferenceProvider provider = lineDiffer
163:                            .getReferenceProvider();
164:                    if (provider != null)
165:                        return provider.getId();
166:                }
167:                return ""; //$NON-NLS-1$
168:            }
169:
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.