Skip to content

Commit 1b7391c

Browse files
committed
1315: static fix and CHANGELOG.md
1 parent 40d763d commit 1b7391c

File tree

3 files changed

+63
-23
lines changed

3 files changed

+63
-23
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
1818
Updated Run command.
1919
- java.lang.Throwable: Assertion failed: Do not use PsiElement for popup model. See PsiTargetNavigator [#2485](https://github.com/magento/magento2-phpstorm-plugin/pull/2485)
2020
- Slow operations are prohibited on EDT [#2486](https://github.com/magento/magento2-phpstorm-plugin/pull/2486)
21+
- When creating a new model with a listing component grid, fulltext search is not working [#2037](https://github.com/magento/magento2-phpstorm-plugin/pull/2037)
2122

2223
### Changed
2324

src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewLayoutTemplateDialog.java

+27-14
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,27 @@
1818
import com.magento.idea.magento2plugin.actions.generation.generator.LayoutXmlTemplateGenerator;
1919
import com.magento.idea.magento2plugin.magento.packages.Areas;
2020
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
21-
22-
import javax.swing.*;
2321
import java.awt.event.KeyEvent;
2422
import java.awt.event.WindowAdapter;
2523
import java.awt.event.WindowEvent;
2624
import java.util.HashMap;
2725
import java.util.Map;
28-
26+
import javax.swing.JButton;
27+
import javax.swing.JComboBox;
28+
import javax.swing.JComponent;
29+
import javax.swing.JLabel;
30+
import javax.swing.JPanel;
31+
import javax.swing.JTextField;
32+
import javax.swing.KeyStroke;
33+
34+
@SuppressWarnings({
35+
"PMD.TooManyFields",
36+
"PMD.TooManyMethods",
37+
"PMD.ConstructorCallsOverridableMethod",
38+
"PMD.ExcessiveImports",
39+
"PMD.SingularField",
40+
"PMD.GodClass"
41+
})
2942
public class NewLayoutTemplateDialog extends AbstractDialog {
3043

3144
private static final String LAYOUT_NAME = "Layout Name";
@@ -49,7 +62,7 @@ public class NewLayoutTemplateDialog extends AbstractDialog {
4962
private JLabel areaLabel;
5063
private JLabel layoutNameErrorMessage;
5164

52-
public NewLayoutTemplateDialog(Project project, PsiDirectory directory) {
65+
public NewLayoutTemplateDialog(final Project project, final PsiDirectory directory) {
5366
super();
5467

5568
this.project = project;
@@ -83,17 +96,17 @@ public void windowClosing(WindowEvent event) {
8396
autoSelectCurrentArea();
8497
}
8598

86-
public static void open(Project project, PsiDirectory directory) {
87-
NewLayoutTemplateDialog dialog = new NewLayoutTemplateDialog(project, directory);
99+
public static void open(final Project project, final PsiDirectory directory) {
100+
final NewLayoutTemplateDialog dialog = new NewLayoutTemplateDialog(project, directory);
88101
dialog.pack();
89102
dialog.centerDialog(dialog);
90103
dialog.setVisible(true);
91104
}
92105

93106
private void onOK() {
94107
if (validateFormFields()) {
95-
String[] layoutNameParts = getLayoutNameParts();
96-
LayoutXmlData layoutXmlData = new LayoutXmlData(
108+
final String[] layoutNameParts = getLayoutNameParts();
109+
final LayoutXmlData layoutXmlData = new LayoutXmlData(
97110
getArea(),
98111
layoutNameParts[0],
99112
moduleName,
@@ -110,30 +123,30 @@ private void onOK() {
110123
private void createUIComponents() {
111124
area = new ComboBox<>();
112125

113-
for (Areas areaEntry : Areas.values()) {
126+
for (final Areas areaEntry : Areas.values()) {
114127
if (areaEntry.equals(Areas.adminhtml) || areaEntry.equals(Areas.frontend)) {
115128
area.addItem(new ComboBoxItemData(areaEntry.toString(), areaEntry.toString()));
116129
}
117130
}
118131
}
119132

120133
private void autoSelectCurrentArea() {
121-
String selectedDirName = directory.getName();
122-
Map<String, Integer> areaIndexMap = new HashMap<>();
134+
final String selectedDirName = directory.getName();
135+
final Map<String, Integer> areaIndexMap = new HashMap<>();
123136

124137
for (int i = 0; i < area.getItemCount(); i++) {
125-
ComboBoxItemData item = area.getItemAt(i);
138+
final ComboBoxItemData item = area.getItemAt(i);
126139
areaIndexMap.put(item.getKey(), i);
127140
}
128141

129-
Integer selectedIndex = areaIndexMap.get(selectedDirName);
142+
final Integer selectedIndex = areaIndexMap.get(selectedDirName);
130143
if (selectedIndex != null) {
131144
area.setSelectedIndex(selectedIndex);
132145
}
133146
}
134147

135148
private String[] getLayoutNameParts() {
136-
String[] layoutNameParts = layoutName.getText().trim().split("_");
149+
final String[] layoutNameParts = layoutName.getText().trim().split("_");
137150
String routeName = "";
138151
String controllerName = "";
139152
String actionName = "";

src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewSetupDataPatchDialog.java

+35-9
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@
1717
import com.magento.idea.magento2plugin.actions.generation.generator.ModuleSetupDataPatchGenerator;
1818
import com.magento.idea.magento2plugin.actions.generation.generator.util.DirectoryGenerator;
1919
import com.magento.idea.magento2plugin.magento.files.ModuleSetupDataPatchFile;
20-
21-
import javax.swing.*;
2220
import java.awt.event.KeyEvent;
2321
import java.awt.event.WindowAdapter;
2422
import java.awt.event.WindowEvent;
23+
import javax.swing.JButton;
24+
import javax.swing.JComponent;
25+
import javax.swing.JLabel;
26+
import javax.swing.JPanel;
27+
import javax.swing.JTextField;
28+
import javax.swing.KeyStroke;
2529

2630
public class NewSetupDataPatchDialog extends AbstractDialog {
2731

@@ -46,7 +50,12 @@ public class NewSetupDataPatchDialog extends AbstractDialog {
4650
/**
4751
* Constructor
4852
*/
49-
public NewSetupDataPatchDialog(Project project, PsiDirectory directory, String modulePackage, String moduleName) {
53+
public NewSetupDataPatchDialog(
54+
Project project,
55+
PsiDirectory directory,
56+
String modulePackage,
57+
String moduleName
58+
) {
5059
super();
5160

5261
this.project = project;
@@ -84,8 +93,18 @@ public void windowClosing(WindowEvent event) {
8493
/**
8594
* Open dialog
8695
*/
87-
public static void open(Project project, PsiDirectory directory, String modulePackage, String moduleName) {
88-
NewSetupDataPatchDialog dialog = new NewSetupDataPatchDialog(project, directory, modulePackage, moduleName);
96+
public static void open(
97+
Project project,
98+
PsiDirectory directory,
99+
String modulePackage,
100+
String moduleName
101+
) {
102+
NewSetupDataPatchDialog dialog = new NewSetupDataPatchDialog(
103+
project,
104+
directory,
105+
modulePackage,
106+
moduleName
107+
);
89108
dialog.pack();
90109
dialog.centerDialog(dialog);
91110
dialog.setVisible(true);
@@ -104,7 +123,9 @@ protected void onOK() {
104123
private void generateFile() {
105124
PsiDirectory directory = DirectoryGenerator.getInstance().findOrCreateSubdirectories(
106125
baseDir,
107-
NewSetupDataPatchAction.PATCH_DIRECTORY + "/" + NewSetupDataPatchAction.DATA_DIRECTORY
126+
NewSetupDataPatchAction.PATCH_DIRECTORY
127+
+ "/"
128+
+ NewSetupDataPatchAction.DATA_DIRECTORY
108129
);
109130
ModuleSetupDataPatchGenerator generator = new ModuleSetupDataPatchGenerator(
110131
new ModuleSetupDataPatchData(
@@ -124,7 +145,8 @@ public String getClassName() {
124145
}
125146

126147
private boolean validateFields() {
127-
PsiDirectory patchDirectory = baseDir.findSubdirectory(NewSetupDataPatchAction.PATCH_DIRECTORY);
148+
PsiDirectory patchDirectory = baseDir
149+
.findSubdirectory(NewSetupDataPatchAction.PATCH_DIRECTORY);
128150
PsiDirectory directory = null;
129151

130152
if (patchDirectory != null) {
@@ -133,10 +155,14 @@ private boolean validateFields() {
133155

134156
if (directory != null) {
135157
for (PsiFile file : directory.getFiles()) {
136-
String className = ModuleSetupDataPatchFile.resolveClassNameFromInput(getClassName());
158+
String className = ModuleSetupDataPatchFile
159+
.resolveClassNameFromInput(getClassName());
137160

138161
if (file.getName().equals(className + ModuleSetupDataPatchFile.EXTENSION)) {
139-
showErrorMessage(fieldsValidationsList.get(0).getField(), "Class name `" + className + "` already exists.");
162+
showErrorMessage(
163+
fieldsValidationsList.get(0).getField(),
164+
"Class name `" + className + "` already exists."
165+
);
140166
return false;
141167
}
142168
}

0 commit comments

Comments
 (0)