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
.codeInspection
.i18n
;
18 import com
.intellij
.lang
.properties
.psi
.PropertiesFile
;
19 import com
.intellij
.lang
.properties
.references
.CreatePropertyFix
;
20 import com
.intellij
.lang
.properties
.references
.I18nizeQuickFixDialog
;
21 import com
.intellij
.openapi
.project
.Project
;
22 import com
.intellij
.openapi
.util
.Pair
;
23 import com
.intellij
.psi
.PsiElement
;
24 import com
.intellij
.psi
.PsiFile
;
25 import com
.intellij
.psi
.PsiLiteralExpression
;
26 import org
.jetbrains
.annotations
.NotNull
;
27 import org
.jetbrains
.annotations
.Nullable
;
29 import java
.util
.List
;
32 * Created by IntelliJ IDEA.
33 * User: Maxim.Mossienko
36 * To change this template use File | Settings | File Templates.
38 public class JavaCreatePropertyFix
extends CreatePropertyFix
{
39 public JavaCreatePropertyFix() {}
41 public JavaCreatePropertyFix(PsiElement element
, String key
, final List
<PropertiesFile
> propertiesFiles
) {
42 super(element
, key
, propertiesFiles
);
46 protected static Pair
<String
, String
> invokeAction(@NotNull final Project project
,
47 @NotNull PsiFile file
,
48 @NotNull PsiElement psiElement
,
49 @Nullable final String suggestedKey
,
50 @Nullable String suggestedValue
,
51 @Nullable final List
<PropertiesFile
> propertiesFiles
) {
52 final PsiLiteralExpression literalExpression
= psiElement
instanceof PsiLiteralExpression ?
(PsiLiteralExpression
)psiElement
: null;
53 final String propertyValue
= suggestedValue
== null ?
"" : suggestedValue
;
55 final I18nizeQuickFixDialog dialog
= new JavaI18nizeQuickFixDialog(
60 createDefaultCustomization(suggestedKey
, propertiesFiles
),
64 return doAction(project
, psiElement
, dialog
);