Skip to content

Commit 49c7687

Browse files
committed
Extracting the static text to Common Bundle
1 parent 163ed87 commit 49c7687

17 files changed

+82
-17
lines changed

resources/magento2/common.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ common.module.dependencies=Module Dependencies
66
common.module.description=Module Description
77
common.ok=OK
88
common.cancel=Cancel
9+
common.error=Error

src/com/magento/idea/magento2plugin/actions/generation/PluginGenerateMethodHandlerBase.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.magento.idea.magento2plugin.actions.generation.util.CodeStyleSettings;
3535
import com.magento.idea.magento2plugin.actions.generation.util.CollectInsertedMethods;
3636
import com.magento.idea.magento2plugin.actions.generation.util.FillTextBufferWithPluginMethods;
37+
import com.magento.idea.magento2plugin.bundles.CommonBundle;
3738
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
3839
import com.magento.idea.magento2plugin.magento.files.Plugin;
3940
import com.magento.idea.magento2plugin.util.GetPhpClassByFQN;
@@ -49,6 +50,7 @@
4950
public abstract class PluginGenerateMethodHandlerBase implements LanguageCodeInsightActionHandler {
5051
private CollectInsertedMethods collectInsertedMethods;
5152
private ValidatorBundle validatorBundle;
53+
private CommonBundle commonBundle;
5254
public String type;
5355
public FillTextBufferWithPluginMethods fillTextBuffer;
5456

@@ -57,6 +59,7 @@ public PluginGenerateMethodHandlerBase(Plugin.PluginType type) {
5759
this.fillTextBuffer = FillTextBufferWithPluginMethods.getInstance();
5860
this.collectInsertedMethods = CollectInsertedMethods.getInstance();
5961
this.validatorBundle = new ValidatorBundle();
62+
this.commonBundle = new CommonBundle();
6063
}
6164

6265
public boolean isValidFor(Editor editor, PsiFile file) {
@@ -165,7 +168,7 @@ protected PhpNamedElementNode[] targetMethods(@NotNull PhpClass phpClass, Key<Ob
165168

166169
if (targetClass == null) {
167170
String errorMessage = validatorBundle.message("validator.class.targetClassNotFound");
168-
JOptionPane.showMessageDialog(null, errorMessage, "Error", JOptionPane.ERROR_MESSAGE);
171+
JOptionPane.showMessageDialog(null, errorMessage, commonBundle.message("common.error"), JOptionPane.ERROR_MESSAGE);
169172
continue;
170173
}
171174

src/com/magento/idea/magento2plugin/actions/generation/dialog/OverrideClassByAPreferenceDialog.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.OverrideClassByAPreferenceDialogValidator;
1515
import com.magento.idea.magento2plugin.actions.generation.generator.PreferenceClassGenerator;
1616
import com.magento.idea.magento2plugin.actions.generation.generator.PreferenceDiXmlGenerator;
17+
import com.magento.idea.magento2plugin.bundles.CommonBundle;
1718
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
1819
import com.magento.idea.magento2plugin.magento.packages.Package;
1920
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
@@ -44,12 +45,14 @@ public class OverrideClassByAPreferenceDialog extends AbstractDialog {
4445
private JLabel inheritClassLabel;
4546
private JLabel preferenceDirectoryLabel;
4647
private ValidatorBundle validatorBundle;
48+
private CommonBundle commonBundle;
4749

4850
public OverrideClassByAPreferenceDialog(@NotNull Project project, PhpClass targetClass) {
4951
this.project = project;
5052
this.targetClass = targetClass;
5153
this.validator = OverrideClassByAPreferenceDialogValidator.getInstance(this);
5254
this.validatorBundle = new ValidatorBundle();
55+
this.commonBundle = new CommonBundle();
5356

5457
setContentPane(contentPane);
5558
setModal(true);
@@ -127,7 +130,8 @@ private void onOK() {
127130
), project).generate(OverrideClassByAPreferenceAction.ACTION_NAME);
128131
if (diXml == null) {
129132
String errorMessage = validatorBundle.message("validator.class.alreadyDeclared", "Preference");
130-
JOptionPane.showMessageDialog(null, errorMessage, "Error", JOptionPane.ERROR_MESSAGE);
133+
String errorTitle = commonBundle.message("common.error");
134+
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
131135

132136
return;
133137
}

src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/CreateAPluginDialogValidator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import com.intellij.openapi.project.Project;
88
import com.magento.idea.magento2plugin.actions.generation.dialog.CreateAPluginDialog;
9+
import com.magento.idea.magento2plugin.bundles.CommonBundle;
910
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
1011
import com.magento.idea.magento2plugin.util.RegExUtil;
1112
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
@@ -15,6 +16,7 @@
1516
public class CreateAPluginDialogValidator {
1617
private static CreateAPluginDialogValidator INSTANCE = null;
1718
private ValidatorBundle validatorBundle;
19+
private CommonBundle commonBundle;
1820
private CreateAPluginDialog dialog;
1921

2022
public static CreateAPluginDialogValidator getInstance(CreateAPluginDialog dialog) {
@@ -28,11 +30,12 @@ public static CreateAPluginDialogValidator getInstance(CreateAPluginDialog dialo
2830

2931
public CreateAPluginDialogValidator() {
3032
this.validatorBundle = new ValidatorBundle();
33+
this.commonBundle = new CommonBundle();
3134
}
3235

3336
public boolean validate(Project project)
3437
{
35-
String errorTitle = "Error";
38+
String errorTitle = commonBundle.message("common.error");
3639
String pluginClassName = dialog.getPluginClassName();
3740

3841
if (pluginClassName.length() == 0) {

src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/CreateAnObserverDialogValidator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import com.intellij.openapi.project.Project;
88
import com.magento.idea.magento2plugin.actions.generation.dialog.CreateAnObserverDialog;
9+
import com.magento.idea.magento2plugin.bundles.CommonBundle;
910
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
1011
import com.magento.idea.magento2plugin.util.RegExUtil;
1112
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
@@ -15,6 +16,7 @@
1516
public class CreateAnObserverDialogValidator {
1617
private static CreateAnObserverDialogValidator INSTANCE = null;
1718
private ValidatorBundle validatorBundle;
19+
private CommonBundle commonBundle;
1820
private CreateAnObserverDialog dialog;
1921

2022
public static CreateAnObserverDialogValidator getInstance(CreateAnObserverDialog dialog) {
@@ -27,11 +29,12 @@ public static CreateAnObserverDialogValidator getInstance(CreateAnObserverDialog
2729

2830
public CreateAnObserverDialogValidator() {
2931
this.validatorBundle = new ValidatorBundle();
32+
this.commonBundle = new CommonBundle();
3033
}
3134

3235
public boolean validate(Project project)
3336
{
34-
String errorTitle = "Error";
37+
String errorTitle = commonBundle.message("common.error");
3538
String observerClassName = dialog.getObserverClassName();
3639
if (observerClassName.length() == 0) {
3740
String errorMessage = validatorBundle.message("validator.notEmpty", "Observer Class Name");

src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/NewBlockValidator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
package com.magento.idea.magento2plugin.actions.generation.dialog.validator;
66

77
import com.magento.idea.magento2plugin.actions.generation.dialog.NewBlockDialog;
8+
import com.magento.idea.magento2plugin.bundles.CommonBundle;
89
import com.magento.idea.magento2plugin.util.RegExUtil;
910
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
1011
import javax.swing.*;
1112

1213
public class NewBlockValidator {
1314
private static NewBlockValidator INSTANCE = null;
1415
private ValidatorBundle validatorBundle;
16+
private CommonBundle commonBundle;
1517
private NewBlockDialog dialog;
1618

1719
public static NewBlockValidator getInstance(NewBlockDialog dialog) {
@@ -24,11 +26,12 @@ public static NewBlockValidator getInstance(NewBlockDialog dialog) {
2426

2527
public NewBlockValidator() {
2628
this.validatorBundle = new ValidatorBundle();
29+
this.commonBundle = new CommonBundle();
2730
}
2831

2932
public boolean validate()
3033
{
31-
String errorTitle = "Error";
34+
String errorTitle = commonBundle.message("common.error");
3235

3336
String moduleName = dialog.getBlockName();
3437
if (moduleName.length() == 0) {

src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/NewGraphQlResolverValidator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package com.magento.idea.magento2plugin.actions.generation.dialog.validator;
66

77
import com.magento.idea.magento2plugin.actions.generation.dialog.NewGraphQlResolverDialog;
8+
import com.magento.idea.magento2plugin.bundles.CommonBundle;
89
import com.magento.idea.magento2plugin.util.RegExUtil;
910
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
1011

@@ -13,6 +14,8 @@
1314
public class NewGraphQlResolverValidator {
1415
private static NewGraphQlResolverValidator INSTANCE = null;
1516
private ValidatorBundle validatorBundle;
17+
private CommonBundle commonBundle;
18+
1619
private NewGraphQlResolverDialog dialog;
1720

1821
public static NewGraphQlResolverValidator getInstance(NewGraphQlResolverDialog dialog) {
@@ -25,11 +28,12 @@ public static NewGraphQlResolverValidator getInstance(NewGraphQlResolverDialog d
2528

2629
public NewGraphQlResolverValidator() {
2730
this.validatorBundle = new ValidatorBundle();
31+
this.commonBundle = new CommonBundle();
2832
}
2933

3034
public boolean validate()
3135
{
32-
String errorTitle = "Error";
36+
String errorTitle = commonBundle.message("common.error");
3337

3438
String resolverClassName = dialog.getGraphQlResolverClassName();
3539
if (resolverClassName.length() == 0) {

src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/NewModuleDialogValidator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
package com.magento.idea.magento2plugin.actions.generation.dialog.validator;
66

77
import com.magento.idea.magento2plugin.actions.generation.dialog.NewModuleDialog;
8+
import com.magento.idea.magento2plugin.bundles.CommonBundle;
89
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
910
import com.magento.idea.magento2plugin.util.RegExUtil;
1011
import javax.swing.*;
1112

1213
public class NewModuleDialogValidator {
1314
private static NewModuleDialogValidator INSTANCE = null;
1415
private ValidatorBundle validatorBundle;
16+
private CommonBundle commonBundle;
1517
private NewModuleDialog dialog;
1618

1719
public static NewModuleDialogValidator getInstance(NewModuleDialog dialog) {
@@ -24,11 +26,12 @@ public static NewModuleDialogValidator getInstance(NewModuleDialog dialog) {
2426

2527
public NewModuleDialogValidator() {
2628
this.validatorBundle = new ValidatorBundle();
29+
this.commonBundle = new CommonBundle();
2730
}
2831

2932
public boolean validate()
3033
{
31-
String errorTitle = "Error";
34+
String errorTitle = commonBundle.message("common.error");
3235
String packageName = dialog.getPackageName();
3336
if (packageName.length() == 0) {
3437
String errorMessage = validatorBundle.message("validator.notEmpty", "Package Name");

src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/NewViewModelValidator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package com.magento.idea.magento2plugin.actions.generation.dialog.validator;
66

77
import com.magento.idea.magento2plugin.actions.generation.dialog.NewViewModelDialog;
8+
import com.magento.idea.magento2plugin.bundles.CommonBundle;
89
import com.magento.idea.magento2plugin.util.RegExUtil;
910
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
1011

@@ -13,6 +14,7 @@
1314
public class NewViewModelValidator {
1415
private static NewViewModelValidator INSTANCE = null;
1516
private ValidatorBundle validatorBundle;
17+
private CommonBundle commonBundle;
1618
private NewViewModelDialog dialog;
1719

1820
public static NewViewModelValidator getInstance(NewViewModelDialog dialog) {
@@ -25,11 +27,12 @@ public static NewViewModelValidator getInstance(NewViewModelDialog dialog) {
2527

2628
public NewViewModelValidator() {
2729
this.validatorBundle = new ValidatorBundle();
30+
this.commonBundle = new CommonBundle();
2831
}
2932

3033
public boolean validate()
3134
{
32-
String errorTitle = "Error";
35+
String errorTitle =commonBundle.message("common.error");
3336

3437
String moduleName = dialog.getViewModelName();
3538
if (moduleName.length() == 0) {

src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/OverrideClassByAPreferenceDialogValidator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import com.intellij.openapi.project.Project;
88
import com.magento.idea.magento2plugin.actions.generation.dialog.OverrideClassByAPreferenceDialog;
9+
import com.magento.idea.magento2plugin.bundles.CommonBundle;
910
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
1011
import com.magento.idea.magento2plugin.util.RegExUtil;
1112
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
@@ -15,6 +16,7 @@
1516
public class OverrideClassByAPreferenceDialogValidator {
1617
private static OverrideClassByAPreferenceDialogValidator INSTANCE = null;
1718
private ValidatorBundle validatorBundle;
19+
private CommonBundle commonBundle;
1820
private OverrideClassByAPreferenceDialog dialog;
1921

2022
public static OverrideClassByAPreferenceDialogValidator getInstance(OverrideClassByAPreferenceDialog dialog) {
@@ -27,11 +29,12 @@ public static OverrideClassByAPreferenceDialogValidator getInstance(OverrideClas
2729

2830
public OverrideClassByAPreferenceDialogValidator() {
2931
validatorBundle = new ValidatorBundle();
32+
this.commonBundle = new CommonBundle();
3033
}
3134

3235
public boolean validate(Project project)
3336
{
34-
String errorTitle = "Error";
37+
String errorTitle = commonBundle.message("common.error");
3538
String preferenceClassName = dialog.getPreferenceClassName();
3639
if (preferenceClassName.length() == 0) {
3740
String errorMessage = validatorBundle.message("validator.notEmpty", "Preference Class Name");

0 commit comments

Comments
 (0)