Skip to content

Commit cd7bcd4

Browse files
872: Code refactoring
1 parent 7f3b781 commit cd7bcd4

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/com/magento/idea/magento2plugin/actions/generation/NewCLICommandAction.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,33 @@
1717
import com.magento.idea.magento2plugin.actions.generation.dialog.NewCLICommandDialog;
1818
import org.jetbrains.annotations.NotNull;
1919

20-
@SuppressWarnings({"PMD.FieldNamingConventions", "PMD.OnlyOneReturn"})
2120
public class NewCLICommandAction extends AnAction {
22-
public static String ACTION_NAME = "Magento 2 CLI Command";
23-
public static String ACTION_DESCRIPTION = "Create a new Magento 2 CLI Command";
21+
22+
public static final String ACTION_NAME = "Magento 2 CLI Command";
23+
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 CLI Command";
2424

2525
public NewCLICommandAction() {
2626
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
2727
}
2828

2929
@Override
30-
public void actionPerformed(@NotNull final AnActionEvent event) {
30+
public void actionPerformed(final @NotNull AnActionEvent event) {
3131
final DataContext context = event.getDataContext();
3232
final IdeView view = LangDataKeys.IDE_VIEW.getData(context);
33+
3334
if (view == null) {
3435
return;
3536
}
36-
3737
final Project project = CommonDataKeys.PROJECT.getData(context);
38+
3839
if (project == null) {
3940
return;
4041
}
41-
4242
final PsiDirectory directory = view.getOrChooseDirectory();
43+
4344
if (directory == null) {
4445
return;
4546
}
46-
4747
NewCLICommandDialog.open(project, directory);
4848
}
4949

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,20 @@
3535
import javax.swing.JTextArea;
3636
import javax.swing.JTextField;
3737
import javax.swing.KeyStroke;
38+
import org.jetbrains.annotations.NotNull;
3839

3940
@SuppressWarnings({"PMD.MissingSerialVersionUID", "PMD.ExcessiveImports"})
4041
public class NewCLICommandDialog extends AbstractDialog {
41-
private JPanel contentPane;
42-
private JButton buttonCancel;
43-
private JButton buttonOK;
42+
4443
private static final String CLASS_NAME = "class name";
4544
private static final String PARENT_DIRECTORY = "parent directory";
4645
private static final String COMMAND_NAME = "command name";
4746
private static final String COMMAND_DESCRIPTION = "description";
4847

48+
private JPanel contentPane;
49+
private JButton buttonCancel;
50+
private JButton buttonOK;
51+
4952
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
5053
message = {NotEmptyRule.MESSAGE, CLASS_NAME})
5154
@FieldValidation(rule = RuleRegistry.PHP_CLASS,
@@ -79,7 +82,10 @@ public class NewCLICommandDialog extends AbstractDialog {
7982
* @param project Project
8083
* @param directory PsiDirectory
8184
*/
82-
public NewCLICommandDialog(final Project project, final PsiDirectory directory) {
85+
public NewCLICommandDialog(
86+
final @NotNull Project project,
87+
final @NotNull PsiDirectory directory
88+
) {
8389
super();
8490
this.project = project;
8591
this.moduleName = GetModuleNameByDirectoryUtil.execute(directory, project);
@@ -181,8 +187,8 @@ public String getCLICommandClassFqn() {
181187
private void onOK() {
182188
if (validateFormFields() && isPHPClassValid()) {
183189
this.generate();
190+
exit();
184191
}
185-
exit();
186192
}
187193

188194
private Boolean isPHPClassValid() {

0 commit comments

Comments
 (0)