|
2 | 2 | * Copyright © Magento, Inc. All rights reserved.
|
3 | 3 | * See COPYING.txt for license details.
|
4 | 4 | */
|
| 5 | + |
5 | 6 | package com.magento.idea.magento2plugin.actions.generation.dialog.validator;
|
6 | 7 |
|
7 | 8 | import com.intellij.openapi.project.Project;
|
8 | 9 | import com.magento.idea.magento2plugin.actions.generation.dialog.OverrideInThemeDialog;
|
9 | 10 | import com.magento.idea.magento2plugin.bundles.CommonBundle;
|
10 | 11 | import com.magento.idea.magento2plugin.bundles.ValidatorBundle;
|
11 | 12 | import com.magento.idea.magento2plugin.indexes.ModuleIndex;
|
12 |
| - |
13 |
| -import javax.swing.*; |
14 | 13 | import java.util.List;
|
| 14 | +import javax.swing.JOptionPane; |
15 | 15 |
|
16 | 16 | public class OverrideInThemeDialogValidator {
|
17 |
| - private static OverrideInThemeDialogValidator INSTANCE = null; |
18 | 17 | private final ValidatorBundle validatorBundle;
|
19 | 18 | 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; |
30 | 20 |
|
31 |
| - public OverrideInThemeDialogValidator() { |
| 21 | + /** |
| 22 | + * Constructor. |
| 23 | + * |
| 24 | + * @param dialog OverrideInThemeDialog |
| 25 | + */ |
| 26 | + public OverrideInThemeDialogValidator(final OverrideInThemeDialog dialog) { |
| 27 | + this.dialog = dialog; |
32 | 28 | this.validatorBundle = new ValidatorBundle();
|
33 | 29 | this.commonBundle = new CommonBundle();
|
34 | 30 | }
|
35 | 31 |
|
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"); |
39 | 40 |
|
40 |
| - String theme = dialog.getTheme(); |
| 41 | + final String theme = dialog.getTheme(); |
41 | 42 | 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 | + ); |
44 | 53 |
|
45 | 54 | return false;
|
46 | 55 | }
|
47 | 56 |
|
48 |
| - List<String> allThemesList = ModuleIndex.getInstance(project).getEditableThemeNames(); |
| 57 | + final List<String> allThemesList = ModuleIndex.getInstance(project).getEditableThemeNames(); |
49 | 58 | 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 | + ); |
52 | 67 |
|
53 | 68 | return false;
|
54 | 69 | }
|
|
0 commit comments