KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 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 java.lang.reflect.InvocationTargetException JavaDoc;
14
15 import org.eclipse.core.runtime.IProgressMonitor;
16
17 import org.eclipse.swt.widgets.Composite;
18
19 import org.eclipse.jface.operation.IRunnableWithProgress;
20
21 import org.eclipse.ui.PlatformUI;
22
23 import org.eclipse.jdt.internal.corext.refactoring.structure.ExtractSupertypeProcessor;
24 import org.eclipse.jdt.internal.corext.refactoring.structure.ExtractSupertypeRefactoring;
25
26 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
27 import org.eclipse.jdt.internal.ui.JavaPlugin;
28
29 /**
30  * Wizard page to select methods to be deleted after extract supertype.
31  *
32  * @since 3.2
33  */

34 public class ExtractSupertypeMethodPage extends PullUpMethodPage {
35
36     /**
37      * Returns the extract supertype refactoring.
38      */

39     public ExtractSupertypeRefactoring getExtractSuperTypeRefactoring() {
40         return (ExtractSupertypeRefactoring) getRefactoring();
41     }
42
43     /**
44      * Returns the refactoring processor.
45      *
46      * @return the refactoring processor
47      */

48     protected ExtractSupertypeProcessor getProcessor() {
49         return getExtractSuperTypeRefactoring().getExtractSupertypeProcessor();
50     }
51
52     /**
53      * {@inheritDoc}
54      */

55     public void createControl(Composite parent) {
56         super.createControl(parent);
57         PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.EXTRACT_SUPERTYPE_WIZARD_PAGE);
58     }
59     
60     /**
61      * {@inheritDoc}
62      */

63     public void setVisible(final boolean visible) {
64         if (visible) {
65             final ExtractSupertypeProcessor processor= getProcessor();
66             processor.resetChanges();
67             try {
68                 getWizard().getContainer().run(false, false, new IRunnableWithProgress() {
69
70                     public void run(final IProgressMonitor monitor) throws InvocationTargetException JavaDoc, InterruptedException JavaDoc {
71                         processor.createWorkingCopyLayer(monitor);
72                     }
73                 });
74             } catch (InvocationTargetException JavaDoc exception) {
75                 JavaPlugin.log(exception);
76             } catch (InterruptedException JavaDoc exception) {
77                 // Does not happen
78
}
79         }
80         super.setVisible(visible);
81     }
82 }
83
Popular Tags