Source Code Cross Referenced for RenameTypeInputPage.java in  » Workflow-Engines » osbl-1_0 » gui » wizards » 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 » Workflow Engines » osbl 1_0 » gui.wizards 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * 
003:         */package gui.wizards;
004:
005:        import gui.RefactoringPlugin;
006:
007:        import org.eclipse.core.runtime.IStatus;
008:        import org.eclipse.jdt.core.JavaConventions;
009:        import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
010:        import org.eclipse.jface.dialogs.Dialog;
011:        import org.eclipse.jface.dialogs.IDialogSettings;
012:        import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
013:        import org.eclipse.swt.SWT;
014:        import org.eclipse.swt.events.KeyAdapter;
015:        import org.eclipse.swt.events.KeyEvent;
016:        import org.eclipse.swt.events.SelectionAdapter;
017:        import org.eclipse.swt.events.SelectionEvent;
018:        import org.eclipse.swt.layout.GridData;
019:        import org.eclipse.swt.layout.GridLayout;
020:        import org.eclipse.swt.widgets.Button;
021:        import org.eclipse.swt.widgets.Combo;
022:        import org.eclipse.swt.widgets.Composite;
023:        import org.eclipse.swt.widgets.Label;
024:        import org.eclipse.swt.widgets.Text;
025:
026:        import core.RefactorInfo;
027:
028:        /** <p>the input page for the Rename Type refactoring, where users can
029:         * control the effects of the refactoring; to be shown in the wizard.</p>
030:         *
031:         * <p>We let the user enter the new name for the property, and we let her 
032:         * decide whether other property files in the bundle should be affected, and
033:         * whether the operation is supposed to span the entire workspace or only 
034:         * the current project.</p>
035:         * 
036:         * @author sh
037:         */
038:        public class RenameTypeInputPage extends UserInputWizardPage {
039:
040:            private static final String DS_KEY = RenameTypeInputPage.class
041:                    .getName();
042:            private static final String DS_UPDATE_BUNDLE = "UPDATE_BUNDLE";
043:            private static final String DS_ALL_PROJECTS = "ALL_PROJECTS";
044:
045:            private final RefactorInfo info;
046:
047:            private IDialogSettings dialogSettings;
048:            private Text txtVarName;
049:            private Combo comboNewType;
050:
051:            public static final String[] TYPES = new String[] { "boolean",
052:                    "byte", "char", "String", "short", "int", "long", "float",
053:                    "double" };
054:
055:            public RenameTypeInputPage(final RefactorInfo info) {
056:                super (RenameTypeInputPage.class.getName());
057:                this .info = info;
058:                //initDialogSettings();
059:            }
060:
061:            /**
062:             * interface methods of UserInputWizardPage
063:             */
064:            public void createControl(final Composite parent) {
065:                Composite composite = createRootComposite(parent);
066:                setControl(composite);
067:
068:                createLblNewType(composite);
069:                createComboNewType(composite);
070:                createLblVarName(composite);
071:                createTxtVarName(composite);
072:
073:                validateType();
074:            }
075:
076:            /**
077:             * UI creation method
078:             */
079:            private Composite createRootComposite(final Composite parent) {
080:                Composite result = new Composite(parent, SWT.NONE);
081:                GridLayout gridLayout = new GridLayout(2, false);
082:                gridLayout.marginWidth = 10;
083:                gridLayout.marginHeight = 10;
084:                result.setLayout(gridLayout);
085:                initializeDialogUnits(result);
086:                Dialog.applyDialogFont(result);
087:                return result;
088:            }
089:
090:            /**
091:             * UI creation method
092:             */
093:            private void createLblNewType(final Composite composite) {
094:                Label lblNewName = new Label(composite, SWT.NONE);
095:                lblNewName.setText("New type");
096:            }
097:
098:            /**
099:             * UI creation method
100:             */
101:            private void createComboNewType(Composite composite) {
102:                comboNewType = new Combo(composite, SWT.SIMPLE);
103:                comboNewType.setItems(TYPES);
104:
105:                String oldType = info.getOldName();
106:                for (int i = 0; i < TYPES.length; i++) {
107:                    String element = TYPES[i];
108:                    if (element.contains(oldType)) {
109:                        comboNewType.select(i);
110:                    }
111:                }
112:
113:                comboNewType.setLayoutData(new GridData(
114:                        GridData.FILL_HORIZONTAL));
115:                comboNewType.addKeyListener(new KeyAdapter() {
116:                    public void keyReleased(final KeyEvent e) {
117:                        info.setNewName(comboNewType.getText());
118:                        validateType();
119:                    }
120:                });
121:                comboNewType.addSelectionListener(new SelectionAdapter() {
122:                    public void widgetSelected(SelectionEvent e) {
123:                        info.setNewName(comboNewType.getText());
124:                        validateType();
125:                    }
126:                });
127:            }
128:
129:            /**
130:             * UI creation method
131:             */
132:            private void createLblVarName(final Composite composite) {
133:                Label lblNewName = new Label(composite, SWT.NONE);
134:                lblNewName.setText("name");
135:            }
136:
137:            /**
138:             * UI creation method
139:             */
140:            private void createTxtVarName(Composite composite) {
141:                txtVarName = new Text(composite, SWT.BORDER);
142:                txtVarName.setText(info.getOldVarName());
143:                txtVarName
144:                        .setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
145:                txtVarName.selectAll();
146:                txtVarName.addKeyListener(new KeyAdapter() {
147:                    public void keyReleased(final KeyEvent e) {
148:                        info.setNewVarName(txtVarName.getText());
149:                        validateFieldName();
150:                    }
151:                });
152:            }
153:
154:            /**
155:             * helper method
156:             */
157:            private void initDialogSettings() {
158:                IDialogSettings ds = RefactoringPlugin.getDefault()
159:                        .getDialogSettings();
160:                dialogSettings = ds.getSection(DS_KEY);
161:                if (dialogSettings == null) {
162:                    dialogSettings = ds.addNewSection(DS_KEY);
163:                    // init default values
164:                    dialogSettings.put(DS_UPDATE_BUNDLE, true);
165:                    dialogSettings.put(DS_ALL_PROJECTS, false);
166:                }
167:            }
168:
169:            /**
170:             * helper method
171:             */
172:            private void validateType() {
173:                String typeTxt = comboNewType.getText();
174:
175:                // check if the selected value exists in the default type collection
176:                boolean contained = false;
177:                for (int j = 0; j < TYPES.length; j++) {
178:                    String type = TYPES[j];
179:                    if (type.equals(typeTxt))
180:                        contained = true;
181:                }
182:
183:                // if not, check if the current value is valid
184:                if (!contained) {
185:                    IStatus status = JavaConventions.validateJavaTypeName(
186:                            typeTxt, CompilerOptions.VERSION_1_3,
187:                            CompilerOptions.VERSION_1_3);
188:                    if (status.isOK()) {
189:                        setPageComplete(true);
190:                        setMessage(null);
191:                    } else if (status.ERROR == IStatus.ERROR) {
192:                        setPageComplete(false);
193:                        setMessage(status.getMessage());
194:                    }
195:                }
196:            }
197:
198:            /**
199:             * helper method
200:             */
201:            private void validateFieldName() {
202:                String nameTxt = txtVarName.getText();
203:                IStatus fieldStatus = JavaConventions.validateFieldName(
204:                        nameTxt, CompilerOptions.VERSION_1_3,
205:                        CompilerOptions.VERSION_1_3);
206:
207:                if (fieldStatus.isOK() && nameTxt.length() > 0) {
208:                    setPageComplete(true);
209:                    setMessage(null);
210:                } else if (fieldStatus.ERROR == IStatus.ERROR) {
211:                    setPageComplete(false);
212:                    setMessage(fieldStatus.getMessage());
213:                }
214:            }
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.