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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 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.examples.javaeditor;
011:
012:        import org.eclipse.swt.graphics.RGB;
013:
014:        import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
015:        import org.eclipse.jface.text.IAutoEditStrategy;
016:        import org.eclipse.jface.text.IDocument;
017:        import org.eclipse.jface.text.ITextDoubleClickStrategy;
018:        import org.eclipse.jface.text.ITextHover;
019:        import org.eclipse.jface.text.TextAttribute;
020:        import org.eclipse.jface.text.contentassist.ContentAssistant;
021:        import org.eclipse.jface.text.contentassist.IContentAssistant;
022:        import org.eclipse.jface.text.presentation.IPresentationReconciler;
023:        import org.eclipse.jface.text.presentation.PresentationReconciler;
024:        import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
025:        import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
026:        import org.eclipse.jface.text.rules.Token;
027:        import org.eclipse.jface.text.source.IAnnotationHover;
028:        import org.eclipse.jface.text.source.ISourceViewer;
029:        import org.eclipse.jface.text.source.SourceViewerConfiguration;
030:
031:        import org.eclipse.ui.examples.javaeditor.java.JavaAutoIndentStrategy;
032:        import org.eclipse.ui.examples.javaeditor.java.JavaCompletionProcessor;
033:        import org.eclipse.ui.examples.javaeditor.java.JavaDoubleClickSelector;
034:        import org.eclipse.ui.examples.javaeditor.javadoc.JavaDocCompletionProcessor;
035:        import org.eclipse.ui.examples.javaeditor.util.JavaColorProvider;
036:
037:        /**
038:         * Example configuration for an <code>SourceViewer</code> which shows Java code.
039:         */
040:        public class JavaSourceViewerConfiguration extends
041:                SourceViewerConfiguration {
042:
043:            /**
044:             * Single token scanner.
045:             */
046:            static class SingleTokenScanner extends BufferedRuleBasedScanner {
047:                public SingleTokenScanner(TextAttribute attribute) {
048:                    setDefaultReturnToken(new Token(attribute));
049:                }
050:            }
051:
052:            /**
053:             * Default constructor.
054:             */
055:            public JavaSourceViewerConfiguration() {
056:            }
057:
058:            /* (non-Javadoc)
059:             * Method declared on SourceViewerConfiguration
060:             */
061:            public IAnnotationHover getAnnotationHover(
062:                    ISourceViewer sourceViewer) {
063:                return new JavaAnnotationHover();
064:            }
065:
066:            /*
067:             * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAutoEditStrategies(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
068:             */
069:            public IAutoEditStrategy[] getAutoEditStrategies(
070:                    ISourceViewer sourceViewer, String contentType) {
071:                IAutoEditStrategy strategy = (IDocument.DEFAULT_CONTENT_TYPE
072:                        .equals(contentType) ? new JavaAutoIndentStrategy()
073:                        : new DefaultIndentLineAutoEditStrategy());
074:                return new IAutoEditStrategy[] { strategy };
075:            }
076:
077:            /*
078:             * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
079:             */
080:            public String getConfiguredDocumentPartitioning(
081:                    ISourceViewer sourceViewer) {
082:                return JavaEditorExamplePlugin.JAVA_PARTITIONING;
083:            }
084:
085:            /* (non-Javadoc)
086:             * Method declared on SourceViewerConfiguration
087:             */
088:            public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
089:                return new String[] { IDocument.DEFAULT_CONTENT_TYPE,
090:                        JavaPartitionScanner.JAVA_DOC,
091:                        JavaPartitionScanner.JAVA_MULTILINE_COMMENT };
092:            }
093:
094:            /* (non-Javadoc)
095:             * Method declared on SourceViewerConfiguration
096:             */
097:            public IContentAssistant getContentAssistant(
098:                    ISourceViewer sourceViewer) {
099:
100:                ContentAssistant assistant = new ContentAssistant();
101:                assistant
102:                        .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
103:                assistant.setContentAssistProcessor(
104:                        new JavaCompletionProcessor(),
105:                        IDocument.DEFAULT_CONTENT_TYPE);
106:                assistant.setContentAssistProcessor(
107:                        new JavaDocCompletionProcessor(),
108:                        JavaPartitionScanner.JAVA_DOC);
109:
110:                assistant.enableAutoActivation(true);
111:                assistant.setAutoActivationDelay(500);
112:                assistant
113:                        .setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
114:                assistant
115:                        .setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
116:                assistant
117:                        .setContextInformationPopupBackground(JavaEditorExamplePlugin
118:                                .getDefault().getJavaColorProvider().getColor(
119:                                        new RGB(150, 150, 0)));
120:
121:                return assistant;
122:            }
123:
124:            /* (non-Javadoc)
125:             * Method declared on SourceViewerConfiguration
126:             */
127:            public String getDefaultPrefix(ISourceViewer sourceViewer,
128:                    String contentType) {
129:                return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" : null); //$NON-NLS-1$
130:            }
131:
132:            /* (non-Javadoc)
133:             * Method declared on SourceViewerConfiguration
134:             */
135:            public ITextDoubleClickStrategy getDoubleClickStrategy(
136:                    ISourceViewer sourceViewer, String contentType) {
137:                return new JavaDoubleClickSelector();
138:            }
139:
140:            /* (non-Javadoc)
141:             * Method declared on SourceViewerConfiguration
142:             */
143:            public String[] getIndentPrefixes(ISourceViewer sourceViewer,
144:                    String contentType) {
145:                return new String[] { "\t", "    " }; //$NON-NLS-1$ //$NON-NLS-2$
146:            }
147:
148:            /* (non-Javadoc)
149:             * Method declared on SourceViewerConfiguration
150:             */
151:            public IPresentationReconciler getPresentationReconciler(
152:                    ISourceViewer sourceViewer) {
153:
154:                JavaColorProvider provider = JavaEditorExamplePlugin
155:                        .getDefault().getJavaColorProvider();
156:                PresentationReconciler reconciler = new PresentationReconciler();
157:                reconciler
158:                        .setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
159:
160:                DefaultDamagerRepairer dr = new DefaultDamagerRepairer(
161:                        JavaEditorExamplePlugin.getDefault()
162:                                .getJavaCodeScanner());
163:                reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
164:                reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
165:
166:                dr = new DefaultDamagerRepairer(JavaEditorExamplePlugin
167:                        .getDefault().getJavaDocScanner());
168:                reconciler.setDamager(dr, JavaPartitionScanner.JAVA_DOC);
169:                reconciler.setRepairer(dr, JavaPartitionScanner.JAVA_DOC);
170:
171:                dr = new DefaultDamagerRepairer(
172:                        new SingleTokenScanner(
173:                                new TextAttribute(
174:                                        provider
175:                                                .getColor(JavaColorProvider.MULTI_LINE_COMMENT))));
176:                reconciler.setDamager(dr,
177:                        JavaPartitionScanner.JAVA_MULTILINE_COMMENT);
178:                reconciler.setRepairer(dr,
179:                        JavaPartitionScanner.JAVA_MULTILINE_COMMENT);
180:
181:                return reconciler;
182:            }
183:
184:            /* (non-Javadoc)
185:             * Method declared on SourceViewerConfiguration
186:             */
187:            public int getTabWidth(ISourceViewer sourceViewer) {
188:                return 4;
189:            }
190:
191:            /* (non-Javadoc)
192:             * Method declared on SourceViewerConfiguration
193:             */
194:            public ITextHover getTextHover(ISourceViewer sourceViewer,
195:                    String contentType) {
196:                return new JavaTextHover();
197:            }
198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.