Source Code Cross Referenced for StringDialogField.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » ui » wizards » dialogfields » 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 » jdt » org.eclipse.jdt.internal.ui.wizards.dialogfields 
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.jdt.internal.ui.wizards.dialogfields;
011:
012:        import org.eclipse.swt.SWT;
013:        import org.eclipse.swt.events.ModifyEvent;
014:        import org.eclipse.swt.events.ModifyListener;
015:        import org.eclipse.swt.layout.GridData;
016:        import org.eclipse.swt.widgets.Composite;
017:        import org.eclipse.swt.widgets.Control;
018:        import org.eclipse.swt.widgets.Label;
019:        import org.eclipse.swt.widgets.Text;
020:
021:        import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
022:
023:        import org.eclipse.jdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
024:
025:        /**
026:         * Dialog field containing a label and a text control.
027:         */
028:        public class StringDialogField extends DialogField {
029:
030:            private String fText;
031:            private Text fTextControl;
032:            private ModifyListener fModifyListener;
033:            private IContentAssistProcessor fContentAssistProcessor;
034:
035:            public StringDialogField() {
036:                super ();
037:                fText = ""; //$NON-NLS-1$
038:            }
039:
040:            public void setContentAssistProcessor(
041:                    IContentAssistProcessor processor) {
042:                fContentAssistProcessor = processor;
043:                if (fContentAssistProcessor != null && isOkToUse(fTextControl)) {
044:                    ControlContentAssistHelper.createTextContentAssistant(
045:                            fTextControl, fContentAssistProcessor);
046:                }
047:            }
048:
049:            public IContentAssistProcessor getContentAssistProcessor() {
050:                return fContentAssistProcessor;
051:            }
052:
053:            // ------- layout helpers
054:
055:            /*
056:             * @see DialogField#doFillIntoGrid
057:             */
058:            public Control[] doFillIntoGrid(Composite parent, int nColumns) {
059:                assertEnoughColumns(nColumns);
060:
061:                Label label = getLabelControl(parent);
062:                label.setLayoutData(gridDataForLabel(1));
063:                Text text = getTextControl(parent);
064:                text.setLayoutData(gridDataForText(nColumns - 1));
065:
066:                return new Control[] { label, text };
067:            }
068:
069:            /*
070:             * @see DialogField#getNumberOfControls
071:             */
072:            public int getNumberOfControls() {
073:                return 2;
074:            }
075:
076:            protected static GridData gridDataForText(int span) {
077:                GridData gd = new GridData();
078:                gd.horizontalAlignment = GridData.FILL;
079:                gd.grabExcessHorizontalSpace = false;
080:                gd.horizontalSpan = span;
081:                return gd;
082:            }
083:
084:            // ------- focus methods
085:
086:            /*
087:             * @see DialogField#setFocus
088:             */
089:            public boolean setFocus() {
090:                if (isOkToUse(fTextControl)) {
091:                    fTextControl.setFocus();
092:                    fTextControl.setSelection(0, fTextControl.getText()
093:                            .length());
094:                }
095:                return true;
096:            }
097:
098:            // ------- ui creation			
099:
100:            /**
101:             * Creates or returns the created text control.
102:             * @param parent The parent composite or <code>null</code> when the widget has
103:             * already been created.
104:             */
105:            public Text getTextControl(Composite parent) {
106:                if (fTextControl == null) {
107:                    assertCompositeNotNull(parent);
108:                    fModifyListener = new ModifyListener() {
109:                        public void modifyText(ModifyEvent e) {
110:                            doModifyText(e);
111:                        }
112:                    };
113:
114:                    fTextControl = new Text(parent, SWT.SINGLE | SWT.BORDER);
115:                    // moved up due to 1GEUNW2
116:                    fTextControl.setText(fText);
117:                    fTextControl.setFont(parent.getFont());
118:                    fTextControl.addModifyListener(fModifyListener);
119:
120:                    fTextControl.setEnabled(isEnabled());
121:                    if (fContentAssistProcessor != null) {
122:                        ControlContentAssistHelper.createTextContentAssistant(
123:                                fTextControl, fContentAssistProcessor);
124:                    }
125:                }
126:                return fTextControl;
127:            }
128:
129:            private void doModifyText(ModifyEvent e) {
130:                if (isOkToUse(fTextControl)) {
131:                    fText = fTextControl.getText();
132:                }
133:                dialogFieldChanged();
134:            }
135:
136:            // ------ enable / disable management
137:
138:            /*
139:             * @see DialogField#updateEnableState
140:             */
141:            protected void updateEnableState() {
142:                super .updateEnableState();
143:                if (isOkToUse(fTextControl)) {
144:                    fTextControl.setEnabled(isEnabled());
145:                }
146:            }
147:
148:            // ------ text access 
149:
150:            /**
151:             * Gets the text. Can not be <code>null</code>
152:             */
153:            public String getText() {
154:                return fText;
155:            }
156:
157:            /**
158:             * Sets the text. Triggers a dialog-changed event.
159:             */
160:            public void setText(String text) {
161:                fText = text;
162:                if (isOkToUse(fTextControl)) {
163:                    fTextControl.setText(text);
164:                } else {
165:                    dialogFieldChanged();
166:                }
167:            }
168:
169:            /**
170:             * Sets the text without triggering a dialog-changed event.
171:             */
172:            public void setTextWithoutUpdate(String text) {
173:                fText = text;
174:                if (isOkToUse(fTextControl)) {
175:                    fTextControl.removeModifyListener(fModifyListener);
176:                    fTextControl.setText(text);
177:                    fTextControl.addModifyListener(fModifyListener);
178:                }
179:            }
180:
181:            /* (non-Javadoc)
182:             * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField#refresh()
183:             */
184:            public void refresh() {
185:                super.refresh();
186:                if (isOkToUse(fTextControl)) {
187:                    setTextWithoutUpdate(fText);
188:                }
189:            }
190:
191:        }
ww___w___.j___a___va___2s.c__o_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.