]>
Commit | Line | Data |
---|---|---|
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 | *******************************************************************************/ | |
11 | package org.eclipse.jdt.internal.ui.refactoring.nls; | |
12 | ||
13 | import org.eclipse.swt.custom.BusyIndicator; | |
14 | import org.eclipse.swt.widgets.Display; | |
15 | import org.eclipse.swt.widgets.Shell; | |
16 | ||
17 | import org.eclipse.jface.wizard.IWizardPage; | |
18 | ||
19 | import org.eclipse.ltk.ui.refactoring.RefactoringWizard; | |
20 | ||
21 | import org.eclipse.jdt.core.ICompilationUnit; | |
22 | ||
23 | import org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring; | |
24 | import org.eclipse.jdt.internal.corext.util.Messages; | |
25 | ||
26 | import org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper; | |
27 | ||
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; | |
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 | */ | |
37 | public 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.setMessage(NLSUIMessages.ExternalizeWizard_select); | |
55 | addPage(page); | |
56 | ||
57 | /*ExternalizeWizardPage2 page2= new ExternalizeWizardPage2(nlsRefac); | |
58 | page2.setMessage(NLSUIMessages.getString("wizard.select_values")); //$NON-NLS-1$ | |
59 | addPage(page2);*/ | |
60 | } | |
61 | ||
62 | @Override | |
63 | public boolean canFinish() { | |
64 | IWizardPage page= getContainer().getCurrentPage(); | |
65 | return super.canFinish() && !(page instanceof ExternalizeWizardPage); | |
66 | } | |
67 | ||
68 | public static void open(final ICompilationUnit unit, final Shell shell) { | |
69 | if (unit == null || !unit.exists()) { | |
70 | return; | |
71 | } | |
72 | Display display= shell != null ? shell.getDisplay() : Display.getCurrent(); | |
73 | BusyIndicator.showWhile(display, new Runnable() { | |
74 | public void run() { | |
75 | NLSRefactoring refactoring= NLSRefactoring.create(unit); | |
76 | if (refactoring != null) | |
77 | new RefactoringStarter().activate(new ExternalizeWizard(refactoring), shell, ActionMessages.ExternalizeStringsAction_dialog_title, RefactoringSaveHelper.SAVE_REFACTORING); | |
78 | } | |
79 | }); | |
80 | } | |
81 | } |