01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.ui.refactoring;
11:
12: import org.eclipse.core.runtime.CoreException;
13:
14: import org.eclipse.swt.widgets.Shell;
15:
16: import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter;
17:
18: import org.eclipse.ltk.core.refactoring.Refactoring;
19: import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
20:
21: /**
22: * Opens the user interface for a given refactoring.
23: */
24: public class UserInterfaceStarter {
25:
26: private RefactoringWizard fWizard;
27:
28: /**
29: * Initializes this user interface starter with the given
30: * wizard.
31: *
32: * @param wizard the refactoring wizard to use
33: */
34: public void initialize(RefactoringWizard wizard) {
35: fWizard = wizard;
36: }
37:
38: /**
39: * Actually activates the user interface. This default implementation
40: * assumes that the configuration element passed to <code>initialize
41: * </code> has an attribute wizard denoting the wizard class to be
42: * used for the given refactoring.
43: * <p>
44: * Subclasses may override to open a different user interface
45: *
46: * @param refactoring the refactoring for which the user interface
47: * should be opened
48: * @param parent the parent shell to be used
49: * @param saveMode a save mode from {@link RefactoringSaveHelper}
50: * @return <code>true</code> iff the refactoring was executed,
51: * <code>false</code> otherwise
52: *
53: * @exception CoreException if the user interface can't be activated
54: */
55: public boolean activate(Refactoring refactoring, Shell parent,
56: int saveMode) throws CoreException {
57: String title = fWizard.getDefaultPageTitle();
58: if (title == null)
59: title = ""; //$NON-NLS-1$
60: return new RefactoringStarter().activate(refactoring, fWizard,
61: parent, title, saveMode);
62: }
63: }
|