KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > refactoring > InlineTempWizard


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.refactoring;
12
13 import org.eclipse.swt.widgets.Composite;
14
15 import org.eclipse.ui.PlatformUI;
16
17 import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
18
19 import org.eclipse.jdt.internal.corext.refactoring.code.InlineTempRefactoring;
20 import org.eclipse.jdt.internal.corext.util.Messages;
21
22 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
23
24 public class InlineTempWizard extends RefactoringWizard {
25
26     public InlineTempWizard(InlineTempRefactoring ref) {
27         super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE | NO_BACK_BUTTON_ON_STATUS_DIALOG);
28         setDefaultPageTitle(RefactoringMessages.InlineTempWizard_defaultPageTitle);
29     }
30
31     protected void addUserInputPages() {
32         addPage(new InlineTempInputPage());
33     }
34
35     public int getMessageLineWidthInChars() {
36         return 0;
37     }
38     
39     private static class InlineTempInputPage extends MessageWizardPage {
40
41         public static final String JavaDoc PAGE_NAME= "InlineTempInputPage"; //$NON-NLS-1$
42

43         public InlineTempInputPage() {
44             super(PAGE_NAME, true, MessageWizardPage.STYLE_QUESTION);
45         }
46         
47         public void createControl(Composite parent) {
48             super.createControl(parent);
49             PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.INLINE_TEMP_WIZARD_PAGE);
50         }
51         
52         protected String JavaDoc getMessageString() {
53             InlineTempRefactoring refactoring= (InlineTempRefactoring) getRefactoring();
54             int occurrences= refactoring.getReferences().length;
55             final String JavaDoc identifier= refactoring.getVariableDeclaration().getName().getIdentifier();
56             switch (occurrences) {
57                 case 0:
58                     return Messages.format(
59                             RefactoringMessages.InlineTempInputPage_message_zero,
60                             identifier);
61
62                 case 1:
63                     return Messages.format(RefactoringMessages.InlineTempInputPage_message_one, identifier);
64
65                 default:
66                     return Messages.format(RefactoringMessages.InlineTempInputPage_message_multi, new Object JavaDoc[] {
67                             new Integer JavaDoc(occurrences), identifier });
68             }
69         }
70     }
71 }
72
Popular Tags