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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 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.refactoring;
011:
012:        import org.eclipse.core.runtime.Assert;
013:
014:        import org.eclipse.swt.SWT;
015:        import org.eclipse.swt.events.ModifyEvent;
016:        import org.eclipse.swt.events.ModifyListener;
017:        import org.eclipse.swt.widgets.Composite;
018:        import org.eclipse.swt.widgets.Text;
019:
020:        import org.eclipse.jdt.internal.ui.dialogs.TextFieldNavigationHandler;
021:
022:        import org.eclipse.ltk.core.refactoring.RefactoringStatus;
023:        import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
024:
025:        /**
026:         * A TextInputWizardPage is a simple UserInputWizardPage with facilities
027:         * to create a text input field and validate its contents.
028:         * The text is assumed to be a java identifier, hence CamelCase word jumping is installed.
029:         */
030:        public abstract class TextInputWizardPage extends UserInputWizardPage {
031:
032:            private String fInitialValue;
033:            private Text fTextField;
034:
035:            public static final String PAGE_NAME = "TextInputPage";//$NON-NLS-1$
036:
037:            /**
038:             * Creates a new text input page.
039:             * @param isLastUserPage <code>true</code> if this page is the wizard's last
040:             *  user input page. Otherwise <code>false</code>.
041:             */
042:            public TextInputWizardPage(String description,
043:                    boolean isLastUserPage) {
044:                this (description, isLastUserPage, ""); //$NON-NLS-1$
045:            }
046:
047:            /**
048:             * Creates a new text input page.
049:             * @param isLastUserPage <code>true</code> if this page is the wizard's last
050:             *  user input page. Otherwise <code>false</code>
051:             * @param initialValue the initial value
052:             */
053:            public TextInputWizardPage(String description,
054:                    boolean isLastUserPage, String initialValue) {
055:                super (PAGE_NAME);
056:                Assert.isNotNull(initialValue);
057:                setDescription(description);
058:                fInitialValue = initialValue;
059:            }
060:
061:            /**
062:             * Returns whether the initial input is valid. Typically it is not, because the 
063:             * user is required to provide some information e.g. a new type name etc.
064:             * 
065:             * @return <code>true</code> iff the input provided at initialization is valid
066:             */
067:            protected boolean isInitialInputValid() {
068:                return false;
069:            }
070:
071:            /**
072:             * Returns whether an empty string is a valid input. Typically it is not, because 
073:             * the user is required to provide some information e.g. a new type name etc.
074:             * 
075:             * @return <code>true</code> iff an empty string is valid
076:             */
077:            protected boolean isEmptyInputValid() {
078:                return false;
079:            }
080:
081:            /**
082:             * Returns the content of the text input field.
083:             * 
084:             * @return the content of the text input field. Returns <code>null</code> if
085:             * not text input field has been created
086:             */
087:            protected String getText() {
088:                if (fTextField == null)
089:                    return null;
090:                return fTextField.getText();
091:            }
092:
093:            /**
094:             * Sets the new text for the text field. Does nothing if the text field has not been created.
095:             * @param text the new value
096:             */
097:            protected void setText(String text) {
098:                if (fTextField == null)
099:                    return;
100:                fTextField.setText(text);
101:            }
102:
103:            /**
104:             * Returns the text entry field
105:             * 
106:             * @return the text entry field
107:             */
108:            protected Text getTextField() {
109:                return fTextField;
110:            }
111:
112:            /**
113:             * Returns the initial value.
114:             * 
115:             * @return the initial value
116:             */
117:            public String getInitialValue() {
118:                return fInitialValue;
119:            }
120:
121:            /**
122:             * Performs input validation. Returns a <code>RefactoringStatus</code> which
123:             * describes the result of input validation. <code>Null<code> is interpreted
124:             * as no error.
125:             */
126:            protected RefactoringStatus validateTextField(String text) {
127:                return null;
128:            }
129:
130:            protected Text createTextInputField(Composite parent) {
131:                return createTextInputField(parent, SWT.BORDER);
132:            }
133:
134:            protected Text createTextInputField(Composite parent, int style) {
135:                fTextField = new Text(parent, style);
136:                fTextField.addModifyListener(new ModifyListener() {
137:                    public void modifyText(ModifyEvent e) {
138:                        textModified(getText());
139:                    }
140:                });
141:                fTextField.setText(fInitialValue);
142:                TextFieldNavigationHandler.install(fTextField);
143:                return fTextField;
144:            }
145:
146:            /**
147:             * Checks the page's state and issues a corresponding error message. The page validation
148:             * is computed by calling <code>validatePage</code>.
149:             */
150:            protected void textModified(String text) {
151:                if (!isEmptyInputValid() && "".equals(text)) { //$NON-NLS-1$
152:                    setPageComplete(false);
153:                    setErrorMessage(null);
154:                    restoreMessage();
155:                    return;
156:                }
157:                if ((!isInitialInputValid()) && fInitialValue.equals(text)) {
158:                    setPageComplete(false);
159:                    setErrorMessage(null);
160:                    restoreMessage();
161:                    return;
162:                }
163:
164:                RefactoringStatus status = validateTextField(text);
165:                if (status == null)
166:                    status = new RefactoringStatus();
167:                setPageComplete(status);
168:            }
169:
170:            /**
171:             * Subclasses can override if they want to restore the message differently.
172:             * This implementation calls <code>setMessage(null)</code>, which clears the message 
173:             * thus exposing the description.
174:             */
175:            protected void restoreMessage() {
176:                setMessage(null);
177:            }
178:
179:            /* (non-Javadoc)
180:             * Method declared in IDialogPage
181:             */
182:            public void dispose() {
183:                fTextField = null;
184:            }
185:
186:            /* (non-Javadoc)
187:             * Method declared in WizardPage
188:             */
189:            public void setVisible(boolean visible) {
190:                if (visible) {
191:                    textModified(getText());
192:                }
193:                super.setVisible(visible);
194:                if (visible && fTextField != null) {
195:                    fTextField.setFocus();
196:                }
197:            }
198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.