Skip to content

Commit 9f79e0b

Browse files
author
Vitaliy
authored
Merge branch '4.3.0-develop' into mainline-eav-attr-code-genearators
2 parents 5516798 + a327cf2 commit 9f79e0b

File tree

10 files changed

+271
-19
lines changed

10 files changed

+271
-19
lines changed

resources/META-INF/plugin.xml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,25 @@
5656
<add-to-group group-id="PhpGenerateGroup" anchor="last"/>
5757
</group>
5858

59-
<group id="MagentoContextBasedActionsGroup" class="com.intellij.ide.actions.NonEmptyActionGroup" text="Context Actions" popup="false" compact="true" searchable="true">
59+
<group id="MagentoContextBasedActionsGroup" class="com.magento.idea.magento2plugin.actions.groups.ContextActionsGroup" text="Context Actions" popup="false" compact="true" searchable="true">
6060
<separator/>
6161
<!-- Context dependent actions -->
62-
<action id="MagentoCreateRoutesFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewRoutesXmlAction"/>
63-
<action id="MagentoCreateDiFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewDiXmlAction"/>
64-
<action id="MagentoCreateWebapiFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewWebapiXmlAction"/>
6562
<action id="MagentoCreateAclFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewAclXmlAction"/>
6663
<action id="MagentoCreateConfigFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewConfigXmlAction"/>
67-
<action id="MagentoCreateSystemFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewSystemXmlAction"/>
64+
<action id="MagentoCreateCrontabFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewCrontabXmlAction"/>
65+
<action id="MagentoCreateDiFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewDiXmlAction"/>
66+
<action id="MagentoCreateEmailTemplatesFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewEmailTemplatesXmlAction"/>
6867
<action id="MagentoCreateExtensionAttributesFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewExtensionAttributesXmlAction"/>
69-
<action id="MagentoCreateWidgetFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewWidgetXmlAction"/>
70-
<action id="MagentoCreateMviewFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewMviewXmlAction"/>
71-
<action id="MagentoCreateIndexerFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewIndexerXmlAction"/>
72-
<action id="MagentoCreateViewFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewViewXmlAction"/>
7368
<action id="MagentoCreateFieldsetFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewFieldsetXmlAction"/>
69+
<action id="MagentoCreateIndexerFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewIndexerXmlAction"/>
70+
<action id="MagentoCreateMviewFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewMviewXmlAction"/>
71+
<action id="MagentoCreatePageTypesFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewPageTypesXmlAction"/>
72+
<action id="MagentoCreateRoutesFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewRoutesXmlAction"/>
7473
<action id="MagentoCreateSectionsFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewSectionsXmlAction"/>
75-
<action id="MagentoCreateEmailTemplatesFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewEmailTemplatesXmlAction"/>
74+
<action id="MagentoCreateSystemFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewSystemXmlAction"/>
75+
<action id="MagentoCreateViewFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewViewXmlAction"/>
76+
<action id="MagentoCreateWebapiFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewWebapiXmlAction"/>
77+
<action id="MagentoCreateWidgetFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewWidgetXmlAction"/>
7678
<!-- Context dependent actions -->
7779
<separator/>
7880
<add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewXml"/>
@@ -594,6 +596,7 @@
594596
<internalFileTemplate name="Magento Fieldset XML"/>
595597
<internalFileTemplate name="Magento Sections XML"/>
596598
<internalFileTemplate name="Magento Module Email Templates Xml"/>
599+
<internalFileTemplate name="Magento Page Types XML"/>
597600

598601
<defaultLiveTemplates file="/liveTemplates/MagentoPWA.xml"/>
599602

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0"?>
22
#parse("XML File Header.xml")
3-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
3+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
45
</config>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0"?>
2+
#parse("XML File Header.xml")
3+
<page_types xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_types.xsd">
5+
</page_types>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html lang="en">
8+
<body>
9+
<font face="verdana" size="-1">
10+
<p>
11+
After creating a new route routing/index/index, it is a good practice to give more control
12+
on it for the admin. By creating a new Page Type, the admin can manage the content of this
13+
page using widgets.
14+
Defining a new page type: etc/frontend/page_types.xml
15+
</p>
16+
<p>
17+
Read more about page_types.xml in the
18+
<a href="https://devdocs.magento.com/guides/v2.4/extension-dev-guide/routing.html#declaring-the-new-route-as-page-type">DevDocs</a>.
19+
</p>
20+
</font>
21+
</body>
22+
</html>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.actions.context.xml;
7+
8+
import com.intellij.ide.fileTemplates.actions.AttributesDefaults;
9+
import com.intellij.psi.PsiDirectory;
10+
import com.intellij.psi.PsiFile;
11+
import com.magento.idea.magento2plugin.actions.context.AbstractContextAction;
12+
import com.magento.idea.magento2plugin.magento.files.CrontabXmlTemplate;
13+
import com.magento.idea.magento2plugin.magento.packages.ComponentType;
14+
import com.magento.idea.magento2plugin.magento.packages.Package;
15+
import com.magento.idea.magento2plugin.util.magento.GetMagentoModuleUtil;
16+
import org.jetbrains.annotations.NotNull;
17+
18+
public class NewCrontabXmlAction extends AbstractContextAction {
19+
20+
public static final String ACTION_NAME = "Magento 2 Crontab File";
21+
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 crontab.xml file";
22+
23+
/**
24+
* New crontab.xml file generation action constructor.
25+
*/
26+
public NewCrontabXmlAction() {
27+
super(ACTION_NAME, ACTION_DESCRIPTION, new CrontabXmlTemplate());
28+
}
29+
30+
@Override
31+
protected boolean isVisible(
32+
final @NotNull GetMagentoModuleUtil.MagentoModuleData moduleData,
33+
final @NotNull PsiDirectory targetDirectory,
34+
final PsiFile targetFile
35+
) {
36+
final PsiDirectory configDir = moduleData.getConfigDir();
37+
38+
if (configDir == null) {
39+
return false;
40+
}
41+
42+
return targetDirectory.getName().equals(Package.moduleBaseAreaDir)
43+
&& targetDirectory.equals(configDir)
44+
&& moduleData.getType().equals(ComponentType.module);
45+
}
46+
47+
48+
@Override
49+
protected AttributesDefaults getProperties(
50+
final @NotNull AttributesDefaults defaults,
51+
final @NotNull GetMagentoModuleUtil.MagentoModuleData moduleData,
52+
final PsiDirectory targetDirectory,
53+
final PsiFile targetFile
54+
) {
55+
return defaults;
56+
}
57+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.actions.context.xml;
7+
8+
import com.intellij.ide.fileTemplates.actions.AttributesDefaults;
9+
import com.intellij.psi.PsiDirectory;
10+
import com.intellij.psi.PsiFile;
11+
import com.magento.idea.magento2plugin.actions.context.AbstractContextAction;
12+
import com.magento.idea.magento2plugin.magento.files.ModulePageTypesXmlFile;
13+
import com.magento.idea.magento2plugin.magento.packages.Areas;
14+
import com.magento.idea.magento2plugin.magento.packages.ComponentType;
15+
import com.magento.idea.magento2plugin.util.magento.GetMagentoModuleUtil;
16+
import org.jetbrains.annotations.NotNull;
17+
18+
public class NewPageTypesXmlAction extends AbstractContextAction {
19+
20+
public static final String ACTION_NAME = "Magento 2 Page Types File";
21+
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 page_types.xml file";
22+
23+
/**
24+
* New page_types.xml file generation action constructor.
25+
*/
26+
public NewPageTypesXmlAction() {
27+
super(ACTION_NAME, ACTION_DESCRIPTION, new ModulePageTypesXmlFile());
28+
}
29+
30+
@Override
31+
protected boolean isVisible(
32+
final @NotNull GetMagentoModuleUtil.MagentoModuleData moduleData,
33+
final @NotNull PsiDirectory targetDirectory,
34+
final PsiFile targetFile
35+
) {
36+
final PsiDirectory parentDir = targetDirectory.getParentDirectory();
37+
final PsiDirectory configDir = moduleData.getConfigDir();
38+
39+
if (parentDir == null || configDir == null) {
40+
return false;
41+
}
42+
43+
return targetDirectory.getName().equals(Areas.frontend.toString())
44+
&& parentDir.equals(configDir)
45+
&& moduleData.getType().equals(ComponentType.module);
46+
}
47+
48+
49+
@Override
50+
protected AttributesDefaults getProperties(
51+
final @NotNull AttributesDefaults defaults,
52+
final @NotNull GetMagentoModuleUtil.MagentoModuleData moduleData,
53+
final PsiDirectory targetDirectory,
54+
final PsiFile targetFile
55+
) {
56+
return defaults;
57+
}
58+
}

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
<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"/>
176176
</constraints>
177177
<properties>
178-
<text value="Controller Name"/>
178+
<text value="Action Path"/>
179179
</properties>
180180
</component>
181181
<component id="bb0f3" class="javax.swing.JTextField" binding="submitControllerName">
@@ -184,7 +184,12 @@
184184
<preferred-size width="150" height="-1"/>
185185
</grid>
186186
</constraints>
187-
<properties/>
187+
<properties>
188+
<toolTipText value="Can consist of few directories, for an ex.: Product/Custom"/>
189+
</properties>
190+
<clientProperties>
191+
<promptText class="java.lang.String" value="Folder name for Action"/>
192+
</clientProperties>
188193
</component>
189194
<component id="27a44" class="javax.swing.JLabel" binding="submitActionNameLabel">
190195
<constraints>
@@ -203,6 +208,9 @@
203208
<properties>
204209
<text value="Save"/>
205210
</properties>
211+
<clientProperties>
212+
<promptText class="java.lang.String" value="Class name for Action"/>
213+
</clientProperties>
206214
</component>
207215
<component id="5065a" class="javax.swing.JLabel" binding="saveControllerLabel">
208216
<constraints>
@@ -246,7 +254,7 @@
246254
<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"/>
247255
</constraints>
248256
<properties>
249-
<text value="Controller Name"/>
257+
<text value="Action Path"/>
250258
</properties>
251259
</component>
252260
<component id="f609b" class="javax.swing.JTextField" binding="viewControllerName">
@@ -255,7 +263,12 @@
255263
<preferred-size width="150" height="-1"/>
256264
</grid>
257265
</constraints>
258-
<properties/>
266+
<properties>
267+
<toolTipText value="Can consist of few directories, for an ex.: Product/Custom"/>
268+
</properties>
269+
<clientProperties>
270+
<promptText class="java.lang.String" value="Folder name for Action"/>
271+
</clientProperties>
259272
</component>
260273
<component id="6a2bd" class="javax.swing.JLabel" binding="viewControllerLabel">
261274
<constraints>
@@ -275,6 +288,9 @@
275288
<properties>
276289
<text value="Edit"/>
277290
</properties>
291+
<clientProperties>
292+
<promptText class="java.lang.String" value="Class name for Action"/>
293+
</clientProperties>
278294
</component>
279295
<component id="e2e73" class="javax.swing.JLabel" binding="actionNameLabel">
280296
<constraints>

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,15 +407,15 @@
407407
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
408408
</constraints>
409409
<properties>
410-
<text value="Action"/>
410+
<text value="Action Name"/>
411411
</properties>
412412
</component>
413413
<component id="2ec13" class="javax.swing.JLabel" binding="controllerLabel">
414414
<constraints>
415415
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
416416
</constraints>
417417
<properties>
418-
<text value="Controller"/>
418+
<text value="Action Path"/>
419419
</properties>
420420
</component>
421421
<component id="ddde2" class="javax.swing.JTextField" binding="route">
@@ -424,15 +424,25 @@
424424
<preferred-size width="150" height="-1"/>
425425
</grid>
426426
</constraints>
427-
<properties/>
427+
<properties>
428+
<toolTipText value="The unique name of your router"/>
429+
</properties>
430+
<clientProperties>
431+
<promptText class="java.lang.String" value="entity_name"/>
432+
</clientProperties>
428433
</component>
429434
<component id="2b2ed" class="javax.swing.JTextField" binding="controllerName">
430435
<constraints>
431436
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
432437
<preferred-size width="150" height="-1"/>
433438
</grid>
434439
</constraints>
435-
<properties/>
440+
<properties>
441+
<toolTipText value="Can consist of few directories, for an ex.: Product/Custom"/>
442+
</properties>
443+
<clientProperties>
444+
<promptText class="java.lang.String" value="Folder name for Action"/>
445+
</clientProperties>
436446
</component>
437447
<component id="d08e6" class="javax.swing.JTextField" binding="actionName">
438448
<constraints>
@@ -441,6 +451,9 @@
441451
</grid>
442452
</constraints>
443453
<properties/>
454+
<clientProperties>
455+
<promptText class="java.lang.String" value="Class name for Action"/>
456+
</clientProperties>
444457
</component>
445458
<component id="e7551" class="javax.swing.JLabel" binding="controllerGeneralLabel">
446459
<constraints>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.actions.groups;
7+
8+
import com.intellij.ide.actions.NonEmptyActionGroup;
9+
import com.intellij.openapi.actionSystem.AnAction;
10+
import com.intellij.openapi.actionSystem.AnActionEvent;
11+
import java.util.Arrays;
12+
import java.util.Comparator;
13+
import java.util.LinkedList;
14+
import java.util.List;
15+
import org.jetbrains.annotations.NotNull;
16+
17+
public class ContextActionsGroup extends NonEmptyActionGroup {
18+
19+
@Override
20+
public void update(final @NotNull AnActionEvent event) {
21+
if (getChildrenCount() > 0) {
22+
final AnAction[] actions = getChildren(event);
23+
final List<AnAction> originalActionList = new LinkedList<>(Arrays.asList(actions));
24+
final List<AnAction> sortedActionList = new LinkedList<>(Arrays.asList(actions));
25+
sortedActionList.sort(new ContextActionsComparator());
26+
27+
if (!originalActionList.equals(sortedActionList)) {
28+
removeAll();
29+
addAll(sortedActionList.toArray(new AnAction[0]));
30+
}
31+
}
32+
33+
super.update(event);
34+
}
35+
36+
private static class ContextActionsComparator implements Comparator<AnAction> {
37+
38+
@Override
39+
public int compare(final AnAction action1, final AnAction action2) {
40+
if (action1.getTemplateText() == null || action2.getTemplateText() == null) {
41+
return 0;
42+
}
43+
44+
return action1.getTemplateText().compareTo(action2.getTemplateText());
45+
}
46+
}
47+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.magento.files;
7+
8+
import com.intellij.lang.Language;
9+
import com.intellij.lang.xml.XMLLanguage;
10+
11+
public final class ModulePageTypesXmlFile implements ModuleFileInterface {
12+
13+
public static final String FILE_NAME = "page_types.xml";
14+
public static final String TEMPLATE = "Magento Page Types XML";
15+
16+
@Override
17+
public String getFileName() {
18+
return FILE_NAME;
19+
}
20+
21+
@Override
22+
public String getTemplate() {
23+
return TEMPLATE;
24+
}
25+
26+
@Override
27+
public Language getLanguage() {
28+
return XMLLanguage.INSTANCE;
29+
}
30+
}

0 commit comments

Comments
 (0)