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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.refactoring;
13 import java.lang.reflect.Constructor;
14 import java.lang.reflect.InvocationTargetException;
16 import org.eclipse.swt.widgets.Shell;
18 import org.eclipse.core.runtime.CoreException;
20 import org.eclipse.ltk.core.refactoring.Refactoring;
21 import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
23 import org.eclipse.jdt.ui.refactoring.RefactoringSaveHelper;
25 import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter;
28 * Opens the user interface for a given refactoring.
30 public class UserInterfaceStarter {
32 private RefactoringWizard fWizard;
35 * Initializes this user interface starter with the given
38 * @param wizard the refactoring wizard to use
40 public void initialize(RefactoringWizard wizard) {
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.
50 * Subclasses may override to open a different user interface
52 * @param refactoring the refactoring for which the user interface
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
59 * @exception CoreException if the user interface can't be activated
61 public boolean activate(Refactoring refactoring, Shell parent, int saveMode) throws CoreException {
62 String title= fWizard.getDefaultPageTitle();
64 title= ""; //$NON-NLS-1$
65 return new RefactoringStarter().activate(fWizard, parent, title, saveMode);
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});