Source Code Cross Referenced for JavaCompletionProcessor.java in  » IDE-Eclipse » ui-examples » org » eclipse » ui » examples » javaeditor » java » 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.java 
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.java;
011:
012:        import java.text.MessageFormat;
013:
014:        import org.eclipse.jface.text.ITextViewer;
015:        import org.eclipse.jface.text.TextPresentation;
016:        import org.eclipse.jface.text.contentassist.*;
017:
018:        /**
019:         * Example Java completion processor.
020:         */
021:        public class JavaCompletionProcessor implements  IContentAssistProcessor {
022:
023:            /**
024:             * Simple content assist tip closer. The tip is valid in a range
025:             * of 5 characters around its popup location.
026:             */
027:            protected static class Validator implements 
028:                    IContextInformationValidator, IContextInformationPresenter {
029:
030:                protected int fInstallOffset;
031:
032:                /*
033:                 * @see IContextInformationValidator#isContextInformationValid(int)
034:                 */
035:                public boolean isContextInformationValid(int offset) {
036:                    return Math.abs(fInstallOffset - offset) < 5;
037:                }
038:
039:                /*
040:                 * @see IContextInformationValidator#install(IContextInformation, ITextViewer, int)
041:                 */
042:                public void install(IContextInformation info,
043:                        ITextViewer viewer, int offset) {
044:                    fInstallOffset = offset;
045:                }
046:
047:                /*
048:                 * @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int, TextPresentation)
049:                 */
050:                public boolean updatePresentation(int documentPosition,
051:                        TextPresentation presentation) {
052:                    return false;
053:                }
054:            }
055:
056:            protected final static String[] fgProposals = {
057:                    "abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "continue", "default", "do", "double", "else", "extends", "false", "final", "finally", "float", "for", "if", "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while" }; //$NON-NLS-48$ //$NON-NLS-47$ //$NON-NLS-46$ //$NON-NLS-45$ //$NON-NLS-44$ //$NON-NLS-43$ //$NON-NLS-42$ //$NON-NLS-41$ //$NON-NLS-40$ //$NON-NLS-39$ //$NON-NLS-38$ //$NON-NLS-37$ //$NON-NLS-36$ //$NON-NLS-35$ //$NON-NLS-34$ //$NON-NLS-33$ //$NON-NLS-32$ //$NON-NLS-31$ //$NON-NLS-30$ //$NON-NLS-29$ //$NON-NLS-28$ //$NON-NLS-27$ //$NON-NLS-26$ //$NON-NLS-25$ //$NON-NLS-24$ //$NON-NLS-23$ //$NON-NLS-22$ //$NON-NLS-21$ //$NON-NLS-20$ //$NON-NLS-19$ //$NON-NLS-18$ //$NON-NLS-17$ //$NON-NLS-16$ //$NON-NLS-15$ //$NON-NLS-14$ //$NON-NLS-13$ //$NON-NLS-12$ //$NON-NLS-11$ //$NON-NLS-10$ //$NON-NLS-9$ //$NON-NLS-8$ //$NON-NLS-7$ //$NON-NLS-6$ //$NON-NLS-5$ //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$
058:
059:            protected IContextInformationValidator fValidator = new Validator();
060:
061:            /* (non-Javadoc)
062:             * Method declared on IContentAssistProcessor
063:             */
064:            public ICompletionProposal[] computeCompletionProposals(
065:                    ITextViewer viewer, int documentOffset) {
066:                ICompletionProposal[] result = new ICompletionProposal[fgProposals.length];
067:                for (int i = 0; i < fgProposals.length; i++) {
068:                    IContextInformation info = new ContextInformation(
069:                            fgProposals[i],
070:                            MessageFormat
071:                                    .format(
072:                                            JavaEditorMessages
073:                                                    .getString("CompletionProcessor.Proposal.ContextInfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$
074:                    result[i] = new CompletionProposal(
075:                            fgProposals[i],
076:                            documentOffset,
077:                            0,
078:                            fgProposals[i].length(),
079:                            null,
080:                            fgProposals[i],
081:                            info,
082:                            MessageFormat
083:                                    .format(
084:                                            JavaEditorMessages
085:                                                    .getString("CompletionProcessor.Proposal.hoverinfo.pattern"), new Object[] { fgProposals[i] })); //$NON-NLS-1$
086:                }
087:                return result;
088:            }
089:
090:            /* (non-Javadoc)
091:             * Method declared on IContentAssistProcessor
092:             */
093:            public IContextInformation[] computeContextInformation(
094:                    ITextViewer viewer, int documentOffset) {
095:                IContextInformation[] result = new IContextInformation[5];
096:                for (int i = 0; i < result.length; i++)
097:                    result[i] = new ContextInformation(
098:                            MessageFormat
099:                                    .format(
100:                                            JavaEditorMessages
101:                                                    .getString("CompletionProcessor.ContextInfo.display.pattern"), new Object[] { new Integer(i), new Integer(documentOffset) }), //$NON-NLS-1$
102:                            MessageFormat
103:                                    .format(
104:                                            JavaEditorMessages
105:                                                    .getString("CompletionProcessor.ContextInfo.value.pattern"), new Object[] { new Integer(i), new Integer(documentOffset - 5), new Integer(documentOffset + 5) })); //$NON-NLS-1$
106:                return result;
107:            }
108:
109:            /* (non-Javadoc)
110:             * Method declared on IContentAssistProcessor
111:             */
112:            public char[] getCompletionProposalAutoActivationCharacters() {
113:                return new char[] { '.', '(' };
114:            }
115:
116:            /* (non-Javadoc)
117:             * Method declared on IContentAssistProcessor
118:             */
119:            public char[] getContextInformationAutoActivationCharacters() {
120:                return new char[] { '#' };
121:            }
122:
123:            /* (non-Javadoc)
124:             * Method declared on IContentAssistProcessor
125:             */
126:            public IContextInformationValidator getContextInformationValidator() {
127:                return fValidator;
128:            }
129:
130:            /* (non-Javadoc)
131:             * Method declared on IContentAssistProcessor
132:             */
133:            public String getErrorMessage() {
134:                return null;
135:            }
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.