]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2000, 2011 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.ui.actions; | |
12 | ||
13 | import org.eclipse.jface.text.ITextSelection; | |
14 | ||
15 | import org.eclipse.ui.PlatformUI; | |
16 | ||
17 | import org.eclipse.jdt.internal.corext.refactoring.RefactoringAvailabilityTester; | |
18 | ||
19 | import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; | |
20 | import org.eclipse.jdt.internal.ui.actions.SelectionConverter; | |
21 | import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; | |
22 | import org.eclipse.jdt.internal.ui.javaeditor.JavaTextSelection; | |
23 | import org.eclipse.jdt.internal.ui.refactoring.RefactoringMessages; | |
24 | ||
25 | /** | |
26 | * Introduces a new method parameter from a selected expression. | |
27 | * | |
28 | * <p> | |
29 | * This class may be instantiated; it is not intended to be subclassed. | |
30 | * </p> | |
31 | * | |
32 | * @since 3.0 | |
33 | * @noextend This class is not intended to be subclassed by clients. | |
34 | */ | |
35 | public class IntroduceParameterAction extends SelectionDispatchAction { | |
36 | ||
37 | public final JavaEditor fEditor; | |
38 | ||
39 | /** | |
40 | * Note: This constructor is for internal use only. Clients should not call this constructor. | |
41 | * @param editor the java editor | |
42 | * | |
43 | * @noreference This constructor is not intended to be referenced by clients. | |
44 | */ | |
45 | public IntroduceParameterAction(JavaEditor editor) { | |
46 | super(editor.getEditorSite()); | |
47 | setText(RefactoringMessages.IntroduceParameterAction_label); | |
48 | fEditor= editor; | |
49 | setEnabled(SelectionConverter.getInputAsCompilationUnit(fEditor) != null); | |
50 | PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.INTRODUCE_PARAMETER_ACTION); | |
51 | } | |
52 | ||
53 | /* (non-Javadoc) | |
54 | * Method declared on SelectionDispatchAction | |
55 | */ | |
56 | @Override | |
57 | public void selectionChanged(ITextSelection selection) { | |
58 | setEnabled((fEditor != null && SelectionConverter.getInputAsCompilationUnit(fEditor) != null)); | |
59 | } | |
60 | ||
61 | /** | |
62 | * Note: This method is for internal use only. Clients should not call this method. | |
63 | * | |
64 | * @param selection the Java text selection | |
65 | * @noreference This method is not intended to be referenced by clients. | |
66 | */ | |
67 | @Override | |
68 | public void selectionChanged(JavaTextSelection selection) { | |
69 | setEnabled(RefactoringAvailabilityTester.isIntroduceParameterAvailable(selection)); | |
70 | } | |
71 | ||
72 | /* (non-Javadoc) | |
73 | * Method declared on SelectionDispatchAction | |
74 | */ | |
75 | @Override | |
76 | public void run(ITextSelection selection) { | |
77 | fEditor.generated_2420795659612852737(this, selection); | |
78 | } | |
79 | } |