Skip to content

Commit 97fa3a3

Browse files
author
Vitaliy
authored
Merge branch '1.0.2-develop' into 247-title-resource-tag-to-be-required-in-acl.xml
2 parents 5ebb467 + b0db9cf commit 97fa3a3

32 files changed

+1012
-141
lines changed

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
1.0.1
2+
=============
3+
* Features:
4+
* Create a CLI command action
5+
* Create a CRON group action
6+
* Create a CRON job action
7+
* Create a Controller action
8+
* Code Inspection: Module declaration inspections in the scope of `module.xml` and `registration.php`
9+
* Code Inspection: GraphQL resolver in the scope of a schema file
10+
* Improvements:
11+
* Fixed the positioning of all dialog popups
12+
* Adjusted Magento root validation for consider `magento/framework` as a requirement
13+
* Adjusted Magento version validation RegExp to support patch versions
14+
* Fixed bugs:
15+
* The `create a plugin action` is accessible from the wrong context
16+
* Null pointer exception on the new module group
17+
118
1.0.0
219
=============
320
* Features:
@@ -108,4 +125,4 @@
108125
0.0.5
109126
=============
110127
* Features:
111-
* Added reference support for classes/interfaces in DI configuration
128+
* Added reference support for classes/interfaces in DI configuration

gradle-tasks/pmd/ruleset.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<rule ref="category/java/errorprone.xml">
3333
<exclude name="BeanMembersShouldSerialize"/>
3434
<exclude name="DataflowAnomalyAnalysis"/>
35+
<exclude name="MissingSerialVersionUID"/>
3536
</rule>
3637
<exclude-pattern>.*/resources/.*</exclude-pattern>
3738
<exclude-pattern>.*/testData/.*</exclude-pattern>

resources/META-INF/plugin.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
<action id="OverrideClassByAPreference.Menu" class="com.magento.idea.magento2plugin.actions.generation.OverrideClassByAPreferenceAction">
8181
<add-to-group group-id="EditorPopupMenu"/>
8282
</action>
83+
<action id="InjectAViewModelAction.Menu" class="com.magento.idea.magento2plugin.actions.generation.InjectAViewModelAction">
84+
<add-to-group group-id="EditorPopupMenu"/>
85+
</action>
8386

8487
</actions>
8588

resources/META-INF/pluginIcon.svg

Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!--
2+
/*
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html>
8+
<body>
9+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
10+
<tr>
11+
<td>
12+
<font face="verdana" size="-1">Constructor arguments. The object manager injects these arguments into the class during creation. The name of the argument configured in the XML file must correspond to the name of the parameter in the constructor in the configured class.</font>
13+
</td>
14+
</tr>
15+
</table>
16+
</body>
17+
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<argument name="${ARGUMENT_NAME}" xsi:type="${ARGUMENT_TYPE}">${ARGUMENT_VALUE}</argument>
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.actions.generation;
7+
8+
import com.intellij.openapi.actionSystem.AnActionEvent;
9+
import com.intellij.openapi.actionSystem.PlatformDataKeys;
10+
import com.intellij.openapi.editor.Caret;
11+
import com.intellij.openapi.project.DumbAwareAction;
12+
import com.intellij.openapi.project.Project;
13+
import com.intellij.psi.PsiElement;
14+
import com.intellij.psi.PsiFile;
15+
import com.intellij.psi.util.PsiTreeUtil;
16+
import com.intellij.psi.xml.XmlTag;
17+
import com.magento.idea.magento2plugin.MagentoIcons;
18+
import com.magento.idea.magento2plugin.actions.generation.dialog.InjectAViewModelDialog;
19+
import com.magento.idea.magento2plugin.magento.files.CommonXml;
20+
import com.magento.idea.magento2plugin.magento.files.LayoutXml;
21+
import com.magento.idea.magento2plugin.project.Settings;
22+
import org.jetbrains.annotations.NotNull;
23+
24+
public class InjectAViewModelAction extends DumbAwareAction {
25+
public static String actionName = "Inject a View Model...";
26+
public static String actionDescription = "Inject a View Model as an argument of block";
27+
private XmlTag targetXmlTag;
28+
29+
public InjectAViewModelAction() {
30+
super(actionName, actionDescription, MagentoIcons.MODULE);
31+
}
32+
33+
@Override
34+
public void update(final AnActionEvent event) {
35+
final Project project = event.getData(PlatformDataKeys.PROJECT);
36+
if (Settings.isEnabled(project)) {
37+
final XmlTag element = getElement(event);
38+
if (element == null) {
39+
this.setStatus(event, false);
40+
} else {
41+
targetXmlTag = element;
42+
this.setStatus(event, true);
43+
}
44+
} else {
45+
this.setStatus(event, false);
46+
}
47+
}
48+
49+
private void setStatus(final AnActionEvent event, final boolean status) {
50+
event.getPresentation().setVisible(status);
51+
event.getPresentation().setEnabled(status);
52+
}
53+
54+
@Override
55+
public void actionPerformed(final @NotNull AnActionEvent event) {
56+
InjectAViewModelDialog.open(event.getProject(), this.targetXmlTag);
57+
}
58+
59+
@Override
60+
public boolean isDumbAware() {
61+
return false;
62+
}
63+
64+
private XmlTag getElement(final @NotNull AnActionEvent event) {
65+
final Caret caret = event.getData(PlatformDataKeys.CARET);
66+
if (caret == null) {
67+
return null;
68+
}
69+
70+
final int offset = caret.getOffset();
71+
final PsiFile psiFile = event.getData(PlatformDataKeys.PSI_FILE);
72+
final PsiElement element = psiFile.findElementAt(offset);
73+
if (element == null) {
74+
return null;
75+
}
76+
77+
final XmlTag xmlTag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
78+
79+
if (xmlTag == null) {
80+
return null;
81+
}
82+
XmlTag resultTag;
83+
if (xmlTag.getName().equals(CommonXml.ATTRIBUTE_ARGUMENTS)) {
84+
resultTag = PsiTreeUtil.getParentOfType(xmlTag, XmlTag.class);
85+
} else {
86+
resultTag = xmlTag;
87+
}
88+
if (resultTag == null) {
89+
return null;
90+
}
91+
92+
if (!resultTag.getName().equals(LayoutXml.BLOCK_ATTRIBUTE_TAG_NAME)
93+
&& !resultTag.getName().equals(LayoutXml.REFERENCE_BLOCK_ATTRIBUTE_TAG_NAME)) {
94+
return null;
95+
}
96+
97+
return resultTag;
98+
}
99+
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.magento.idea.magento2plugin.actions.generation.dialog.NewModuleDialog;
1919
import com.magento.idea.magento2plugin.actions.generation.util.IsClickedDirectoryInsideProject;
2020
import com.magento.idea.magento2plugin.project.Settings;
21-
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectory;
21+
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
2222
import org.jetbrains.annotations.NotNull;
2323

2424
public class NewModuleAction extends com.intellij.openapi.actionSystem.AnAction {
@@ -86,9 +86,8 @@ public void update(final AnActionEvent event) {
8686
return;
8787
}
8888

89-
final GetModuleNameByDirectory getModuleName = GetModuleNameByDirectory
90-
.getInstance(project);
91-
final String moduleName = getModuleName.execute((PsiDirectory) psiElement);
89+
final String moduleName = GetModuleNameByDirectoryUtil
90+
.execute((PsiDirectory) psiElement, project);
9291
if (moduleName == null) {
9392
event.getPresentation().setVisible(true);
9493
return;
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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.InjectAViewModelDialog">
3+
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="3" 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="48" y="54" width="600" height="500"/>
7+
</constraints>
8+
<properties>
9+
<preferredSize width="450" height="180"/>
10+
<requestFocusEnabled value="true"/>
11+
</properties>
12+
<border type="none"/>
13+
<children>
14+
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
15+
<margin top="0" left="0" bottom="0" right="0"/>
16+
<constraints>
17+
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
18+
</constraints>
19+
<properties/>
20+
<border type="none"/>
21+
<children>
22+
<hspacer id="98af6">
23+
<constraints>
24+
<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"/>
25+
</constraints>
26+
</hspacer>
27+
<grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="true" same-size-vertically="false" hgap="-1" vgap="-1">
28+
<margin top="0" left="0" bottom="0" right="0"/>
29+
<constraints>
30+
<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"/>
31+
</constraints>
32+
<properties/>
33+
<border type="none"/>
34+
<children>
35+
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
36+
<constraints>
37+
<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"/>
38+
</constraints>
39+
<properties>
40+
<text resource-bundle="magento2/common" key="common.ok"/>
41+
</properties>
42+
</component>
43+
<component id="5723f" class="javax.swing.JButton" binding="buttonCancel">
44+
<constraints>
45+
<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"/>
46+
</constraints>
47+
<properties>
48+
<text resource-bundle="magento2/common" key="common.cancel"/>
49+
</properties>
50+
</component>
51+
</children>
52+
</grid>
53+
</children>
54+
</grid>
55+
<grid id="e3588" layout-manager="GridLayoutManager" row-count="3" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
56+
<margin top="0" left="0" bottom="0" right="0"/>
57+
<constraints>
58+
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
59+
</constraints>
60+
<properties/>
61+
<border type="none"/>
62+
<children>
63+
<component id="ad3ba" class="javax.swing.JTextField" binding="viewModelClassName">
64+
<constraints>
65+
<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">
66+
<preferred-size width="150" height="-1"/>
67+
</grid>
68+
</constraints>
69+
<properties/>
70+
<clientProperties>
71+
<html.disable class="java.lang.Boolean" value="true"/>
72+
</clientProperties>
73+
</component>
74+
<component id="3fe2b" class="javax.swing.JLabel" binding="viewModelClassNameLabel">
75+
<constraints>
76+
<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"/>
77+
</constraints>
78+
<properties>
79+
<text resource-bundle="magento2/common" key="common.className"/>
80+
</properties>
81+
</component>
82+
<component id="e4858" class="javax.swing.JTextField" binding="viewModelDirectory">
83+
<constraints>
84+
<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">
85+
<preferred-size width="150" height="-1"/>
86+
</grid>
87+
</constraints>
88+
<properties>
89+
<enabled value="true"/>
90+
<text value=""/>
91+
<toolTipText value="Preference directory path separated by slashes"/>
92+
</properties>
93+
<clientProperties>
94+
<html.disable class="java.lang.Boolean" value="true"/>
95+
</clientProperties>
96+
</component>
97+
<component id="6831e" class="javax.swing.JLabel" binding="viewModelDirectoryLabel">
98+
<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"/>
100+
</constraints>
101+
<properties>
102+
<text resource-bundle="magento2/common" key="common.directory"/>
103+
</properties>
104+
</component>
105+
<component id="2bc2c" class="javax.swing.JLabel" binding="viewModelArgumentNameLabel">
106+
<constraints>
107+
<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"/>
108+
</constraints>
109+
<properties>
110+
<text value="Argument Name"/>
111+
</properties>
112+
</component>
113+
<component id="c3a92" class="javax.swing.JTextField" binding="viewModelArgumentName">
114+
<constraints>
115+
<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">
116+
<preferred-size width="150" height="-1"/>
117+
</grid>
118+
</constraints>
119+
<properties/>
120+
</component>
121+
</children>
122+
</grid>
123+
</children>
124+
</grid>
125+
</form>

0 commit comments

Comments
 (0)