Source Code Cross Referenced for IntroduceIndirectionInputPage.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, 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.jdt.internal.ui.refactoring;
011:
012:        import java.util.ArrayList;
013:        import java.util.List;
014:
015:        import org.eclipse.swt.SWT;
016:        import org.eclipse.swt.events.ModifyEvent;
017:        import org.eclipse.swt.events.ModifyListener;
018:        import org.eclipse.swt.events.SelectionAdapter;
019:        import org.eclipse.swt.events.SelectionEvent;
020:        import org.eclipse.swt.layout.GridData;
021:        import org.eclipse.swt.layout.GridLayout;
022:        import org.eclipse.swt.widgets.Button;
023:        import org.eclipse.swt.widgets.Combo;
024:        import org.eclipse.swt.widgets.Composite;
025:        import org.eclipse.swt.widgets.Label;
026:        import org.eclipse.swt.widgets.Text;
027:
028:        import org.eclipse.jface.window.Window;
029:        import org.eclipse.jface.wizard.IWizardPage;
030:
031:        import org.eclipse.ui.PlatformUI;
032:
033:        import org.eclipse.ltk.core.refactoring.RefactoringStatus;
034:        import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
035:
036:        import org.eclipse.jdt.core.IJavaElement;
037:        import org.eclipse.jdt.core.IJavaProject;
038:        import org.eclipse.jdt.core.IType;
039:        import org.eclipse.jdt.core.search.IJavaSearchConstants;
040:        import org.eclipse.jdt.core.search.IJavaSearchScope;
041:        import org.eclipse.jdt.core.search.SearchEngine;
042:
043:        import org.eclipse.jdt.internal.corext.refactoring.code.IntroduceIndirectionRefactoring;
044:
045:        import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
046:        import org.eclipse.jdt.internal.ui.dialogs.FilteredTypesSelectionDialog;
047:        import org.eclipse.jdt.internal.ui.dialogs.TextFieldNavigationHandler;
048:        import org.eclipse.jdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
049:        import org.eclipse.jdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor;
050:        import org.eclipse.jdt.internal.ui.util.SWTUtil;
051:
052:        /**
053:         * @since 3.2
054:         */
055:        public class IntroduceIndirectionInputPage extends UserInputWizardPage {
056:
057:            /**
058:             * The name of the intermediary method to be created.
059:             */
060:            private Text fIntermediaryMethodName;
061:
062:            private Combo fIntermediaryTypeName;
063:            private static final int INTERMEDIARY_TYPE_COUNT = 10;
064:            private static List fgIntermediaryTypes = new ArrayList(
065:                    INTERMEDIARY_TYPE_COUNT);
066:
067:            /**
068:             * Constructor for IntroduceIndirectionInputPage.
069:             * @param name the name of the page
070:             */
071:            public IntroduceIndirectionInputPage(String name) {
072:                super (name);
073:            }
074:
075:            private Text createIntermediaryNameCombo(Composite result) {
076:                final Text textField = new Text(result, SWT.SINGLE | SWT.LEFT
077:                        | SWT.BORDER);
078:                textField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
079:                TextFieldNavigationHandler.install(textField);
080:                return textField;
081:            }
082:
083:            private Combo createIntermediaryTypeCombo(Composite composite) {
084:                final Combo textCombo = new Combo(composite, SWT.SINGLE
085:                        | SWT.BORDER);
086:                textCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
087:                textCombo.setItems((String[]) fgIntermediaryTypes
088:                        .toArray(new String[fgIntermediaryTypes.size()]));
089:                textCombo.setVisibleItemCount(INTERMEDIARY_TYPE_COUNT);
090:
091:                JavaTypeCompletionProcessor processor = new JavaTypeCompletionProcessor(
092:                        false, false, true);
093:                processor
094:                        .setPackageFragment(getIntroduceIndirectionRefactoring()
095:                                .getInvocationPackage());
096:                ControlContentAssistHelper.createComboContentAssistant(
097:                        textCombo, processor);
098:                TextFieldNavigationHandler.install(textCombo);
099:                return textCombo;
100:            }
101:
102:            /**
103:             * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
104:             */
105:            public void createControl(Composite parent) {
106:                Composite result = new Composite(parent, SWT.NONE);
107:
108:                setControl(result);
109:
110:                GridLayout layout = new GridLayout();
111:                layout.numColumns = 2;
112:                result.setLayout(layout);
113:
114:                Label methNameLabel = new Label(result, SWT.NONE);
115:                methNameLabel
116:                        .setText(RefactoringMessages.IntroduceIndirectionInputPage_new_method_name);
117:
118:                fIntermediaryMethodName = createIntermediaryNameCombo(result);
119:
120:                final Label intermediaryTypeLabel = new Label(result, SWT.NONE);
121:                intermediaryTypeLabel
122:                        .setText(RefactoringMessages.IntroduceIndirectionInputPage_declaring_class);
123:
124:                Composite inner = new Composite(result, SWT.NONE);
125:                GridLayout innerLayout = new GridLayout();
126:                innerLayout.marginHeight = 0;
127:                innerLayout.marginWidth = 0;
128:                innerLayout.numColumns = 2;
129:                inner.setLayout(innerLayout);
130:                inner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
131:
132:                fIntermediaryTypeName = createIntermediaryTypeCombo(inner);
133:                fIntermediaryTypeName.setLayoutData(new GridData(
134:                        GridData.FILL_HORIZONTAL));
135:
136:                final Button browseTypes = new Button(inner, SWT.PUSH);
137:                browseTypes
138:                        .setText(RefactoringMessages.IntroduceIndirectionInputPage_browse);
139:                GridData gd = new GridData();
140:                gd.horizontalAlignment = GridData.END;
141:                gd.widthHint = SWTUtil.getButtonWidthHint(browseTypes);
142:                browseTypes.setLayoutData(gd);
143:
144:                final Button enableReferencesCheckBox = new Button(result,
145:                        SWT.CHECK);
146:                enableReferencesCheckBox
147:                        .setText(RefactoringMessages.IntroduceIndirectionInputPage_update_references);
148:                gd = new GridData(GridData.FILL_HORIZONTAL);
149:                gd.horizontalSpan = 2;
150:                gd.verticalIndent = 2;
151:                enableReferencesCheckBox.setLayoutData(gd);
152:
153:                fIntermediaryMethodName
154:                        .setText(getIntroduceIndirectionRefactoring()
155:                                .getIntermediaryMethodName());
156:                fIntermediaryTypeName
157:                        .setText(getIntroduceIndirectionRefactoring()
158:                                .getIntermediaryClassName());
159:
160:                fIntermediaryMethodName.addModifyListener(new ModifyListener() {
161:                    public void modifyText(ModifyEvent e) {
162:                        validateInput();
163:                    }
164:                });
165:
166:                enableReferencesCheckBox
167:                        .addSelectionListener(new SelectionAdapter() {
168:                            public void widgetSelected(SelectionEvent e) {
169:                                getIntroduceIndirectionRefactoring()
170:                                        .setEnableUpdateReferences(
171:                                                enableReferencesCheckBox
172:                                                        .getSelection());
173:                            }
174:                        });
175:
176:                fIntermediaryTypeName.addModifyListener(new ModifyListener() {
177:                    public void modifyText(ModifyEvent e) {
178:                        validateInput();
179:                    }
180:                });
181:
182:                browseTypes.addSelectionListener(new SelectionAdapter() {
183:                    public void widgetSelected(SelectionEvent e) {
184:                        IType intermediaryType = chooseIntermediaryClass();
185:
186:                        if (intermediaryType == null)
187:                            return;
188:
189:                        fIntermediaryTypeName.setText(intermediaryType
190:                                .getFullyQualifiedName());
191:                    }
192:                });
193:
194:                if (getIntroduceIndirectionRefactoring()
195:                        .canEnableUpdateReferences())
196:                    enableReferencesCheckBox.setSelection(true);
197:                else {
198:                    enableReferencesCheckBox.setSelection(false);
199:                    enableReferencesCheckBox.setEnabled(false);
200:                    getIntroduceIndirectionRefactoring()
201:                            .setEnableUpdateReferences(false);
202:                }
203:
204:                fIntermediaryMethodName.setFocus();
205:                fIntermediaryMethodName.selectAll();
206:                validateInput();
207:
208:                PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
209:                        IJavaHelpContextIds.INTRODUCE_INDIRECTION_WIZARD_PAGE);
210:            }
211:
212:            private IType chooseIntermediaryClass() {
213:                IJavaProject proj = getIntroduceIndirectionRefactoring()
214:                        .getProject();
215:
216:                if (proj == null)
217:                    return null;
218:
219:                IJavaElement[] elements = new IJavaElement[] { proj };
220:                IJavaSearchScope scope = SearchEngine
221:                        .createJavaSearchScope(elements);
222:
223:                FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog(
224:                        getShell(), false, getWizard().getContainer(), scope,
225:                        IJavaSearchConstants.CLASS);
226:
227:                dialog
228:                        .setTitle(RefactoringMessages.IntroduceIndirectionInputPage_dialog_choose_declaring_class);
229:                dialog
230:                        .setMessage(RefactoringMessages.IntroduceIndirectionInputPage_dialog_choose_declaring_class_long);
231:
232:                if (dialog.open() == Window.OK) {
233:                    return (IType) dialog.getFirstResult();
234:                }
235:                return null;
236:            }
237:
238:            private IntroduceIndirectionRefactoring getIntroduceIndirectionRefactoring() {
239:                return (IntroduceIndirectionRefactoring) getRefactoring();
240:            }
241:
242:            private void validateInput() {
243:                RefactoringStatus merged = new RefactoringStatus();
244:                merged.merge(getIntroduceIndirectionRefactoring()
245:                        .setIntermediaryClassName(
246:                                fIntermediaryTypeName.getText()));
247:                merged.merge(getIntroduceIndirectionRefactoring()
248:                        .setIntermediaryMethodName(
249:                                fIntermediaryMethodName.getText()));
250:
251:                setPageComplete(!merged.hasError());
252:                int severity = merged.getSeverity();
253:                String message = merged.getMessageMatchingSeverity(severity);
254:                if (severity >= RefactoringStatus.INFO) {
255:                    setMessage(message, severity);
256:                } else {
257:                    setMessage("", NONE); //$NON-NLS-1$
258:                }
259:            }
260:
261:            protected boolean performFinish() {
262:                storeIntermediaryTypeName();
263:                return super .performFinish();
264:            }
265:
266:            public IWizardPage getNextPage() {
267:                storeIntermediaryTypeName();
268:                return super .getNextPage();
269:            }
270:
271:            private void storeIntermediaryTypeName() {
272:                String destination = fIntermediaryTypeName.getText();
273:                if (!fgIntermediaryTypes.remove(destination)
274:                        && fgIntermediaryTypes.size() >= INTERMEDIARY_TYPE_COUNT)
275:                    fgIntermediaryTypes.remove(fgIntermediaryTypes.size() - 1);
276:                fgIntermediaryTypes.add(0, destination);
277:            }
278:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.