Source Code Cross Referenced for IntroduceParameterWizard.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 org.eclipse.core.runtime.Assert;
013:
014:        import org.eclipse.swt.SWT;
015:        import org.eclipse.swt.events.SelectionAdapter;
016:        import org.eclipse.swt.events.SelectionEvent;
017:        import org.eclipse.swt.layout.GridData;
018:        import org.eclipse.swt.layout.GridLayout;
019:        import org.eclipse.swt.widgets.Button;
020:        import org.eclipse.swt.widgets.Composite;
021:        import org.eclipse.swt.widgets.Control;
022:        import org.eclipse.swt.widgets.Label;
023:
024:        import org.eclipse.jface.dialogs.Dialog;
025:        import org.eclipse.jface.preference.IPreferenceStore;
026:        import org.eclipse.jface.resource.JFaceResources;
027:
028:        import org.eclipse.jface.text.Document;
029:
030:        import org.eclipse.ui.PlatformUI;
031:
032:        import org.eclipse.ltk.core.refactoring.RefactoringStatus;
033:        import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
034:        import org.eclipse.ltk.ui.refactoring.UserInputWizardPage;
035:
036:        import org.eclipse.jdt.core.JavaModelException;
037:
038:        import org.eclipse.jdt.internal.corext.refactoring.ParameterInfo;
039:        import org.eclipse.jdt.internal.corext.refactoring.code.IntroduceParameterRefactoring;
040:
041:        import org.eclipse.jdt.ui.PreferenceConstants;
042:        import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;
043:
044:        import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
045:        import org.eclipse.jdt.internal.ui.JavaPlugin;
046:        import org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer;
047:        import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
048:        import org.eclipse.jdt.internal.ui.util.PixelConverter;
049:
050:        public class IntroduceParameterWizard extends RefactoringWizard {
051:
052:            public IntroduceParameterWizard(IntroduceParameterRefactoring ref) {
053:                super (ref, DIALOG_BASED_USER_INTERFACE
054:                        | PREVIEW_EXPAND_FIRST_NODE);
055:                setDefaultPageTitle(RefactoringMessages.IntroduceParameterWizard_defaultPageTitle);
056:            }
057:
058:            /* non java-doc
059:             * @see RefactoringWizard#addUserInputPages
060:             */
061:            protected void addUserInputPages() {
062:                addPage(new IntroduceParameterInputPage(
063:                        getIntroduceParameterRefactoring()
064:                                .guessParameterNames()));
065:            }
066:
067:            private IntroduceParameterRefactoring getIntroduceParameterRefactoring() {
068:                return (IntroduceParameterRefactoring) getRefactoring();
069:            }
070:
071:            private static class IntroduceParameterInputPage extends
072:                    UserInputWizardPage {
073:
074:                private static final String DESCRIPTION = RefactoringMessages.IntroduceParameterInputPage_description;
075:                public static final String PAGE_NAME = "IntroduceParameterInputPage";//$NON-NLS-1$
076:                private String[] fParamNameProposals;
077:
078:                private JavaSourceViewer fSignaturePreview;
079:                private Document fSignaturePreviewDocument;
080:                private Button fLeaveDelegateCheckBox;
081:                private Button fDeprecateDelegateCheckBox;
082:
083:                public IntroduceParameterInputPage(String[] tempNameProposals) {
084:                    super (PAGE_NAME);
085:                    setDescription(DESCRIPTION);
086:                    Assert.isNotNull(tempNameProposals);
087:                    fParamNameProposals = tempNameProposals;
088:                    fSignaturePreviewDocument = new Document();
089:                }
090:
091:                private IntroduceParameterRefactoring getIntroduceParameterRefactoring() {
092:                    return (IntroduceParameterRefactoring) getRefactoring();
093:                }
094:
095:                public void createControl(Composite parent) {
096:                    Composite result = new Composite(parent, SWT.NONE);
097:                    setControl(result);
098:                    GridLayout layout = new GridLayout();
099:                    result.setLayout(layout);
100:
101:                    createParameterTableControl(result);
102:                    fLeaveDelegateCheckBox = DelegateUIHelper
103:                            .generateLeaveDelegateCheckbox(result,
104:                                    getRefactoring(), false);
105:                    if (fLeaveDelegateCheckBox != null) {
106:                        fDeprecateDelegateCheckBox = new Button(result,
107:                                SWT.CHECK);
108:                        GridData data = new GridData();
109:                        data.horizontalAlignment = GridData.FILL;
110:                        data.horizontalIndent = (layout.marginWidth + fDeprecateDelegateCheckBox
111:                                .computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
112:                        fDeprecateDelegateCheckBox.setLayoutData(data);
113:                        fDeprecateDelegateCheckBox.setText(DelegateUIHelper
114:                                .getDeprecateDelegateCheckBoxTitle());
115:                        final IntroduceParameterRefactoring refactoring = getIntroduceParameterRefactoring();
116:                        fDeprecateDelegateCheckBox
117:                                .setSelection(DelegateUIHelper
118:                                        .loadDeprecateDelegateSetting(refactoring));
119:                        refactoring
120:                                .setDeprecateDelegates(fDeprecateDelegateCheckBox
121:                                        .getSelection());
122:                        fDeprecateDelegateCheckBox
123:                                .addSelectionListener(new SelectionAdapter() {
124:                                    public void widgetSelected(SelectionEvent e) {
125:                                        refactoring
126:                                                .setDeprecateDelegates(fDeprecateDelegateCheckBox
127:                                                        .getSelection());
128:                                    }
129:                                });
130:                        fDeprecateDelegateCheckBox
131:                                .setEnabled(fLeaveDelegateCheckBox
132:                                        .getSelection());
133:                        fLeaveDelegateCheckBox
134:                                .addSelectionListener(new SelectionAdapter() {
135:                                    public void widgetSelected(SelectionEvent e) {
136:                                        fDeprecateDelegateCheckBox
137:                                                .setEnabled(fLeaveDelegateCheckBox
138:                                                        .getSelection());
139:                                    }
140:                                });
141:                    }
142:                    Label sep = new Label(result, SWT.SEPARATOR
143:                            | SWT.HORIZONTAL);
144:                    sep.setLayoutData((new GridData(GridData.FILL_HORIZONTAL)));
145:                    createSignaturePreview(result);
146:
147:                    update(false);
148:                    Dialog.applyDialogFont(result);
149:                    PlatformUI
150:                            .getWorkbench()
151:                            .getHelpSystem()
152:                            .setHelp(
153:                                    getControl(),
154:                                    IJavaHelpContextIds.INTRODUCE_PARAMETER_WIZARD_PAGE);
155:                }
156:
157:                private ChangeParametersControl createParameterTableControl(
158:                        Composite composite) {
159:                    String labelText = RefactoringMessages.IntroduceParameterWizard_parameters;
160:                    ChangeParametersControl cp = new ChangeParametersControl(
161:                            composite, SWT.NONE, labelText,
162:                            new IParameterListChangeListener() {
163:                                public void parameterChanged(
164:                                        ParameterInfo parameter) {
165:                                    update(true);
166:                                }
167:
168:                                public void parameterListChanged() {
169:                                    update(true);
170:                                }
171:
172:                                public void parameterAdded(
173:                                        ParameterInfo parameter) {
174:                                    update(true);
175:                                }
176:                            },
177:                            ChangeParametersControl.Mode.INTRODUCE_PARAMETER,
178:                            fParamNameProposals);
179:                    cp.setLayoutData(new GridData(GridData.FILL_BOTH));
180:                    cp.setInput(getIntroduceParameterRefactoring()
181:                            .getParameterInfos());
182:                    cp.editParameter(getIntroduceParameterRefactoring()
183:                            .getAddedParameterInfo());
184:                    return cp;
185:                }
186:
187:                public void dispose() {
188:                    DelegateUIHelper
189:                            .saveLeaveDelegateSetting(fLeaveDelegateCheckBox);
190:                    DelegateUIHelper
191:                            .saveDeprecateDelegateSetting(fDeprecateDelegateCheckBox);
192:                    super .dispose();
193:                }
194:
195:                private void createSignaturePreview(Composite composite) {
196:                    Label previewLabel = new Label(composite, SWT.NONE);
197:                    previewLabel
198:                            .setText(RefactoringMessages.ChangeSignatureInputPage_method_Signature_Preview);
199:
200:                    IPreferenceStore store = JavaPlugin.getDefault()
201:                            .getCombinedPreferenceStore();
202:                    fSignaturePreview = new JavaSourceViewer(composite, null,
203:                            null, false, SWT.READ_ONLY | SWT.V_SCROLL
204:                                    | SWT.WRAP /*| SWT.BORDER*/, store);
205:                    fSignaturePreview
206:                            .configure(new JavaSourceViewerConfiguration(
207:                                    JavaPlugin.getDefault().getJavaTextTools()
208:                                            .getColorManager(), store, null,
209:                                    null));
210:                    fSignaturePreview
211:                            .getTextWidget()
212:                            .setFont(
213:                                    JFaceResources
214:                                            .getFont(PreferenceConstants.EDITOR_TEXT_FONT));
215:                    fSignaturePreview.getTextWidget().setBackground(
216:                            composite.getBackground());
217:                    fSignaturePreview.setDocument(fSignaturePreviewDocument);
218:                    fSignaturePreview.setEditable(false);
219:
220:                    //Layouting problems with wrapped text: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=9866
221:                    Control signaturePreviewControl = fSignaturePreview
222:                            .getControl();
223:                    PixelConverter pixelConverter = new PixelConverter(
224:                            signaturePreviewControl);
225:                    GridData gdata = new GridData(GridData.FILL_BOTH);
226:                    gdata.widthHint = pixelConverter
227:                            .convertWidthInCharsToPixels(50);
228:                    gdata.heightHint = pixelConverter
229:                            .convertHeightInCharsToPixels(2);
230:                    signaturePreviewControl.setLayoutData(gdata);
231:                }
232:
233:                private void update(boolean displayErrorMessage) {
234:                    updateStatus(displayErrorMessage);
235:                    updateSignaturePreview();
236:                }
237:
238:                private void updateStatus(boolean displayErrorMessage) {
239:                    RefactoringStatus nameCheck = getIntroduceParameterRefactoring()
240:                            .validateInput();
241:                    if (displayErrorMessage) {
242:                        setPageComplete(nameCheck);
243:                    } else {
244:                        setErrorMessage(null);
245:                        setPageComplete(true);
246:                    }
247:                }
248:
249:                private void updateSignaturePreview() {
250:                    try {
251:                        int top = fSignaturePreview.getTextWidget()
252:                                .getTopPixel();
253:                        fSignaturePreviewDocument
254:                                .set(getIntroduceParameterRefactoring()
255:                                        .getMethodSignaturePreview());
256:                        fSignaturePreview.getTextWidget().setTopPixel(top);
257:                    } catch (JavaModelException e) {
258:                        ExceptionHandler
259:                                .handle(
260:                                        e,
261:                                        RefactoringMessages.IntroduceParameterWizard_defaultPageTitle,
262:                                        RefactoringMessages.ChangeSignatureInputPage_exception);
263:                    }
264:                }
265:
266:            }
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.