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


001:        package org.drools.eclipse.editors.completion;
002:
003:        import java.util.Comparator;
004:
005:        import org.eclipse.jface.text.BadLocationException;
006:        import org.eclipse.jface.text.IDocument;
007:        import org.eclipse.jface.text.contentassist.ICompletionProposal;
008:        import org.eclipse.jface.text.contentassist.IContextInformation;
009:        import org.eclipse.swt.graphics.Image;
010:        import org.eclipse.swt.graphics.Point;
011:
012:        /**
013:         * Holds a completion proposal to be popped up.
014:         *
015:         * @author Michael Neale
016:         *
017:         */
018:        public class RuleCompletionProposal implements  ICompletionProposal {
019:
020:            private String content;
021:            private String display;
022:            private int replacementOffset;
023:            private int replacementLength;
024:            private int cursorPosition;
025:            private Image image;
026:            private int priority;
027:
028:            /** This is used when the stuff that is displayed, is the stuff that is used. */
029:            public RuleCompletionProposal(int replacementOffset,
030:                    int replacementLength, String content) {
031:                this (replacementOffset, replacementLength, content, content);
032:            }
033:
034:            /** This is used when a different display value is shown to what is put in when selected. */
035:            public RuleCompletionProposal(int replacementOffset,
036:                    int replacementLength, String display, String content) {
037:                this (replacementOffset, replacementLength, display, content,
038:                        content.length());
039:            }
040:
041:            /** Also allows an icon to be used */
042:            public RuleCompletionProposal(int replacementOffset,
043:                    int replacementLength, String display, String content,
044:                    Image image) {
045:                this (replacementOffset, replacementLength, display, content,
046:                        content.length(), image);
047:            }
048:
049:            public RuleCompletionProposal(int replacementOffset,
050:                    int replacementLength, String display, String content,
051:                    int cursorPosition) {
052:                this (replacementOffset, replacementLength, display, content,
053:                        cursorPosition, null);
054:            }
055:
056:            /** This is used when a different display value is shown to what is put in when selected. */
057:            public RuleCompletionProposal(int replacementOffset,
058:                    int replacementLength, String display, String content,
059:                    int cursorPosition, Image image) {
060:                this .replacementOffset = replacementOffset;
061:                this .replacementLength = replacementLength;
062:                this .content = content;
063:                this .display = display;
064:                this .cursorPosition = cursorPosition;
065:                this .image = image;
066:            }
067:
068:            public String getDisplay() {
069:                return display;
070:            }
071:
072:            public int getReplacementLength() {
073:                return replacementLength;
074:            }
075:
076:            public int getCursorPosition() {
077:                return cursorPosition;
078:            }
079:
080:            public Image getImage() {
081:                return image;
082:            }
083:
084:            public String getContent() {
085:                return content;
086:            }
087:
088:            public void setImage(Image image) {
089:                this .image = image;
090:            }
091:
092:            public int getPriority() {
093:                return priority;
094:            }
095:
096:            public void setPriority(int priority) {
097:                this .priority = priority;
098:            }
099:
100:            public String toString() {
101:                return content;
102:            }
103:
104:            //TODO:fixme now that we mix,JDT  and own propsals, comparison is all wrong, resulting in wrong ordering of mixed proposals (such as with mvel
105:            public static class RuleCompletionProposalComparator implements 
106:                    Comparator {
107:                public int compare(Object arg0, Object arg1) {
108:                    if (arg0 instanceof  RuleCompletionProposal) {
109:                        if (arg1 instanceof  RuleCompletionProposal) {
110:                            RuleCompletionProposal prop0 = (RuleCompletionProposal) arg0;
111:                            RuleCompletionProposal prop1 = (RuleCompletionProposal) arg1;
112:                            if (prop0.getPriority() == prop1.getPriority()) {
113:                                return prop0.display.compareTo(prop1.display);
114:                            } else if (prop0.getPriority() > prop1
115:                                    .getPriority()) {
116:                                return -1;
117:                            } else {
118:                                return 1;
119:                            }
120:                        } else {
121:                            return -1;
122:                        }
123:                    } else {
124:                        if (arg1 instanceof  RuleCompletionProposal) {
125:                            return 1;
126:                        }
127:                        return 0;
128:                    }
129:                }
130:            }
131:
132:            public void apply(IDocument document) {
133:                try {
134:                    document.replace(replacementOffset, replacementLength,
135:                            content);
136:                } catch (BadLocationException x) {
137:                    // ignore
138:                }
139:            }
140:
141:            public String getAdditionalProposalInfo() {
142:                return null;
143:            }
144:
145:            public IContextInformation getContextInformation() {
146:                return null;
147:            }
148:
149:            public String getDisplayString() {
150:                if (display != null) {
151:                    return display;
152:                }
153:                return content;
154:            }
155:
156:            public int hashCode() {
157:                final int PRIME = 31;
158:                int result = 1;
159:                result = PRIME * result
160:                        + ((content == null) ? 0 : content.hashCode());
161:                result = PRIME * result
162:                        + ((display == null) ? 0 : display.hashCode());
163:                return result;
164:            }
165:
166:            public boolean equals(Object obj) {
167:                if (this  == obj)
168:                    return true;
169:                if (obj == null)
170:                    return false;
171:                if (getClass() != obj.getClass())
172:                    return false;
173:                final RuleCompletionProposal other = (RuleCompletionProposal) obj;
174:                if (content == null) {
175:                    if (other.content != null)
176:                        return false;
177:                } else if (!content.equals(other.content))
178:                    return false;
179:                if (display == null) {
180:                    if (other.display != null)
181:                        return false;
182:                } else if (!display.equals(other.display))
183:                    return false;
184:                return true;
185:            }
186:
187:            public Point getSelection(IDocument document) {
188:                return new Point(replacementOffset + cursorPosition, 0);
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.