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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.refactoring.nls;
13 import org.eclipse.swt.custom.BusyIndicator;
14 import org.eclipse.swt.widgets.Display;
15 import org.eclipse.swt.widgets.Shell;
17 import org.eclipse.jface.wizard.IWizardPage;
19 import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
21 import org.eclipse.jdt.core.ICompilationUnit;
23 import org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring;
24 import org.eclipse.jdt.internal.corext.util.Messages;
26 import org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper;
28 import org.eclipse.jdt.internal.ui.JavaPluginImages;
29 import org.eclipse.jdt.internal.ui.actions.ActionMessages;
30 import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter;
31 import org.eclipse.jdt.internal.ui.viewsupport.BasicElementLabels;
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)
37 public class ExternalizeWizard extends RefactoringWizard {
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);
47 * @see RefactoringWizard#addUserInputPages()
50 protected void addUserInputPages() {
52 NLSRefactoring nlsRefac= (NLSRefactoring) getRefactoring();
53 ExternalizeWizardPage page= new ExternalizeWizardPage(nlsRefac);
54 page.generated_1159564774291516404(this);
56 /*ExternalizeWizardPage2 page2= new ExternalizeWizardPage2(nlsRefac);
57 page2.setMessage(NLSUIMessages.getString("wizard.select_values")); //$NON-NLS-1$
62 public boolean canFinish() {
63 IWizardPage page= getContainer().getCurrentPage();
64 return super.canFinish() && !(page instanceof ExternalizeWizardPage);
67 public static void open(final ICompilationUnit unit, final Shell shell) {
68 if (unit == null || !unit.exists()) {
71 Display display= shell != null ? shell.getDisplay() : Display.getCurrent();
72 BusyIndicator.showWhile(display, new Runnable() {
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);