From 713311aa1edfda8d69031868e6820c40cefd36c0 Mon Sep 17 00:00:00 2001 From: Mykola Donin Date: Wed, 9 Feb 2022 17:19:24 +0200 Subject: [PATCH 1/2] Added a new context dependent Action for the acl.xml file generation --- resources/META-INF/plugin.xml | 1 + .../internal/Magento ACL XML.xml.ft | 3 +- .../actions/context/xml/NewAclXmlAction.java | 49 +++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/com/magento/idea/magento2plugin/actions/context/xml/NewAclXmlAction.java diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 48ccf6142..eb5e89e78 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -60,6 +60,7 @@ + diff --git a/resources/fileTemplates/internal/Magento ACL XML.xml.ft b/resources/fileTemplates/internal/Magento ACL XML.xml.ft index e71b822e9..717f337bc 100644 --- a/resources/fileTemplates/internal/Magento ACL XML.xml.ft +++ b/resources/fileTemplates/internal/Magento ACL XML.xml.ft @@ -1,4 +1,5 @@ #parse("XML File Header.xml") - + diff --git a/src/com/magento/idea/magento2plugin/actions/context/xml/NewAclXmlAction.java b/src/com/magento/idea/magento2plugin/actions/context/xml/NewAclXmlAction.java new file mode 100644 index 000000000..4939760fb --- /dev/null +++ b/src/com/magento/idea/magento2plugin/actions/context/xml/NewAclXmlAction.java @@ -0,0 +1,49 @@ +/* + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +package com.magento.idea.magento2plugin.actions.context.xml; + +import com.intellij.ide.fileTemplates.actions.AttributesDefaults; +import com.intellij.psi.PsiDirectory; +import com.intellij.psi.PsiFile; +import com.magento.idea.magento2plugin.actions.context.AbstractContextAction; +import com.magento.idea.magento2plugin.magento.files.ModuleAclXml; +import com.magento.idea.magento2plugin.magento.packages.ComponentType; +import com.magento.idea.magento2plugin.magento.packages.Package; +import com.magento.idea.magento2plugin.util.magento.GetMagentoModuleUtil; +import org.jetbrains.annotations.NotNull; + +public class NewAclXmlAction extends AbstractContextAction { + + public static final String ACTION_NAME = "Magento 2 ACL File"; + public static final String ACTION_DESCRIPTION = "Create a new Magento 2 acl.xml file"; + + /** + * New routes.xml file generation action constructor. + */ + public NewAclXmlAction() { + super(ACTION_NAME, ACTION_DESCRIPTION, ModuleAclXml.getInstance()); + } + + @Override + protected boolean isVisible( + final @NotNull GetMagentoModuleUtil.MagentoModuleData moduleData, + final @NotNull PsiDirectory targetDirectory, + final PsiFile targetFile + ) { + return targetDirectory.getName().equals(Package.moduleBaseAreaDir) + && moduleData.getType().equals(ComponentType.module); + } + + @Override + protected AttributesDefaults getProperties( + final @NotNull AttributesDefaults defaults, + final @NotNull GetMagentoModuleUtil.MagentoModuleData moduleData, + final PsiDirectory targetDirectory, + final PsiFile targetFile + ) { + return defaults; + } +} From 1ac2b76988e7a1233e27d341aad066763a4ac8c1 Mon Sep 17 00:00:00 2001 From: Mykola Donin Date: Thu, 10 Feb 2022 10:47:26 +0200 Subject: [PATCH 2/2] 965: update annotation --- .../magento2plugin/actions/context/xml/NewAclXmlAction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/magento/idea/magento2plugin/actions/context/xml/NewAclXmlAction.java b/src/com/magento/idea/magento2plugin/actions/context/xml/NewAclXmlAction.java index 4939760fb..0b996ce97 100644 --- a/src/com/magento/idea/magento2plugin/actions/context/xml/NewAclXmlAction.java +++ b/src/com/magento/idea/magento2plugin/actions/context/xml/NewAclXmlAction.java @@ -21,7 +21,7 @@ public class NewAclXmlAction extends AbstractContextAction { public static final String ACTION_DESCRIPTION = "Create a new Magento 2 acl.xml file"; /** - * New routes.xml file generation action constructor. + * New acl.xml file generation action constructor. */ public NewAclXmlAction() { super(ACTION_NAME, ACTION_DESCRIPTION, ModuleAclXml.getInstance());