]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-before/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/InlineTempWizard.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / ui refactoring / org / eclipse / jdt / internal / ui / refactoring / InlineTempWizard.java
CommitLineData
1b2798f6
EK
1/*******************************************************************************
2 * Copyright (c) 2000, 2011 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 *******************************************************************************/
11package org.eclipse.jdt.internal.ui.refactoring;
12
13import org.eclipse.swt.widgets.Composite;
14
15import org.eclipse.ui.PlatformUI;
16
17import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
18
19import org.eclipse.jdt.internal.corext.refactoring.code.InlineTempRefactoring;
20import org.eclipse.jdt.internal.corext.util.Messages;
21
22import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
23import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
24
25public class InlineTempWizard extends RefactoringWizard {
26
27 public InlineTempWizard(InlineTempRefactoring ref) {
28 super(ref, DIALOG_BASED_USER_INTERFACE | PREVIEW_EXPAND_FIRST_NODE | NO_BACK_BUTTON_ON_STATUS_DIALOG);
29 setDefaultPageTitle(RefactoringMessages.InlineTempWizard_defaultPageTitle);
30 }
31
32 @Override
33 protected void addUserInputPages() {
34 addPage(new InlineTempInputPage());
35 }
36
37 @Override
38 public int getMessageLineWidthInChars() {
39 return 0;
40 }
41
42 private static class InlineTempInputPage extends MessageWizardPage {
43
44 public static final String PAGE_NAME= "InlineTempInputPage"; //$NON-NLS-1$
45
46 public InlineTempInputPage() {
47 super(PAGE_NAME, true, MessageWizardPage.STYLE_QUESTION);
48 }
49
50 @Override
51 public void createControl(Composite parent) {
52 super.createControl(parent);
53 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.INLINE_TEMP_WIZARD_PAGE);
54 }
55
56 @Override
57 protected String getMessageString() {
58 InlineTempRefactoring refactoring= (InlineTempRefactoring) getRefactoring();
59 int occurrences= refactoring.getReferences().length;
60 final String identifier= BasicElementLabels.getJavaElementName(refactoring.getVariableDeclaration().getName().getIdentifier());
61 switch (occurrences) {
62 case 0:
63 return Messages.format(
64 RefactoringMessages.InlineTempInputPage_message_zero,
65 identifier);
66
67 case 1:
68 return Messages.format(RefactoringMessages.InlineTempInputPage_message_one, identifier);
69
70 default:
71 return Messages.format(RefactoringMessages.InlineTempInputPage_message_multi, new Object[] {
72 new Integer(occurrences), identifier });
73 }
74 }
75 }
76}