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


001:        /*******************************************************************************
002:         * Copyright (c) 2006, 2007 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.fieldassist;
011:
012:        import org.eclipse.jface.fieldassist.DecoratedField;
013:        import org.eclipse.jface.fieldassist.FieldDecoration;
014:        import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
015:        import org.eclipse.jface.fieldassist.IContentProposalProvider;
016:        import org.eclipse.jface.fieldassist.IControlContentAdapter;
017:        import org.eclipse.jface.fieldassist.IControlCreator;
018:        import org.eclipse.osgi.util.NLS;
019:        import org.eclipse.swt.SWT;
020:        import org.eclipse.swt.widgets.Composite;
021:        import org.eclipse.ui.PlatformUI;
022:        import org.eclipse.ui.internal.WorkbenchMessages;
023:        import org.eclipse.ui.keys.IBindingService;
024:
025:        /**
026:         * ContentAssistField utilizes the concepts of a {@link DecoratedField} and the
027:         * {@link ContentAssistCommandAdapter} to provide a decorated field that shows a
028:         * content assist cue when it gets focus and invokes content assist for a
029:         * specified command.
030:         * <p>
031:         * This class is not intended to be subclassed.
032:         * 
033:         * @since 3.2
034:         * @deprecated As of 3.3, clients should use
035:         *             {@link org.eclipse.jface.fieldassist.ControlDecoration} and
036:         *             {@link ContentAssistCommandAdapter} instead of this class.
037:         */
038:        public class ContentAssistField extends DecoratedField {
039:
040:            private ContentAssistCommandAdapter adapter;
041:
042:            private static final String CONTENT_ASSIST_DECORATION_ID = "org.eclipse.ui.fieldAssist.ContentAssistField"; //$NON-NLS-1$
043:
044:            /**
045:             * Construct a content assist field that shows a content assist cue and can
046:             * assist the user with choosing content for the field.
047:             * 
048:             * @param parent
049:             *            the parent of the decorated field.
050:             * @param style
051:             *            the desired style bits for the field.
052:             * @param controlCreator
053:             *            the IControlCreator used to specify the specific kind of
054:             *            control that is to be decorated.
055:             * @param controlContentAdapter
056:             *            the <code>IControlContentAdapter</code> used to obtain and
057:             *            update the control's contents as proposals are accepted. May
058:             *            not be <code>null</code>.
059:             * @param proposalProvider
060:             *            the <code>IContentProposalProvider</code> used to obtain
061:             *            content proposals for this control, or <code>null</code> if
062:             *            no content proposal is available.
063:             * @param commandId
064:             *            the String id of the command that will invoke the content
065:             *            assistant. If not supplied, the default value will be
066:             *            "org.eclipse.ui.edit.text.contentAssist.proposals".
067:             * @param autoActivationCharacters
068:             *            An array of characters that trigger auto-activation of content
069:             *            proposal. If specified, these characters will trigger
070:             *            auto-activation of the proposal popup, regardless of the
071:             *            specified command id.
072:             */
073:            public ContentAssistField(Composite parent, int style,
074:                    IControlCreator controlCreator,
075:                    IControlContentAdapter controlContentAdapter,
076:                    IContentProposalProvider proposalProvider,
077:                    String commandId, char[] autoActivationCharacters) {
078:
079:                super (parent, style, controlCreator);
080:                adapter = new ContentAssistCommandAdapter(getControl(),
081:                        controlContentAdapter, proposalProvider, commandId,
082:                        autoActivationCharacters);
083:
084:                addFieldDecoration(getFieldDecoration(), SWT.LEFT | SWT.TOP,
085:                        true);
086:
087:            }
088:
089:            /**
090:             * Set the boolean flag that determines whether the content assist is
091:             * enabled.
092:             * 
093:             * @param enabled
094:             *            <code>true</code> if content assist is enabled and
095:             *            responding to user input, <code>false</code> if it is
096:             *            ignoring user input.
097:             * 
098:             */
099:            public void setEnabled(boolean enabled) {
100:                adapter.setEnabled(enabled);
101:                if (enabled) {
102:                    showDecoration(getFieldDecoration());
103:                } else {
104:                    hideDecoration(getFieldDecoration());
105:                }
106:            }
107:
108:            /*
109:             * Get a field decoration appropriate for cueing the user, including a
110:             * description of the active key binding.
111:             * 
112:             */
113:            private FieldDecoration getFieldDecoration() {
114:                FieldDecorationRegistry registry = FieldDecorationRegistry
115:                        .getDefault();
116:                // Look for a decoration installed for this particular command id.
117:                String decId = CONTENT_ASSIST_DECORATION_ID
118:                        + adapter.getCommandId();
119:                FieldDecoration dec = registry.getFieldDecoration(decId);
120:
121:                // If there is not one, base ours on the standard JFace one.
122:                if (dec == null) {
123:                    FieldDecoration originalDec = registry
124:                            .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
125:
126:                    registry.registerFieldDecoration(decId, null, originalDec
127:                            .getImage());
128:                    dec = registry.getFieldDecoration(decId);
129:                }
130:                // Always update the decoration text since the key binding may
131:                // have changed since it was last retrieved.
132:                IBindingService bindingService = (IBindingService) PlatformUI
133:                        .getWorkbench().getService(IBindingService.class);
134:                dec.setDescription(NLS.bind(
135:                        WorkbenchMessages.ContentAssist_Cue_Description_Key,
136:                        bindingService.getBestActiveBindingFormattedFor(adapter
137:                                .getCommandId())));
138:
139:                // Now return the field decoration
140:                return dec;
141:            }
142:
143:            /**
144:             * Return the ContentAssistCommandAdapter installed on the receiver. This
145:             * adapter is provided so that clients can configure the adapter if the
146:             * default values are not appropriate.
147:             * 
148:             * @return the ContentAssistCommandAdapter installed on the field.
149:             */
150:            public ContentAssistCommandAdapter getContentAssistCommandAdapter() {
151:                return adapter;
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.