Source Code Cross Referenced for ChangeAwareSourceViewerConfiguration.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » editor » text » 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 » Eclipse plug in development » org.eclipse.pde.internal.ui.editor.text 
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.pde.internal.ui.editor.text;
011:
012:        import org.eclipse.jface.preference.IPreferenceStore;
013:        import org.eclipse.jface.text.AbstractInformationControlManager;
014:        import org.eclipse.jface.text.DefaultInformationControl;
015:        import org.eclipse.jface.text.IInformationControl;
016:        import org.eclipse.jface.text.IInformationControlCreator;
017:        import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
018:        import org.eclipse.jface.text.information.IInformationPresenter;
019:        import org.eclipse.jface.text.information.IInformationProvider;
020:        import org.eclipse.jface.text.information.InformationPresenter;
021:        import org.eclipse.jface.text.reconciler.IReconciler;
022:        import org.eclipse.jface.text.reconciler.MonoReconciler;
023:        import org.eclipse.jface.text.source.ISourceViewer;
024:        import org.eclipse.jface.util.PropertyChangeEvent;
025:        import org.eclipse.pde.core.IBaseModel;
026:        import org.eclipse.pde.internal.core.text.IReconcilingParticipant;
027:        import org.eclipse.pde.internal.ui.PDEPlugin;
028:        import org.eclipse.pde.internal.ui.editor.ISortableContentOutlinePage;
029:        import org.eclipse.pde.internal.ui.editor.PDESourcePage;
030:        import org.eclipse.pde.internal.ui.editor.actions.PDEActionConstants;
031:        import org.eclipse.pde.internal.ui.editor.contentassist.display.HTMLTextPresenter;
032:        import org.eclipse.pde.internal.ui.editor.outline.QuickOutlinePopupDialog;
033:        import org.eclipse.swt.SWT;
034:        import org.eclipse.swt.widgets.Shell;
035:        import org.eclipse.ui.editors.text.EditorsUI;
036:        import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
037:        import org.eclipse.ui.texteditor.ChainedPreferenceStore;
038:
039:        public abstract class ChangeAwareSourceViewerConfiguration extends
040:                TextSourceViewerConfiguration {
041:
042:            protected PDESourcePage fSourcePage;
043:            protected IColorManager fColorManager;
044:            private MonoReconciler fReconciler;
045:            private InformationPresenter fInfoPresenter;
046:            private InformationPresenter fOutlinePresenter;
047:
048:            /**
049:             * @param page
050:             * @param manager - an IColorManager, clients must dispose this themselves.
051:             * @param store
052:             */
053:            public ChangeAwareSourceViewerConfiguration(PDESourcePage page,
054:                    IColorManager manager, IPreferenceStore store) {
055:                super (store);
056:                fColorManager = manager;
057:                fSourcePage = page;
058:            }
059:
060:            public ChangeAwareSourceViewerConfiguration(PDESourcePage page,
061:                    IColorManager manager) {
062:                this (page, manager, new ChainedPreferenceStore(
063:                        new IPreferenceStore[] {
064:                                PDEPlugin.getDefault().getPreferenceStore(),
065:                                EditorsUI.getPreferenceStore() // general text editor store
066:                        }));
067:            }
068:
069:            public IReconciler getReconciler(ISourceViewer sourceViewer) {
070:                if (fSourcePage != null && fReconciler == null) {
071:                    IBaseModel model = fSourcePage.getInputContext().getModel();
072:                    if (model instanceof  IReconcilingParticipant) {
073:                        ReconcilingStrategy strategy = new ReconcilingStrategy();
074:                        strategy
075:                                .addParticipant((IReconcilingParticipant) model);
076:                        ISortableContentOutlinePage outline = fSourcePage
077:                                .getContentOutline();
078:                        if (outline instanceof  IReconcilingParticipant)
079:                            strategy
080:                                    .addParticipant((IReconcilingParticipant) outline);
081:                        fReconciler = new MonoReconciler(strategy, false);
082:                        fReconciler.setDelay(500);
083:                    }
084:                }
085:                return fReconciler;
086:            }
087:
088:            public IInformationPresenter getInformationPresenter(
089:                    ISourceViewer sourceViewer) {
090:                if (fSourcePage == null)
091:                    return null;
092:                if (fInfoPresenter == null
093:                        && getInfoImplementationType() != SourceInformationProvider.F_NO_IMP) {
094:                    IInformationControlCreator icc = getInformationControlCreator(false);
095:                    fInfoPresenter = new InformationPresenter(icc);
096:                    fInfoPresenter
097:                            .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
098:
099:                    // Register information provider
100:                    IInformationProvider provider = new SourceInformationProvider(
101:                            fSourcePage, icc, getInfoImplementationType());
102:                    String[] contentTypes = getConfiguredContentTypes(sourceViewer);
103:                    for (int i = 0; i < contentTypes.length; i++)
104:                        fInfoPresenter.setInformationProvider(provider,
105:                                contentTypes[i]);
106:
107:                    fInfoPresenter.setSizeConstraints(60, 10, true, true);
108:                }
109:                return fInfoPresenter;
110:            }
111:
112:            /**
113:             * @param sourceViewer
114:             * @return
115:             */
116:            public IInformationPresenter getOutlinePresenter(
117:                    ISourceViewer sourceViewer) {
118:                // Ensure the source page is defined
119:                if (fSourcePage == null) {
120:                    return null;
121:                }
122:                // Reuse the old outline presenter
123:                if (fOutlinePresenter != null) {
124:                    return fOutlinePresenter;
125:                }
126:                // Define a new outline presenter
127:                fOutlinePresenter = new InformationPresenter(
128:                        getOutlinePresenterControlCreator(sourceViewer,
129:                                PDEActionConstants.COMMAND_ID_QUICK_OUTLINE));
130:                fOutlinePresenter
131:                        .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
132:                fOutlinePresenter
133:                        .setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
134:                // Define a new outline provider
135:                IInformationProvider provider = new PDESourceInfoProvider(
136:                        fSourcePage);
137:                // Set the provider on all defined content types
138:                String[] contentTypes = getConfiguredContentTypes(sourceViewer);
139:                for (int i = 0; i < contentTypes.length; i++) {
140:                    fOutlinePresenter.setInformationProvider(provider,
141:                            contentTypes[i]);
142:                }
143:                // Set the presenter size constraints
144:                fOutlinePresenter.setSizeConstraints(50, 20, true, false);
145:
146:                return fOutlinePresenter;
147:            }
148:
149:            /**
150:             * Returns the outline presenter control creator. The creator is a 
151:             * factory creating outline presenter controls for the given source viewer. 
152:             *
153:             * @param sourceViewer the source viewer to be configured by this configuration
154:             * @param commandId the ID of the command that opens this control
155:             * @return an information control creator
156:             */
157:            private IInformationControlCreator getOutlinePresenterControlCreator(
158:                    ISourceViewer sourceViewer, final String commandId) {
159:                return new IInformationControlCreator() {
160:                    public IInformationControl createInformationControl(
161:                            Shell parent) {
162:                        int shellStyle = SWT.RESIZE;
163:                        QuickOutlinePopupDialog dialog = new QuickOutlinePopupDialog(
164:                                parent, shellStyle, fSourcePage, fSourcePage);
165:                        return dialog;
166:                    }
167:                };
168:            }
169:
170:            protected int getInfoImplementationType() {
171:                return SourceInformationProvider.F_NO_IMP;
172:            }
173:
174:            protected IInformationControlCreator getInformationControlCreator(
175:                    final boolean cutDown) {
176:                return new IInformationControlCreator() {
177:                    public IInformationControl createInformationControl(
178:                            Shell parent) {
179:                        int style = cutDown ? SWT.RESIZE : (SWT.V_SCROLL
180:                                | SWT.H_SCROLL | SWT.RESIZE);
181:                        return new DefaultInformationControl(parent, style,
182:                                new HTMLTextPresenter(cutDown));
183:                    }
184:                };
185:            }
186:
187:            public IHyperlinkDetector[] getHyperlinkDetectors(
188:                    ISourceViewer sourceViewer) {
189:                if (fSourcePage != null)
190:                    return new IHyperlinkDetector[] { (IHyperlinkDetector) fSourcePage
191:                            .getAdapter(IHyperlinkDetector.class) };
192:                return super .getHyperlinkDetectors(sourceViewer);
193:            }
194:
195:            public abstract boolean affectsTextPresentation(
196:                    PropertyChangeEvent event);
197:
198:            public abstract boolean affectsColorPresentation(
199:                    PropertyChangeEvent event);
200:
201:            public abstract void adaptToPreferenceChange(
202:                    PropertyChangeEvent event);
203:
204:            public abstract void dispose();
205:
206:        }
ww___w_.___j__a__v___a2___s._co__m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.