Skip to content

Commit 73eaf70

Browse files
author
Vitaliy
authored
Merge branch '2.1.0-develop' into issue-293
2 parents 0ff1c8b + 57073bd commit 73eaf70

File tree

5 files changed

+71
-215
lines changed

5 files changed

+71
-215
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ If applicable, add screenshots to help explain your problem.
3939

4040
**Please complete the following information:** (*)
4141

42-
- OS: [e.g. iOS]
43-
- PhpStorm/Intellij version [e.g. 2019.3.3]
44-
- Version [e.g. 1.0.0]
42+
- OS: [e.g. MacOS or Ubuntu Linux 20.04]
43+
- PhpStorm/Intellij version: [e.g. 2019.3.3]
44+
- Plugin Version: [e.g. 1.0.0]
4545

4646
**Additional context**
4747

.github/workflows/gradle.yml

Lines changed: 32 additions & 4 deletions
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

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

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
import com.magento.idea.magento2plugin.actions.generation.CreateAnObserverAction;
1111
import com.magento.idea.magento2plugin.actions.generation.data.ObserverEventsXmlData;
1212
import com.magento.idea.magento2plugin.actions.generation.data.ObserverFileData;
13-
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.CreateAnObserverDialogValidator;
13+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.FieldValidation;
14+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.RuleRegistry;
15+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.AlphanumericWithUnderscoreRule;
16+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.DirectoryRule;
17+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.NotEmptyRule;
18+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.PhpClassRule;
1419
import com.magento.idea.magento2plugin.actions.generation.generator.ObserverClassGenerator;
1520
import com.magento.idea.magento2plugin.actions.generation.generator.ObserverEventsXmlGenerator;
1621
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
@@ -36,26 +41,47 @@
3641
"PMD.MissingSerialVersionUID",
3742
"PMD.DataClass",
3843
"PMD.UnusedPrivateField",
44+
"PMD.ExcessiveImports",
3945
})
4046
public class CreateAnObserverDialog extends AbstractDialog {
4147
@NotNull
4248
private final Project project;
43-
@NotNull
44-
private final CreateAnObserverDialogValidator validator;
4549
private final String targetEvent;
4650
private JPanel contentPane;
4751
private JButton buttonOK;
4852
private JButton buttonCancel;
49-
private JTextField observerClassName;
50-
private JTextField observerDirectory;
51-
private FilteredComboBox observerModule;
5253
private JComboBox observerArea;
53-
private JTextField observerName;
5454
private JLabel observerClassNameLabel;
5555
private JLabel observerDirectoryName;
5656
private JLabel selectObserverModule;
5757
private JLabel observerAreaLabel;
5858
private JLabel observerNameLabel;
59+
private static final String OBSERVER_MODULE = "target module";
60+
private static final String OBSERVER_CLASS = "class name";
61+
private static final String OBSERVER_DIRECTORY = "directory";
62+
private static final String OBSERVER_NAME = "name";
63+
64+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
65+
message = {NotEmptyRule.MESSAGE, OBSERVER_MODULE})
66+
private FilteredComboBox observerModule;
67+
68+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
69+
message = {NotEmptyRule.MESSAGE, OBSERVER_CLASS})
70+
@FieldValidation(rule = RuleRegistry.PHP_CLASS,
71+
message = {PhpClassRule.MESSAGE, OBSERVER_CLASS})
72+
private JTextField observerClassName;
73+
74+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
75+
message = {NotEmptyRule.MESSAGE, OBSERVER_DIRECTORY})
76+
@FieldValidation(rule = RuleRegistry.DIRECTORY,
77+
message = {DirectoryRule.MESSAGE, OBSERVER_DIRECTORY})
78+
private JTextField observerDirectory;
79+
80+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
81+
message = {NotEmptyRule.MESSAGE, OBSERVER_NAME})
82+
@FieldValidation(rule = RuleRegistry.ALPHANUMERIC_WITH_UNDERSCORE,
83+
message = {AlphanumericWithUnderscoreRule.MESSAGE, OBSERVER_NAME})
84+
private JTextField observerName;
5985

6086
/**
6187
* Constructor.
@@ -68,7 +94,6 @@ public CreateAnObserverDialog(@NotNull final Project project, final String targe
6894

6995
this.project = project;
7096
this.targetEvent = targetEvent;
71-
this.validator = CreateAnObserverDialogValidator.getInstance(this);
7297

7398
setContentPane(contentPane);
7499
setModal(true);
@@ -119,7 +144,7 @@ private void fillTargetAreaOptions() {
119144
* Perform code generation using input data.
120145
*/
121146
private void onOK() {
122-
if (!validator.validate(project)) {
147+
if (!validateFormFields()) {
123148
return;
124149
}
125150
new ObserverClassGenerator(new ObserverFileData(

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

Lines changed: 0 additions & 198 deletions
This file was deleted.

0 commit comments

Comments
 (0)