Skip to content

Commit f2c3010

Browse files
author
Vitaliy Boyko
committed
64: static fixes 3
1 parent 828285d commit f2c3010

File tree

3 files changed

+42
-26
lines changed

3 files changed

+42
-26
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public OverrideInThemeDialog(final @NotNull Project project, final PsiFile psiFi
4848

4949
this.project = project;
5050
this.psiFile = psiFile;
51-
this.validator = OverrideInThemeDialogValidator.getInstance(this);
51+
this.validator = new OverrideInThemeDialogValidator(this);
5252

5353
setContentPane(contentPane);
5454
setModal(true);

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

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,68 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.actions.generation.dialog.validator;
67

78
import com.intellij.openapi.project.Project;
89
import com.magento.idea.magento2plugin.actions.generation.dialog.OverrideInThemeDialog;
910
import com.magento.idea.magento2plugin.bundles.CommonBundle;
1011
import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
1112
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
12-
13-
import javax.swing.*;
1413
import java.util.List;
14+
import javax.swing.JOptionPane;
1515

1616
public class OverrideInThemeDialogValidator {
17-
private static OverrideInThemeDialogValidator INSTANCE = null;
1817
private final ValidatorBundle validatorBundle;
1918
private final CommonBundle commonBundle;
20-
private OverrideInThemeDialog dialog;
21-
22-
public static OverrideInThemeDialogValidator getInstance(OverrideInThemeDialog dialog) {
23-
if (null == INSTANCE) {
24-
INSTANCE = new OverrideInThemeDialogValidator();
25-
}
26-
27-
INSTANCE.dialog = dialog;
28-
return INSTANCE;
29-
}
19+
private final OverrideInThemeDialog dialog;
3020

31-
public OverrideInThemeDialogValidator() {
21+
/**
22+
* Constructor.
23+
*
24+
* @param dialog OverrideInThemeDialog
25+
*/
26+
public OverrideInThemeDialogValidator(final OverrideInThemeDialog dialog) {
27+
this.dialog = dialog;
3228
this.validatorBundle = new ValidatorBundle();
3329
this.commonBundle = new CommonBundle();
3430
}
3531

36-
public boolean validate(Project project)
37-
{
38-
String errorTitle = commonBundle.message("common.error");
32+
/**
33+
* Validate dialog.
34+
*
35+
* @param project Project
36+
* @return boolean
37+
*/
38+
public boolean validate(final Project project) {
39+
final String errorTitle = commonBundle.message("common.error");
3940

40-
String theme = dialog.getTheme();
41+
final String theme = dialog.getTheme();
4142
if (theme.length() == 0) {
42-
String errorMessage = validatorBundle.message("validator.notEmpty", "Target Theme");
43-
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
43+
final String errorMessage = validatorBundle.message(
44+
"validator.notEmpty",
45+
"Target Theme"
46+
);
47+
JOptionPane.showMessageDialog(
48+
null,
49+
errorMessage,
50+
errorTitle,
51+
JOptionPane.ERROR_MESSAGE
52+
);
4453

4554
return false;
4655
}
4756

48-
List<String> allThemesList = ModuleIndex.getInstance(project).getEditableThemeNames();
57+
final List<String> allThemesList = ModuleIndex.getInstance(project).getEditableThemeNames();
4958
if (!allThemesList.contains(theme)) {
50-
String errorMessage = validatorBundle.message("validator.module.noSuchModule", theme);
51-
JOptionPane.showMessageDialog(null, errorMessage, errorTitle, JOptionPane.ERROR_MESSAGE);
59+
final String errorMessage = validatorBundle
60+
.message("validator.module.noSuchModule", theme);
61+
JOptionPane.showMessageDialog(
62+
null,
63+
errorMessage,
64+
errorTitle,
65+
JOptionPane.ERROR_MESSAGE
66+
);
5267

5368
return false;
5469
}

src/com/magento/idea/magento2plugin/actions/generation/generator/OverrideInThemeGenerator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ public OverrideInThemeGenerator(final Project project) {
4242
* @param themeName String
4343
*/
4444
public void execute(final PsiFile baseFile, final String themeName) {
45-
final String componentType = GetComponentTypeByNameUtil.execute(GetComponentNameByDirectoryUtil
46-
.execute(baseFile.getContainingDirectory(), project));
45+
final String componentType = GetComponentTypeByNameUtil.execute(
46+
GetComponentNameByDirectoryUtil
47+
.execute(baseFile.getContainingDirectory(), project));
4748

4849
List<String> pathComponents;
4950
if (componentType.equals(ComponentType.module.toString())) {

0 commit comments

Comments
 (0)