3
3
* See COPYING.txt for license details.
4
4
*/
5
5
6
- package com .magento .idea .magento2plugin .actions .generation .dialog . NewSetupDataPatch ;
6
+ package com .magento .idea .magento2plugin .actions .generation .dialog ;
7
7
8
8
import com .intellij .openapi .project .Project ;
9
9
import com .intellij .psi .PsiDirectory ;
10
10
import com .intellij .psi .PsiFile ;
11
11
import com .magento .idea .magento2plugin .actions .context .php .NewSetupDataPatchAction ;
12
12
import com .magento .idea .magento2plugin .actions .generation .ModuleSetupDataPatchData ;
13
- import com .magento .idea .magento2plugin .actions .generation .dialog .AbstractDialog ;
14
13
import com .magento .idea .magento2plugin .actions .generation .dialog .validator .annotation .FieldValidation ;
15
14
import com .magento .idea .magento2plugin .actions .generation .dialog .validator .annotation .RuleRegistry ;
16
15
import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .NotEmptyRule ;
17
16
import com .magento .idea .magento2plugin .actions .generation .dialog .validator .rule .PhpClassRule ;
18
17
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleSetupDataPatchGenerator ;
19
18
import com .magento .idea .magento2plugin .magento .files .ModuleSetupDataPatchFile ;
20
-
21
-
19
+ import java .awt .event .ActionEvent ;
20
+ import java .awt .event .KeyEvent ;
21
+ import java .awt .event .WindowAdapter ;
22
+ import java .awt .event .WindowEvent ;
23
+ import java .util .Objects ;
22
24
import javax .swing .JButton ;
23
25
import javax .swing .JComponent ;
24
26
import javax .swing .JLabel ;
25
27
import javax .swing .JPanel ;
26
28
import javax .swing .JTextField ;
27
29
import javax .swing .KeyStroke ;
28
- import java .awt .event .ActionEvent ;
29
- import java .awt .event .KeyEvent ;
30
- import java .awt .event .WindowAdapter ;
31
- import java .awt .event .WindowEvent ;
32
- import java .util .Objects ;
33
30
34
31
public class NewSetupDataPatchDialog extends AbstractDialog {
35
32
@@ -48,8 +45,8 @@ public class NewSetupDataPatchDialog extends AbstractDialog {
48
45
@ FieldValidation (rule = RuleRegistry .PHP_CLASS ,
49
46
message = {PhpClassRule .MESSAGE , CLASS_NAME })
50
47
private JTextField className ;
51
- private JLabel classNameLabel ;
52
- private JLabel classNameErrorMessage ;
48
+ private JLabel classNameLabel ;//NOPMD
49
+ private JLabel classNameErrorMessage ;//NOPMD
53
50
54
51
55
52
/**
@@ -61,8 +58,8 @@ public class NewSetupDataPatchDialog extends AbstractDialog {
61
58
public NewSetupDataPatchDialog (
62
59
final Project project ,
63
60
final PsiDirectory directory ,
64
- String modulePackage ,
65
- String moduleName
61
+ final String modulePackage ,
62
+ final String moduleName
66
63
) {
67
64
super ();
68
65
@@ -109,8 +106,8 @@ public void windowClosing(final WindowEvent event) {
109
106
public static void open (
110
107
final Project project ,
111
108
final PsiDirectory directory ,
112
- String modulePackage ,
113
- String moduleName
109
+ final String modulePackage ,
110
+ final String moduleName
114
111
) {
115
112
final NewSetupDataPatchDialog dialog = new NewSetupDataPatchDialog (
116
113
project ,
@@ -149,11 +146,11 @@ public String getClassName() {
149
146
}
150
147
151
148
private boolean validateFields () {
152
- PsiDirectory targetDirectory = getDirectory (baseDir );
149
+ final PsiDirectory targetDirectory = getDirectory (baseDir );
153
150
154
- if (targetDirectory . getName () .equals (NewSetupDataPatchAction . DATA_DIRECTORY )) {
151
+ if (NewSetupDataPatchAction . DATA_DIRECTORY .equals (targetDirectory . getName () )) {
155
152
final PsiFile [] files = targetDirectory .getFiles ();
156
- for (PsiFile file : files ) {
153
+ for (final PsiFile file : files ) {
157
154
if (file .getName ().equals (getClassName () + ModuleSetupDataPatchFile .FILE_NAME )) {
158
155
showErrorMessage (
159
156
fieldsValidationsList .get (0 ).getField (),
@@ -167,34 +164,35 @@ private boolean validateFields() {
167
164
return validateFormFields ();
168
165
}
169
166
170
- private PsiDirectory getDirectory (PsiDirectory targetDirectory ){
171
- if (baseDir .getName ().equals (NewSetupDataPatchAction .ROOT_DIRECTORY )) {
172
- PsiDirectory subDirectoryPatch =
173
- baseDir .findSubdirectory (NewSetupDataPatchAction .PATCH_DIRECTORY );
167
+ private PsiDirectory getDirectory (final PsiDirectory targetDirectory ) {
168
+ if (NewSetupDataPatchAction .ROOT_DIRECTORY .equals (baseDir .getName ())) {
169
+ final PsiDirectory subDirectoryPatch = baseDir .findSubdirectory (
170
+ NewSetupDataPatchAction .PATCH_DIRECTORY
171
+ );
174
172
175
173
if (subDirectoryPatch != null ) {
176
174
return subDirectoryPatch .findSubdirectory (NewSetupDataPatchAction .DATA_DIRECTORY );
177
175
}
178
176
}
179
- if ( baseDir . getName () .equals (NewSetupDataPatchAction . PATCH_DIRECTORY )) {
177
+ if ( NewSetupDataPatchAction . PATCH_DIRECTORY .equals (baseDir . getName () )) {
180
178
return baseDir .findSubdirectory (NewSetupDataPatchAction .DATA_DIRECTORY );
181
179
}
182
180
183
181
return targetDirectory ;
184
182
}
185
183
186
- private PsiDirectory createDirectory (PsiDirectory targetDirectory ) {
187
- if ( targetDirectory . getName () .equals (NewSetupDataPatchAction . ROOT_DIRECTORY )) {
188
- PsiDirectory subDirectoryPatch = targetDirectory .findSubdirectory (
184
+ private PsiDirectory createDirectory (final PsiDirectory targetDirectory ) {
185
+ if ( NewSetupDataPatchAction . ROOT_DIRECTORY .equals (targetDirectory . getName ())) {
186
+ final PsiDirectory subDirectoryPatch = targetDirectory .findSubdirectory (
189
187
NewSetupDataPatchAction .PATCH_DIRECTORY
190
188
);
191
189
192
- if (subDirectoryPatch == null ) {
190
+ if (subDirectoryPatch == null ) {
193
191
return targetDirectory .createSubdirectory (
194
192
NewSetupDataPatchAction .PATCH_DIRECTORY
195
193
).createSubdirectory (NewSetupDataPatchAction .DATA_DIRECTORY );
196
194
}
197
- PsiDirectory subDirectoryData = subDirectoryPatch .findSubdirectory (
195
+ final PsiDirectory subDirectoryData = subDirectoryPatch .findSubdirectory (
198
196
NewSetupDataPatchAction .DATA_DIRECTORY
199
197
);
200
198
@@ -204,8 +202,8 @@ private PsiDirectory createDirectory(PsiDirectory targetDirectory) {
204
202
)
205
203
);
206
204
}
207
- if ( targetDirectory . getName () .equals (NewSetupDataPatchAction . PATCH_DIRECTORY )) {
208
- PsiDirectory subDirectoryData = targetDirectory .findSubdirectory (
205
+ if ( NewSetupDataPatchAction . PATCH_DIRECTORY .equals (targetDirectory . getName ())) {
206
+ final PsiDirectory subDirectoryData = targetDirectory .findSubdirectory (
209
207
NewSetupDataPatchAction .DATA_DIRECTORY
210
208
);
211
209
0 commit comments