Skip to content

Commit 6304129

Browse files
authored
Merge pull request #885 from bohdan-harniuk/872-enhance-new-cli-command-dialog-ux
872: enhanced new cli command dialog UX
2 parents b537b45 + 953ef3e commit 6304129

21 files changed

+383
-195
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.jetbrains.annotations.NotNull;
1919

2020
public class NewBlockAction extends AnAction {
21+
2122
public static final String ACTION_NAME = "Magento 2 Block";
2223
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Block";
2324

@@ -26,23 +27,24 @@ public NewBlockAction() {
2627
}
2728

2829
@Override
29-
public void actionPerformed(@NotNull final AnActionEvent event) {
30+
public void actionPerformed(final @NotNull AnActionEvent event) {
3031
final DataContext dataContext = event.getDataContext();
3132
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
33+
3234
if (view == null) {
3335
return;
3436
}
3537

3638
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
39+
3740
if (project == null) {
3841
return;
3942
}
40-
4143
final PsiDirectory directory = view.getOrChooseDirectory();
44+
4245
if (directory == null) {
4346
return;
4447
}
45-
4648
NewBlockDialog.open(project, directory);
4749
}
4850

@@ -51,4 +53,3 @@ public boolean isDumbAware() {
5153
return false;
5254
}
5355
}
54-

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/NewControllerAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
import com.magento.idea.magento2plugin.MagentoIcons;
1717
import com.magento.idea.magento2plugin.actions.generation.dialog.NewControllerDialog;
1818

19-
@SuppressWarnings({"PMD.OnlyOneReturn", "PMD.FieldNamingConventions"})
2019
public class NewControllerAction extends AnAction {
20+
2121
public static final String ACTION_NAME = "Magento 2 Controller";
2222
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Controller";
2323

@@ -36,13 +36,13 @@ public void actionPerformed(final AnActionEvent event) {
3636
if (view == null) {
3737
return;
3838
}
39-
4039
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
40+
4141
if (project == null) {
4242
return;
4343
}
44-
4544
final PsiDirectory directory = view.getOrChooseDirectory();
45+
4646
if (directory == null) {
4747
return;
4848
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import com.magento.idea.magento2plugin.MagentoIcons;
1616
import com.magento.idea.magento2plugin.actions.generation.dialog.NewCronGroupDialog;
1717

18-
@SuppressWarnings({"PMD.OnlyOneReturn"})
1918
public class NewCronGroupAction extends com.intellij.openapi.actionSystem.AnAction {
19+
2020
public static final String ACTION_NAME = "Magento 2 Cron Group";
2121
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Cron Group";
2222

@@ -35,18 +35,16 @@ public void actionPerformed(final AnActionEvent event) {
3535
if (view == null) {
3636
return;
3737
}
38-
3938
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
39+
4040
if (project == null) {
4141
return;
4242
}
43-
4443
final PsiDirectory directory = view.getOrChooseDirectory();
4544

4645
if (directory == null) {
4746
return;
4847
}
49-
5048
NewCronGroupDialog.open(project, directory);
5149
}
5250

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

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

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

2525
public NewCronjobAction() {
2626
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
@@ -34,17 +34,16 @@ public void actionPerformed(final @NotNull AnActionEvent event) {
3434
if (view == null) {
3535
return;
3636
}
37-
3837
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
38+
3939
if (project == null) {
4040
return;
4141
}
42-
4342
final PsiDirectory directory = view.getOrChooseDirectory();
43+
4444
if (directory == null) {
4545
return;
4646
}
47-
4847
NewCronjobDialog.open(project, directory);
4948
}
5049

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,48 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.actions.generation;
67

78
import com.intellij.ide.IdeView;
8-
import com.intellij.openapi.actionSystem.*;
9+
import com.intellij.openapi.actionSystem.AnAction;
10+
import com.intellij.openapi.actionSystem.AnActionEvent;
11+
import com.intellij.openapi.actionSystem.CommonDataKeys;
12+
import com.intellij.openapi.actionSystem.DataContext;
13+
import com.intellij.openapi.actionSystem.LangDataKeys;
914
import com.intellij.openapi.project.Project;
1015
import com.intellij.psi.PsiDirectory;
1116
import com.magento.idea.magento2plugin.MagentoIcons;
1217
import com.magento.idea.magento2plugin.actions.generation.dialog.NewGraphQlResolverDialog;
1318
import org.jetbrains.annotations.NotNull;
1419

1520
public class NewGraphQlResolverAction extends AnAction {
16-
public static String ACTION_NAME = "Magento 2 GraphQL Resolver";
17-
public static String ACTION_DESCRIPTION = "Create a new Magento 2 GraphQL Resolver";
1821

19-
NewGraphQlResolverAction() {
22+
public static final String ACTION_NAME = "Magento 2 GraphQL Resolver";
23+
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 GraphQL Resolver";
24+
25+
public NewGraphQlResolverAction() {
2026
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
2127
}
2228

2329
@Override
24-
public void actionPerformed(@NotNull AnActionEvent e) {
25-
DataContext dataContext = e.getDataContext();
26-
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
30+
public void actionPerformed(final @NotNull AnActionEvent event) {
31+
final DataContext dataContext = event.getDataContext();
32+
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
33+
2734
if (view == null) {
2835
return;
2936
}
37+
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
3038

31-
Project project = CommonDataKeys.PROJECT.getData(dataContext);
3239
if (project == null) {
3340
return;
3441
}
42+
final PsiDirectory directory = view.getOrChooseDirectory();
3543

36-
PsiDirectory directory = view.getOrChooseDirectory();
3744
if (directory == null) {
3845
return;
3946
}
40-
4147
NewGraphQlResolverDialog.open(project, directory);
4248
}
4349

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,48 @@
22
* Copyright © Magento, Inc. All rights reserved.
33
* See COPYING.txt for license details.
44
*/
5+
56
package com.magento.idea.magento2plugin.actions.generation;
67

78
import com.intellij.ide.IdeView;
8-
import com.intellij.openapi.actionSystem.*;
9+
import com.intellij.openapi.actionSystem.AnAction;
10+
import com.intellij.openapi.actionSystem.AnActionEvent;
11+
import com.intellij.openapi.actionSystem.CommonDataKeys;
12+
import com.intellij.openapi.actionSystem.DataContext;
13+
import com.intellij.openapi.actionSystem.LangDataKeys;
914
import com.intellij.openapi.project.Project;
1015
import com.intellij.psi.PsiDirectory;
1116
import com.magento.idea.magento2plugin.MagentoIcons;
1217
import com.magento.idea.magento2plugin.actions.generation.dialog.NewViewModelDialog;
1318
import org.jetbrains.annotations.NotNull;
1419

1520
public class NewViewModelAction extends AnAction {
16-
public static String ACTION_NAME = "Magento 2 View Model";
17-
public static String ACTION_DESCRIPTION = "Create a new Magento 2 View Model";
1821

19-
NewViewModelAction() {
22+
public static final String ACTION_NAME = "Magento 2 View Model";
23+
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 View Model";
24+
25+
public NewViewModelAction() {
2026
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
2127
}
2228

2329
@Override
24-
public void actionPerformed(@NotNull AnActionEvent e) {
25-
DataContext dataContext = e.getDataContext();
26-
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
30+
public void actionPerformed(final @NotNull AnActionEvent event) {
31+
final DataContext dataContext = event.getDataContext();
32+
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
33+
2734
if (view == null) {
2835
return;
2936
}
37+
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
3038

31-
Project project = CommonDataKeys.PROJECT.getData(dataContext);
3239
if (project == null) {
3340
return;
3441
}
42+
final PsiDirectory directory = view.getOrChooseDirectory();
3543

36-
PsiDirectory directory = view.getOrChooseDirectory();
3744
if (directory == null) {
3845
return;
3946
}
40-
4147
NewViewModelDialog.open(project, directory);
4248
}
4349

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

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</grid>
5454
</children>
5555
</grid>
56-
<grid id="e3588" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
56+
<grid id="e3588" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
5757
<margin top="0" left="0" bottom="0" right="0"/>
5858
<constraints>
5959
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -85,7 +85,7 @@
8585
</component>
8686
<component id="fdc52" class="javax.swing.JTextField" binding="blockParentDir">
8787
<constraints>
88-
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
88+
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
8989
<preferred-size width="150" height="-1"/>
9090
</grid>
9191
</constraints>
@@ -96,7 +96,7 @@
9696
</component>
9797
<component id="be25f" class="javax.swing.JLabel">
9898
<constraints>
99-
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
99+
<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"/>
100100
</constraints>
101101
<properties>
102102
<labelFor value="fdc52"/>
@@ -106,6 +106,22 @@
106106
<html.disable class="java.lang.Boolean" value="true"/>
107107
</clientProperties>
108108
</component>
109+
<component id="48e8" class="javax.swing.JLabel" binding="blockNameErrorMessage">
110+
<constraints>
111+
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
112+
</constraints>
113+
<properties>
114+
<text value=""/>
115+
</properties>
116+
</component>
117+
<component id="340c3" class="javax.swing.JLabel" binding="blockParentDirErrorMessage">
118+
<constraints>
119+
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
120+
</constraints>
121+
<properties>
122+
<text value=""/>
123+
</properties>
124+
</component>
109125
</children>
110126
</grid>
111127
<grid id="ddd4f" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">

0 commit comments

Comments
 (0)