c9240a4cf8ecf6a8e1048c5bb0ab81a7ff5453ab
[idea/community.git] / python / src / com / jetbrains / python / refactoring / move / makeFunctionTopLevel / PyMakeFunctionTopLevelDialog.java
1 /*
2  * Copyright 2000-2015 JetBrains s.r.o.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package com.jetbrains.python.refactoring.move.makeFunctionTopLevel;
17
18 import com.intellij.openapi.project.Project;
19 import com.jetbrains.python.PyBundle;
20 import com.jetbrains.python.psi.PyFunction;
21 import com.jetbrains.python.refactoring.move.PyBaseMoveDialog;
22 import com.jetbrains.python.refactoring.move.PyMoveRefactoringUtil;
23 import org.jetbrains.annotations.NotNull;
24 import org.jetbrains.annotations.Nullable;
25
26 /**
27  * @author Mikhail Golubev
28  */
29 public class PyMakeFunctionTopLevelDialog extends PyBaseMoveDialog {
30
31   public PyMakeFunctionTopLevelDialog(@NotNull Project project,
32                                       @NotNull PyFunction function, 
33                                       @NotNull String sourcePath,
34                                       @NotNull String destinationPath) {
35     super(project, sourcePath, destinationPath);
36     final String functionName = PyMoveRefactoringUtil.getCompactPresentableName(function);
37     if (function.getContainingClass() != null) {
38       setTitle(PyBundle.message("refactoring.make.method.top.level.dialog.title"));
39       myDescription.setText(PyBundle.message("refactoring.make.method.top.level.dialog.description", functionName));
40     }
41     else {
42       setTitle(PyBundle.message("refactoring.make.local.function.top.level.dialog.title"));
43       myDescription.setText(PyBundle.message("refactoring.make.local.function.top.level.dialog.description", functionName));
44     }
45     if (function.getContainingClass() != null) {
46       myDescription.setText("Make top-level function from method ");
47     }
48     myExtraPanel.setVisible(false);
49     init();
50   }
51
52   @Override
53   protected String getHelpId() {
54     return "python.reference.makeFunctionTopLevel";
55   }
56
57   @Nullable
58   @Override
59   protected String getDimensionServiceKey() {
60     return "#com.jetbrains.python.refactoring.move.PyMakeFunctionTopLevelDialog";
61   }
62 }