]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-after/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/ExternalizeWizard.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui refactoring / org / eclipse / jdt / internal / ui / refactoring / nls / ExternalizeWizard.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.nls;
12
13import org.eclipse.swt.custom.BusyIndicator;
14import org.eclipse.swt.widgets.Display;
15import org.eclipse.swt.widgets.Shell;
16
17import org.eclipse.jface.wizard.IWizardPage;
18
19import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
20
21import org.eclipse.jdt.core.ICompilationUnit;
22
23import org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring;
24import org.eclipse.jdt.internal.corext.util.Messages;
25
26import org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper;
27
28import org.eclipse.jdt.internal.ui.JavaPluginImages;
29import org.eclipse.jdt.internal.ui.actions.ActionMessages;
30import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter;
31import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
32
33/**
34 * good citizen problems - wizard is only valid after constructor (when the pages toggle
35 * some values and force an validate the validate can't get a wizard)
36 */
37public class ExternalizeWizard extends RefactoringWizard {
38
39 public ExternalizeWizard(NLSRefactoring refactoring) {
40 super(refactoring,CHECK_INITIAL_CONDITIONS_ON_OPEN | WIZARD_BASED_USER_INTERFACE);
41 setDefaultPageTitle(Messages.format(NLSUIMessages.ExternalizeWizardPage_title, BasicElementLabels.getFileName(refactoring.getCu())));
42 setWindowTitle(NLSUIMessages.ExternalizeWizard_name);
43 setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_EXTERNALIZE_STRINGS);
44 }
45
46 /**
47 * @see RefactoringWizard#addUserInputPages()
48 */
49 @Override
50 protected void addUserInputPages() {
51
52 NLSRefactoring nlsRefac= (NLSRefactoring) getRefactoring();
53 ExternalizeWizardPage page= new ExternalizeWizardPage(nlsRefac);
54 page.generated_1159564774291516404(this);
55
56 /*ExternalizeWizardPage2 page2= new ExternalizeWizardPage2(nlsRefac);
57 page2.setMessage(NLSUIMessages.getString("wizard.select_values")); //$NON-NLS-1$
58 addPage(page2);*/
59 }
60
61 @Override
62 public boolean canFinish() {
63 IWizardPage page= getContainer().getCurrentPage();
64 return super.canFinish() && !(page instanceof ExternalizeWizardPage);
65 }
66
67 public static void open(final ICompilationUnit unit, final Shell shell) {
68 if (unit == null || !unit.exists()) {
69 return;
70 }
71 Display display= shell != null ? shell.getDisplay() : Display.getCurrent();
72 BusyIndicator.showWhile(display, new Runnable() {
73 public void run() {
74 NLSRefactoring refactoring= NLSRefactoring.create(unit);
75 if (refactoring != null)
76 new RefactoringStarter().activate(new ExternalizeWizard(refactoring), shell, ActionMessages.ExternalizeStringsAction_dialog_title, RefactoringSaveHelper.SAVE_REFACTORING);
77 }
78 });
79 }
80}