KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > refactoring > UserInterfaceStarter


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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 org.eclipse.core.runtime.CoreException;
14
15 import org.eclipse.swt.widgets.Shell;
16
17 import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter;
18
19 import org.eclipse.ltk.core.refactoring.Refactoring;
20 import org.eclipse.ltk.ui.refactoring.RefactoringWizard;
21
22 /**
23  * Opens the user interface for a given refactoring.
24  */

25 public class UserInterfaceStarter {
26     
27     private RefactoringWizard fWizard;
28     
29     /**
30      * Initializes this user interface starter with the given
31      * wizard.
32      *
33      * @param wizard the refactoring wizard to use
34      */

35     public void initialize(RefactoringWizard wizard) {
36         fWizard= wizard;
37     }
38     
39     /**
40      * Actually activates the user interface. This default implementation
41      * assumes that the configuration element passed to <code>initialize
42      * </code> has an attribute wizard denoting the wizard class to be
43      * used for the given refactoring.
44      * <p>
45      * Subclasses may override to open a different user interface
46      *
47      * @param refactoring the refactoring for which the user interface
48      * should be opened
49      * @param parent the parent shell to be used
50      * @param saveMode a save mode from {@link RefactoringSaveHelper}
51      * @return <code>true</code> iff the refactoring was executed,
52      * <code>false</code> otherwise
53      *
54      * @exception CoreException if the user interface can't be activated
55      */

56     public boolean activate(Refactoring refactoring, Shell parent, int saveMode) throws CoreException {
57         String JavaDoc title= fWizard.getDefaultPageTitle();
58         if (title == null)
59             title= ""; //$NON-NLS-1$
60
return new RefactoringStarter().activate(refactoring, fWizard, parent, title, saveMode);
61     }
62 }
63
Popular Tags