2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.refactoring
.convertToInstanceMethod
;
18 import com
.intellij
.openapi
.diagnostic
.Logger
;
19 import com
.intellij
.openapi
.help
.HelpManager
;
20 import com
.intellij
.psi
.PsiMethod
;
21 import com
.intellij
.psi
.PsiParameter
;
22 import com
.intellij
.psi
.PsiVariable
;
23 import com
.intellij
.refactoring
.HelpID
;
24 import com
.intellij
.refactoring
.RefactoringBundle
;
25 import com
.intellij
.refactoring
.move
.moveInstanceMethod
.MoveInstanceMethodDialogBase
;
32 public class ConvertToInstanceMethodDialog
extends MoveInstanceMethodDialogBase
{
33 private static final Logger LOG
= Logger
.getInstance("#com.intellij.refactoring.convertToInstanceMethod.ConvertToInstanceMethodDialog");
34 public ConvertToInstanceMethodDialog(final PsiMethod method
, final PsiParameter
[] variables
) {
35 super(method
, variables
, ConvertToInstanceMethodHandler
.REFACTORING_NAME
);
39 protected void doAction() {
40 final PsiVariable targetVariable
= (PsiVariable
)myList
.getSelectedValue();
41 LOG
.assertTrue(targetVariable
instanceof PsiParameter
);
42 final ConvertToInstanceMethodProcessor processor
= new ConvertToInstanceMethodProcessor(myMethod
.getProject(),
43 myMethod
, (PsiParameter
)targetVariable
,
44 myVisibilityPanel
.getVisibility());
45 if (!verifyTargetClass(processor
.getTargetClass())) return;
46 invokeRefactoring(processor
);
49 protected void doHelpAction() {
50 HelpManager
.getInstance().invokeHelp(HelpID
.CONVERT_TO_INSTANCE_METHOD
);
53 protected JComponent
createCenterPanel() {
54 final Box vBox
= Box
.createVerticalBox();
55 final Box labelBox
= Box
.createHorizontalBox();
56 final JLabel label
= new JLabel();
58 labelBox
.add(Box
.createHorizontalGlue());
60 vBox
.add(Box
.createVerticalStrut(4));
62 vBox
.add(createListAndVisibilityPanels());
63 label
.setText(RefactoringBundle
.message("moveInstanceMethod.select.an.instance.parameter"));