Source Code Cross Referenced for DRLSourceViewerConfig.java in  » Rule-Engine » drolls-Rule-Engine » org » drools » eclipse » editors » 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 » Rule Engine » drolls Rule Engine » org.drools.eclipse.editors 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.drools.eclipse.editors;
002:
003:        import org.drools.eclipse.editors.completion.DefaultCompletionProcessor;
004:        import org.drools.eclipse.editors.completion.RuleCompletionProcessor;
005:        import org.drools.eclipse.editors.scanners.DRLPartionScanner;
006:        import org.drools.eclipse.editors.scanners.DRLScanner;
007:        import org.eclipse.core.runtime.NullProgressMonitor;
008:        import org.eclipse.jface.text.IDocument;
009:        import org.eclipse.jface.text.TextAttribute;
010:        import org.eclipse.jface.text.contentassist.ContentAssistant;
011:        import org.eclipse.jface.text.contentassist.IContentAssistant;
012:        import org.eclipse.jface.text.presentation.IPresentationReconciler;
013:        import org.eclipse.jface.text.presentation.PresentationReconciler;
014:        import org.eclipse.jface.text.reconciler.IReconciler;
015:        import org.eclipse.jface.text.reconciler.MonoReconciler;
016:        import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
017:        import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
018:        import org.eclipse.jface.text.rules.Token;
019:        import org.eclipse.jface.text.source.DefaultAnnotationHover;
020:        import org.eclipse.jface.text.source.IAnnotationHover;
021:        import org.eclipse.jface.text.source.ISourceViewer;
022:        import org.eclipse.jface.text.source.SourceViewerConfiguration;
023:        import org.eclipse.swt.graphics.Color;
024:
025:        /**
026:         * Source viewer config wires up the syntax highlighting, partitioning
027:         * and content assistance.
028:         * 
029:         * @author Michael Neale
030:         * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
031:         */
032:        public class DRLSourceViewerConfig extends SourceViewerConfiguration {
033:
034:            private DRLScanner scanner;
035:
036:            private static Color DEFAULT_COLOR = ColorManager.getInstance()
037:                    .getColor(ColorManager.DEFAULT);
038:
039:            private AbstractRuleEditor editor;
040:
041:            public DRLSourceViewerConfig(AbstractRuleEditor editor) {
042:                this .editor = editor;
043:            }
044:
045:            protected AbstractRuleEditor getEditor() {
046:                return editor;
047:            }
048:
049:            protected DRLScanner getScanner() {
050:                if (scanner == null) {
051:                    scanner = new DRLScanner();
052:                    scanner.setDefaultReturnToken(new Token(new TextAttribute(
053:                            DEFAULT_COLOR)));
054:                }
055:                return scanner;
056:            }
057:
058:            /**
059:             * Define reconciler - this has to be done for each partition.
060:             * Currently there are 3 partitions, Inside rule, outside rule and inside comment.
061:             */
062:            public IPresentationReconciler getPresentationReconciler(
063:                    ISourceViewer sourceViewer) {
064:                PresentationReconciler reconciler = new PresentationReconciler();
065:
066:                //bucket partition... (everything else outside a rule)
067:                DefaultDamagerRepairer dr = new DefaultDamagerRepairer(
068:                        getScanner());
069:                reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
070:                reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
071:
072:                //inside a rule partition
073:                dr = new DefaultDamagerRepairer(getScanner());
074:                reconciler.setDamager(dr, DRLPartionScanner.RULE_PART_CONTENT);
075:                reconciler.setRepairer(dr, DRLPartionScanner.RULE_PART_CONTENT);
076:
077:                //finally, inside a multi line comment.
078:                dr = new DefaultDamagerRepairer(new SingleTokenScanner(
079:                        new TextAttribute(ColorManager.getInstance().getColor(
080:                                ColorManager.SINGLE_LINE_COMMENT))));
081:                reconciler.setDamager(dr, DRLPartionScanner.RULE_COMMENT);
082:                reconciler.setRepairer(dr, DRLPartionScanner.RULE_COMMENT);
083:
084:                return reconciler;
085:            }
086:
087:            /**
088:             * Single token scanner, used for scanning for multiline comments mainly.
089:             */
090:            static class SingleTokenScanner extends BufferedRuleBasedScanner {
091:                public SingleTokenScanner(TextAttribute attribute) {
092:                    setDefaultReturnToken(new Token(attribute));
093:                }
094:            }
095:
096:            /**
097:             * Get the appropriate content assistance, for each partition.
098:             */
099:            public IContentAssistant getContentAssistant(
100:                    ISourceViewer sourceViewer) {
101:                ContentAssistant assistant = new ContentAssistant();
102:                //setup the content assistance, which is
103:                //sensitive to the partition that it is in.
104:                assistant.setContentAssistProcessor(
105:                        new DefaultCompletionProcessor(editor),
106:                        IDocument.DEFAULT_CONTENT_TYPE);
107:                assistant.setContentAssistProcessor(
108:                        new RuleCompletionProcessor(editor),
109:                        DRLPartionScanner.RULE_PART_CONTENT);
110:                assistant
111:                        .setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
112:                return assistant;
113:            }
114:
115:            public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
116:                return DRLPartionScanner.LEGAL_CONTENT_TYPES;
117:            }
118:
119:            public IReconciler getReconciler(ISourceViewer sourceViewer) {
120:                MonoReconciler reconciler = null;
121:                if (sourceViewer != null) {
122:                    reconciler = new MonoReconciler(new DRLReconcilingStrategy(
123:                            sourceViewer, editor), false);
124:                    reconciler.setDelay(500);
125:                    reconciler.setProgressMonitor(new NullProgressMonitor());
126:                }
127:                return reconciler;
128:            }
129:
130:            public IAnnotationHover getOverviewRulerAnnotationHover(
131:                    ISourceViewer sourceViewer) {
132:                return new DefaultAnnotationHover();
133:            }
134:
135:            public IAnnotationHover getAnnotationHover(
136:                    ISourceViewer sourceViewer) {
137:                return new DefaultAnnotationHover();
138:            }
139:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.