diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 81e4c2f1a..b57f6718b 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -61,6 +61,7 @@ + diff --git a/src/com/magento/idea/magento2plugin/actions/context/xml/NewWebapiXmlAction.java b/src/com/magento/idea/magento2plugin/actions/context/xml/NewWebapiXmlAction.java new file mode 100644 index 000000000..241d24d83 --- /dev/null +++ b/src/com/magento/idea/magento2plugin/actions/context/xml/NewWebapiXmlAction.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.ModuleWebApiXmlFile; +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 NewWebapiXmlAction extends AbstractContextAction { + + public static final String ACTION_NAME = "Magento 2 WEB API File"; + public static final String ACTION_DESCRIPTION = "Create a new Magento 2 webapi.xml file"; + + /** + * New webapi.xml file generation action constructor. + */ + public NewWebapiXmlAction() { + super(ACTION_NAME, ACTION_DESCRIPTION, new ModuleWebApiXmlFile()); + } + + @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; + } +}