]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2000, 2009 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 java.lang.reflect.Constructor; | |
14 | import java.lang.reflect.InvocationTargetException; | |
15 | ||
16 | import org.eclipse.swt.widgets.Shell; | |
17 | ||
18 | import org.eclipse.core.runtime.CoreException; | |
19 | ||
20 | import org.eclipse.ltk.core.refactoring.Refactoring; | |
21 | import org.eclipse.ltk.ui.refactoring.RefactoringWizard; | |
22 | ||
23 | import org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper; | |
24 | ||
25 | import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter; | |
26 | ||
27 | /** | |
28 | * Opens the user interface for a given refactoring. | |
29 | */ | |
30 | public class UserInterfaceStarter { | |
31 | ||
32 | private RefactoringWizard fWizard; | |
33 | ||
34 | /** | |
35 | * Initializes this user interface starter with the given | |
36 | * wizard. | |
37 | * | |
38 | * @param wizard the refactoring wizard to use | |
39 | */ | |
40 | public void initialize(RefactoringWizard wizard) { | |
41 | fWizard= wizard; | |
42 | } | |
43 | ||
44 | /** | |
45 | * Actually activates the user interface. This default implementation | |
46 | * assumes that the configuration element passed to <code>initialize | |
47 | * </code> has an attribute wizard denoting the wizard class to be | |
48 | * used for the given refactoring. | |
49 | * <p> | |
50 | * Subclasses may override to open a different user interface | |
51 | * | |
52 | * @param refactoring the refactoring for which the user interface | |
53 | * should be opened | |
54 | * @param parent the parent shell to be used | |
55 | * @param saveMode a save mode from {@link RefactoringSaveHelper} | |
56 | * @return <code>true</code> iff the refactoring was executed, | |
57 | * <code>false</code> otherwise | |
58 | * | |
59 | * @exception CoreException if the user interface can't be activated | |
60 | */ | |
61 | public boolean activate(Refactoring refactoring, Shell parent, int saveMode) throws CoreException { | |
62 | String title= fWizard.getDefaultPageTitle(); | |
63 | if (title == null) | |
64 | title= ""; //$NON-NLS-1$ | |
65 | return new RefactoringStarter().activate(fWizard, parent, title, saveMode); | |
66 | } | |
67 | ||
68 | public UserInterfaceStarter generated_7813664409379443177(Refactoring refactoring, Class<? extends RefactoringWizard> wizardClass) throws NoSuchMethodException, | |
69 | InstantiationException, IllegalAccessException, InvocationTargetException { | |
70 | Constructor<? extends RefactoringWizard> constructor= wizardClass.getConstructor(new Class[] {Refactoring.class}); | |
71 | RefactoringWizard wizard= constructor.newInstance(new Object[] {refactoring}); | |
72 | initialize(wizard); | |
73 | return this; | |
74 | } | |
75 | } |