ComponentWithBrowseButton - optional remove listener on hide
[fedora-idea.git] / plugins / java-i18n / src / com / intellij / codeInspection / i18n / JavaCreatePropertyFix.java
blobd32b9507e74471c1701a1df1631e7fcadaa43e0a
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.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;
31 /**
32 * @author Maxim.Mossienko
34 public class JavaCreatePropertyFix extends CreatePropertyFix {
35 public JavaCreatePropertyFix() {}
37 public JavaCreatePropertyFix(PsiElement element, String key, final List<PropertiesFile> propertiesFiles) {
38 super(element, key, propertiesFiles);
41 @Nullable
42 protected static Pair<String, String> invokeAction(@NotNull final Project project,
43 @NotNull PsiFile file,
44 @NotNull PsiElement psiElement,
45 @Nullable final String suggestedKey,
46 @Nullable String suggestedValue,
47 @Nullable final List<PropertiesFile> propertiesFiles) {
48 final PsiLiteralExpression literalExpression = psiElement instanceof PsiLiteralExpression ? (PsiLiteralExpression)psiElement : null;
49 final String propertyValue = suggestedValue == null ? "" : suggestedValue;
51 final I18nizeQuickFixDialog dialog = new JavaI18nizeQuickFixDialog(
52 project,
53 file,
54 literalExpression,
55 propertyValue,
56 createDefaultCustomization(suggestedKey, propertiesFiles),
57 false,
58 false
60 return doAction(project, psiElement, dialog);