update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / refactoring / inline / InlineFieldDialog.java
blob4dbbfedebb87495bf32cecafcab3e75fd34c69d1
1 /*
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.inline;
18 import com.intellij.openapi.help.HelpManager;
19 import com.intellij.openapi.project.Project;
20 import com.intellij.psi.PsiField;
21 import com.intellij.psi.PsiReferenceExpression;
22 import com.intellij.psi.PsiSubstitutor;
23 import com.intellij.psi.util.PsiFormatUtil;
24 import com.intellij.refactoring.HelpID;
25 import com.intellij.refactoring.RefactoringBundle;
26 import com.intellij.refactoring.JavaRefactoringSettings;
28 public class InlineFieldDialog extends InlineOptionsDialog {
29 public static final String REFACTORING_NAME = RefactoringBundle.message("inline.field.title");
30 private final PsiReferenceExpression myReferenceExpression;
32 private final PsiField myField;
34 public InlineFieldDialog(Project project, PsiField field, PsiReferenceExpression ref) {
35 super(project, true, field);
36 myField = field;
37 myReferenceExpression = ref;
38 myInvokedOnReference = myReferenceExpression != null;
40 setTitle(REFACTORING_NAME);
42 init();
45 protected String getNameLabelText() {
46 String fieldText = PsiFormatUtil.formatVariable(myField, PsiFormatUtil.SHOW_NAME | PsiFormatUtil.SHOW_TYPE,PsiSubstitutor.EMPTY);
47 return RefactoringBundle.message("inline.field.field.name.label", fieldText);
50 protected String getBorderTitle() {
51 return RefactoringBundle.message("inline.field.border.title");
54 protected String getInlineThisText() {
55 return RefactoringBundle.message("this.reference.only.and.keep.the.field");
58 protected String getInlineAllText() {
59 return RefactoringBundle.message("all.references.and.remove.the.field");
62 protected boolean isInlineThis() {
63 return JavaRefactoringSettings.getInstance().INLINE_FIELD_THIS;
66 protected void doAction() {
67 invokeRefactoring(new InlineConstantFieldProcessor(myField, getProject(), myReferenceExpression, isInlineThisOnly()));
68 JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
69 if(myRbInlineThisOnly.isEnabled() && myRbInlineAll.isEnabled()) {
70 settings.INLINE_FIELD_THIS = isInlineThisOnly();
74 protected void doHelpAction() {
75 HelpManager.getInstance().invokeHelp(HelpID.INLINE_FIELD);