Skip to content

Commit e0923e0

Browse files
author
Vitaliy
authored
Merge branch '2.1.0-develop' into forwardport-2.0.1->2.1.0
2 parents afc7ba6 + c99c08d commit e0923e0

File tree

9 files changed

+110
-398
lines changed

9 files changed

+110
-398
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
If relevant, please provide a list of fixed issues in the format magento/magento2-phpstorm-plugin#<issue_number>.
2121
There could be 1 or more issues linked here and it will help us find some more information about the reasoning behind this change.
2222
-->
23-
1. magento/magento2-phpstorm-plugin#<issue_number>: Issue title
23+
1. Fixes magento/magento2-phpstorm-plugin#<issue_number>
2424

2525
**Questions or comments**
2626
<!---

.github/workflows/gradle.yml

+32-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99

1010
jobs:
1111
build-linux:
12-
1312
runs-on: ubuntu-latest
1413

1514
steps:
@@ -18,6 +17,14 @@ jobs:
1817
uses: actions/setup-java@v1
1918
with:
2019
java-version: 1.8
20+
- uses: actions/cache@v2
21+
with:
22+
path: |
23+
~/.gradle/caches
24+
~/.gradle/wrapper
25+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
26+
restore-keys: |
27+
${{ runner.os }}-gradle-
2128
- name: Gradle wrapper
2229
run: gradle wrapper
2330
- name: Grant execute permission for gradlew
@@ -26,7 +33,6 @@ jobs:
2633
run: ./gradlew test -i --no-daemon
2734

2835
build-windows:
29-
3036
runs-on: windows-latest
3137

3238
steps:
@@ -35,6 +41,14 @@ jobs:
3541
uses: actions/setup-java@v1
3642
with:
3743
java-version: 1.8
44+
- uses: actions/cache@v2
45+
with:
46+
path: |
47+
~/.gradle/caches
48+
~/.gradle/wrapper
49+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
50+
restore-keys: |
51+
${{ runner.os }}-gradle-
3852
- name: Gradle wrapper
3953
run: gradle wrapper
4054
- name: Grant execute permission for gradlew
@@ -43,7 +57,6 @@ jobs:
4357
run: ./gradlew test -i --no-daemon
4458

4559
build-macos:
46-
4760
runs-on: macos-latest
4861

4962
steps:
@@ -52,6 +65,14 @@ jobs:
5265
uses: actions/setup-java@v1
5366
with:
5467
java-version: 1.8
68+
- uses: actions/cache@v2
69+
with:
70+
path: |
71+
~/.gradle/caches
72+
~/.gradle/wrapper
73+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
74+
restore-keys: |
75+
${{ runner.os }}-gradle-
5576
- name: Gradle wrapper
5677
run: gradle wrapper
5778
- name: Grant execute permission for gradlew
@@ -60,7 +81,6 @@ jobs:
6081
run: ./gradlew test -i --no-daemon
6182

6283
static-tests:
63-
6484
runs-on: ubuntu-latest
6585

6686
steps:
@@ -69,6 +89,14 @@ jobs:
6989
uses: actions/setup-java@v1
7090
with:
7191
java-version: 1.8
92+
- uses: actions/cache@v2
93+
with:
94+
path: |
95+
~/.gradle/caches
96+
~/.gradle/wrapper
97+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
98+
restore-keys: |
99+
${{ runner.os }}-gradle-
72100
- name: Gradle wrapper
73101
run: gradle wrapper
74102
- name: Grant execute permission for gradlew

resources/magento2/common.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ common.module.target=Target Module
2222
common.theme.target=Target Theme
2323
common.area.target=Target Area
2424
common.name=Name
25-
common.className=Class name
26-
common.argument=Argument name
25+
common.className=Class Name
26+
common.pluginName=Plugin Name
2727
common.directoryPath=Directory Path
2828
common.methodType=Method Type
2929
common.sortOrder=Sort Order

resources/magento2/validation.properties

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
validator.notEmpty=The {0} field must not be empty
22
validator.package.validPath=Please specify a valid Magento 2 installation path
3-
validator.alphaNumericCharacters=The {0} must contain letters and numbers only
3+
validator.alphaNumericCharacters=The {0} field must contain letters and numbers only
44
validator.alphaNumericAndUnderscoreCharacters={0} must contain letters, numbers and underscores only
5-
validator.alreadyDeclared={0} is already declared in the {1} module.
6-
validator.startWithNumberOrCapitalLetter=The {0} must start from a number or a capital letter
7-
validator.onlyNumbers={0} must contain numbers only
5+
validator.alreadyDeclared={0} is already declared in the {1} module
6+
validator.startWithNumberOrCapitalLetter=The {0} field must start with a number or a capital letter
7+
validator.onlyNumbers=The {0} field must contain numbers only
88
validator.mustNotBeNegative={0} must not be negative
9-
validator.identifier={0} must contain letters, numbers, dashes, and underscores only
9+
validator.identifier=The {0} field must contain letters, numbers, dashes, and underscores only
1010
validator.class.isNotValid=The {0} field does not contain a valid class name
1111
validator.class.shouldBeUnique=Duplicated class {0}
12-
validator.namespace.isNotValid=The {0} is not valid namespace name
13-
validator.directory.isNotValid={0} is not valid
12+
validator.namespace.isNotValid=The {0} field does not contain a valid namespace
13+
validator.directory.isNotValid=The {0} field does not contain a valid directory
1414
validator.directory.php.isNotValid=The {0} field does not contain a valid PHP directory
1515
validator.command.isNotValid=The {0} field does not contain a valid Magento 2 CLI command
1616
validator.module.noSuchModule=No such module {0}

src/com/magento/idea/magento2plugin/actions/generation/dialog/CreateAPluginDialog.form

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
109109
</constraints>
110110
<properties>
111-
<text resource-bundle="magento2/common" key="common.name"/>
111+
<text resource-bundle="magento2/common" key="common.pluginName"/>
112112
</properties>
113113
</component>
114114
<component id="9431c" class="javax.swing.JTextField" binding="pluginName">

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

+52-26
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
import com.magento.idea.magento2plugin.actions.generation.CreateAPluginAction;
1212
import com.magento.idea.magento2plugin.actions.generation.data.PluginDiXmlData;
1313
import com.magento.idea.magento2plugin.actions.generation.data.PluginFileData;
14-
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.CreateAPluginDialogValidator;
14+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.FieldValidation;
15+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.RuleRegistry;
16+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.DirectoryRule;
17+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.IdentifierRule;
18+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.NotEmptyRule;
19+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.NumericRule;
20+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.PhpClassRule;
1521
import com.magento.idea.magento2plugin.actions.generation.generator.PluginClassGenerator;
1622
import com.magento.idea.magento2plugin.actions.generation.generator.PluginDiXmlGenerator;
1723
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
@@ -21,7 +27,6 @@
2127
import com.magento.idea.magento2plugin.magento.packages.Package;
2228
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
2329
import java.awt.event.ActionEvent;
24-
import java.awt.event.ActionListener;
2530
import java.awt.event.KeyEvent;
2631
import java.awt.event.WindowAdapter;
2732
import java.awt.event.WindowEvent;
@@ -35,24 +40,57 @@
3540
import javax.swing.KeyStroke;
3641
import org.jetbrains.annotations.NotNull;
3742

38-
@SuppressWarnings({"PMD.TooManyFields", "PMD.DataClass", "PMD.UnusedPrivateMethod"})
43+
@SuppressWarnings({
44+
"PMD.TooManyFields",
45+
"PMD.DataClass",
46+
"PMD.UnusedPrivateMethod",
47+
"PMD.ExcessiveImports"
48+
})
3949
public class CreateAPluginDialog extends AbstractDialog {
4050
@NotNull
4151
private final Project project;
4252
private final Method targetMethod;
4353
private final PhpClass targetClass;
44-
@NotNull
45-
private final CreateAPluginDialogValidator validator;
4654
private JPanel contentPane;
4755
private JButton buttonOK;
4856
private JButton buttonCancel;
49-
private JTextField pluginClassName;
50-
private JTextField pluginDirectory;
5157
private JComboBox pluginType;
52-
private FilteredComboBox pluginModule;
5358
private JComboBox pluginArea;
59+
60+
private static final String CLASS_NAME = "class name";
61+
private static final String DIRECTORY = "directory path";
62+
private static final String SORT_ORDER = "sort order";
63+
private static final String PLUGIN_NAME = "plugin name";
64+
private static final String TARGET_MODULE = "target module";
65+
66+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
67+
message = {NotEmptyRule.MESSAGE, TARGET_MODULE})
68+
private FilteredComboBox pluginModule;
69+
70+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
71+
message = {NotEmptyRule.MESSAGE, CLASS_NAME})
72+
@FieldValidation(rule = RuleRegistry.PHP_CLASS,
73+
message = {PhpClassRule.MESSAGE, CLASS_NAME})
74+
private JTextField pluginClassName;
75+
76+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
77+
message = {NotEmptyRule.MESSAGE, DIRECTORY})
78+
@FieldValidation(rule = RuleRegistry.DIRECTORY,
79+
message = {DirectoryRule.MESSAGE, DIRECTORY})
80+
private JTextField pluginDirectory;
81+
82+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
83+
message = {NotEmptyRule.MESSAGE, SORT_ORDER})
84+
@FieldValidation(rule = RuleRegistry.NUMERIC,
85+
message = {NumericRule.MESSAGE, SORT_ORDER})
5486
private JTextField pluginSortOrder;
87+
88+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
89+
message = {NotEmptyRule.MESSAGE, PLUGIN_NAME})
90+
@FieldValidation(rule = RuleRegistry.IDENTIFIER,
91+
message = {IdentifierRule.MESSAGE, PLUGIN_NAME})
5592
private JTextField pluginName;
93+
5694
private JLabel pluginDirectoryName;//NOPMD
5795
private JLabel selectPluginModule;//NOPMD
5896
private JLabel pluginTypeLabel;//NOPMD
@@ -77,25 +115,15 @@ public CreateAPluginDialog(
77115
this.project = project;
78116
this.targetMethod = targetMethod;
79117
this.targetClass = targetClass;
80-
this.validator = CreateAPluginDialogValidator.getInstance(this);
81118

82119
setContentPane(contentPane);
83120
setModal(true);
84121
getRootPane().setDefaultButton(buttonOK);
85122
fillPluginTypeOptions();
86123
fillTargetAreaOptions();
87124

88-
buttonOK.addActionListener(new ActionListener() {
89-
public void actionPerformed(final ActionEvent event) {
90-
onOK();
91-
}
92-
});
93-
94-
buttonCancel.addActionListener(new ActionListener() {
95-
public void actionPerformed(final ActionEvent event) {
96-
onCancel();
97-
}
98-
});
125+
buttonOK.addActionListener((final ActionEvent event) -> onOK());
126+
buttonCancel.addActionListener((final ActionEvent event) -> onCancel());
99127

100128
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
101129
addWindowListener(new WindowAdapter() {
@@ -104,11 +132,9 @@ public void windowClosing(final WindowEvent event) {
104132
}
105133
});
106134

107-
contentPane.registerKeyboardAction(new ActionListener() {
108-
public void actionPerformed(final ActionEvent event) {
109-
onCancel();
110-
}
111-
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
135+
contentPane.registerKeyboardAction(
136+
(final ActionEvent event) -> onCancel(),
137+
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
112138
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
113139
);
114140
}
@@ -126,7 +152,7 @@ private void fillTargetAreaOptions() {
126152
}
127153

128154
protected void onOK() {
129-
if (!validator.validate(project)) {
155+
if (!validateFormFields()) {
130156
return;
131157
}
132158
new PluginClassGenerator(new PluginFileData(

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

+15-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
import com.intellij.psi.PsiDirectory;
1010
import com.magento.idea.magento2plugin.actions.generation.NewCronGroupAction;
1111
import com.magento.idea.magento2plugin.actions.generation.data.CronGroupXmlData;
12-
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.NewCronGroupValidator;
12+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.FieldValidation;
13+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.RuleRegistry;
14+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.IdentifierRule;
15+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.NotEmptyRule;
1316
import com.magento.idea.magento2plugin.actions.generation.generator.ModuleCronGroupXmlGenerator;
1417
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
1518
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
@@ -30,16 +33,23 @@
3033

3134
@SuppressWarnings({
3235
"PMD.TooManyFields",
33-
"PMD.TooManyMethods"
36+
"PMD.TooManyMethods",
37+
"PMD.ExcessiveImports,"
3438
})
3539
public class NewCronGroupDialog extends AbstractDialog {
36-
private final NewCronGroupValidator validator;
3740
private final String moduleName;
3841
private final Project project;
3942
private JPanel contentPanel;
4043
private JButton buttonOK;
4144
private JButton buttonCancel;
45+
private static final String NAME = "name";
46+
47+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
48+
message = {NotEmptyRule.MESSAGE, NAME})
49+
@FieldValidation(rule = RuleRegistry.IDENTIFIER,
50+
message = {IdentifierRule.MESSAGE, NAME})
4251
private JTextField cronGroupName;
52+
4353
private JSpinner scheduleGenerateEvery;
4454
private JSpinner scheduleAheadFor;
4555
private JSpinner scheduleLifetime;
@@ -67,7 +77,6 @@ public NewCronGroupDialog(final Project project, final PsiDirectory directory) {
6777
setContentPane(contentPanel);
6878
setModal(true);
6979
getRootPane().setDefaultButton(buttonOK);
70-
this.validator = NewCronGroupValidator.getInstance();
7180
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
7281

7382
buttonOK.addActionListener(event -> onOK());
@@ -125,14 +134,15 @@ public static void open(final Project project, final PsiDirectory directory) {
125134
}
126135

127136
private void onOK() {
128-
if (!validator.validate(this)) {
137+
if (!validateFormFields()) {
129138
return;
130139
}
131140

132141
generateFile();
133142
this.setVisible(false);
134143
}
135144

145+
@Override
136146
protected void onCancel() {
137147
dispose();
138148
}

0 commit comments

Comments
 (0)