Skip to content

Commit db981f5

Browse files
author
Vitaliy
authored
Merge branch '1.0.0-develop' into code-generation-di-xml-plugin-template-description
2 parents 86bbb19 + ae4645b commit db981f5

17 files changed

+723
-50
lines changed

resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<!-- Module file generators -->
5858
<group id="MagentoNewModuleFileGroup" class="com.magento.idea.magento2plugin.actions.groups.NewModuleFileGroup" text="Module File" popup="true">
5959
<action id="MagentoCreateABlock" class="com.magento.idea.magento2plugin.actions.generation.NewBlockAction" />
60+
<action id="MagentoCreateAViewModel" class="com.magento.idea.magento2plugin.actions.generation.NewViewModelAction" />
6061
<add-to-group group-id="NewGroup" anchor="last"/>
6162
</group>
6263

resources/META-INF/withJsGraphQl.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@
33
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.graphql.GraphQlResolverIndex" />
44
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.php.linemarker.GraphQlResolverUsageLineMarkerProvider"/>
55
<codeInsight.lineMarkerProvider language="GraphQL" implementationClass="com.magento.idea.magento2plugin.graphql.linemarker.GraphQlResolverClassLineMarkerProvider"/>
6+
<localInspection language="PHP" groupPath="PHP"
7+
shortName="GraphQlResolverInspection" displayName="Graphql must implements ResolverInterface"
8+
groupName="Magento 2"
9+
enabledByDefault="true"
10+
level="ERROR"
11+
implementationClass="com.magento.idea.magento2plugin.inspections.php.GraphQlResolverInspection"/>
612
</extensions>
713
</idea-plugin>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html>
8+
<body>
9+
<p>
10+
All GraphQl resolver must implements Magento\Framework\GraphQl\Query\ResolverInterface interface
11+
</p>
12+
</body>
13+
</html>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.actions.generation;
6+
7+
import com.intellij.ide.IdeView;
8+
import com.intellij.openapi.actionSystem.*;
9+
import com.intellij.openapi.project.Project;
10+
import com.intellij.psi.PsiDirectory;
11+
import com.magento.idea.magento2plugin.MagentoIcons;
12+
import com.magento.idea.magento2plugin.actions.generation.dialog.NewViewModelDialog;
13+
import org.jetbrains.annotations.NotNull;
14+
15+
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";
18+
19+
NewViewModelAction() {
20+
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
21+
}
22+
23+
@Override
24+
public void actionPerformed(@NotNull AnActionEvent e) {
25+
DataContext dataContext = e.getDataContext();
26+
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
27+
if (view == null) {
28+
return;
29+
}
30+
31+
Project project = CommonDataKeys.PROJECT.getData(dataContext);
32+
if (project == null) {
33+
return;
34+
}
35+
36+
PsiDirectory directory = view.getOrChooseDirectory();
37+
if (directory == null) {
38+
return;
39+
}
40+
41+
NewViewModelDialog.open(project, directory);
42+
}
43+
44+
@Override
45+
public boolean isDumbAware() {
46+
return false;
47+
}
48+
}
49+

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@ public void update(AnActionEvent event) {
3737
PsiFile psiFile = pair.getFirst();
3838
PhpClass phpClass = pair.getSecond();
3939
targetClass = phpClass;
40-
if (!(psiFile instanceof PhpFile) && phpClass != null) {
40+
if (psiFile instanceof PhpFile && phpClass != null) {
41+
this.setStatus(event, true);
42+
} else {
4143
this.setStatus(event, false);
42-
return;
4344
}
4445
} else {
4546
this.setStatus(event, false);
46-
return;
4747
}
48-
this.setStatus(event, true);
4948
}
5049

5150
private void setStatus(AnActionEvent event, boolean status) {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.actions.generation.data;
6+
7+
public class ViewModelFileData {
8+
private String viewModelDirectory;
9+
private String viewModelClassName;
10+
private String viewModelModule;
11+
private String namespace;
12+
13+
public ViewModelFileData(
14+
String viewModelDirectory,
15+
String viewModelClassName,
16+
String viewModelModule,
17+
String namespace
18+
) {
19+
this.viewModelDirectory = viewModelDirectory;
20+
this.viewModelClassName = viewModelClassName;
21+
this.viewModelModule = viewModelModule;
22+
this.namespace = namespace;
23+
}
24+
25+
public String getViewModelClassName() {
26+
return viewModelClassName;
27+
}
28+
29+
public String getViewModelDirectory() {
30+
return viewModelDirectory;
31+
}
32+
33+
public String getViewModelModule() {
34+
return viewModelModule;
35+
}
36+
37+
public String getNamespace() {
38+
return namespace;
39+
}
40+
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.magento.idea.magento2plugin.actions.generation.dialog.NewViewModelDialog">
3+
<grid id="1871d" binding="contentPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
4+
<margin top="10" left="10" bottom="10" right="10"/>
5+
<constraints>
6+
<xy x="70" y="43" width="419" height="356"/>
7+
</constraints>
8+
<properties>
9+
<opaque value="true"/>
10+
<preferredSize width="420" height="120"/>
11+
<requestFocusEnabled value="true"/>
12+
</properties>
13+
<border type="none"/>
14+
<children>
15+
<grid id="90a70" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
16+
<margin top="0" left="0" bottom="0" right="0"/>
17+
<constraints>
18+
<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"/>
19+
</constraints>
20+
<properties/>
21+
<border type="none"/>
22+
<children>
23+
<component id="b0da4" class="javax.swing.JLabel">
24+
<constraints>
25+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
26+
<preferred-size width="113" height="16"/>
27+
</grid>
28+
</constraints>
29+
<properties>
30+
<labelFor value="2d9cc"/>
31+
<text value="View Model Name"/>
32+
</properties>
33+
</component>
34+
<component id="1f03b" class="javax.swing.JTextField" binding="viewModelName">
35+
<constraints>
36+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
37+
<preferred-size width="150" height="-1"/>
38+
</grid>
39+
</constraints>
40+
<properties/>
41+
<clientProperties>
42+
<html.disable class="java.lang.Boolean" value="true"/>
43+
</clientProperties>
44+
</component>
45+
<component id="29a9d" class="javax.swing.JTextField" binding="viewModelParentDir">
46+
<constraints>
47+
<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">
48+
<preferred-size width="150" height="-1"/>
49+
</grid>
50+
</constraints>
51+
<properties/>
52+
<clientProperties>
53+
<html.disable class="java.lang.Boolean" value="true"/>
54+
</clientProperties>
55+
</component>
56+
<component id="b5004" class="javax.swing.JLabel">
57+
<constraints>
58+
<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"/>
59+
</constraints>
60+
<properties>
61+
<labelFor value="fdc52"/>
62+
<text value="View Model Directory"/>
63+
</properties>
64+
<clientProperties>
65+
<html.disable class="java.lang.Boolean" value="true"/>
66+
</clientProperties>
67+
</component>
68+
</children>
69+
</grid>
70+
<grid id="b0154" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
71+
<margin top="0" left="0" bottom="0" right="0"/>
72+
<constraints>
73+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
74+
</constraints>
75+
<properties/>
76+
<border type="none"/>
77+
<children>
78+
<vspacer id="28111">
79+
<constraints>
80+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
81+
</constraints>
82+
</vspacer>
83+
</children>
84+
</grid>
85+
<grid id="9ad5" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
86+
<margin top="0" left="0" bottom="0" right="0"/>
87+
<constraints>
88+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
89+
</constraints>
90+
<properties/>
91+
<border type="none"/>
92+
<children>
93+
<hspacer id="4aa6d">
94+
<constraints>
95+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
96+
</constraints>
97+
</hspacer>
98+
<grid id="f892c" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="true" same-size-vertically="false" hgap="-1" vgap="-1">
99+
<margin top="0" left="0" bottom="0" right="0"/>
100+
<constraints>
101+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
102+
</constraints>
103+
<properties/>
104+
<border type="none"/>
105+
<children>
106+
<component id="20801" class="javax.swing.JButton" binding="buttonOK">
107+
<constraints>
108+
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
109+
</constraints>
110+
<properties>
111+
<text value="OK"/>
112+
</properties>
113+
</component>
114+
<component id="1b860" class="javax.swing.JButton" binding="buttonCancel">
115+
<constraints>
116+
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
117+
</constraints>
118+
<properties>
119+
<text value="Cancel"/>
120+
</properties>
121+
</component>
122+
</children>
123+
</grid>
124+
</children>
125+
</grid>
126+
</children>
127+
</grid>
128+
</form>

0 commit comments

Comments
 (0)