Skip to content

Commit dace03a

Browse files
committed
968: Added a new context dependent Action for the webapi.xml file generation
1 parent f10c3d5 commit dace03a

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<separator/>
6161
<!-- Context dependent actions -->
6262
<action id="MagentoCreateRoutesFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewRoutesXmlAction"/>
63+
<action id="MagentoCreateWebapiFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewWebapiXmlAction"/>
6364
<!-- Context dependent actions -->
6465
<separator/>
6566
<add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewXml"/>
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+
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.ModuleWebApiXmlFile;
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 NewWebapiXmlAction extends AbstractContextAction {
19+
20+
public static final String ACTION_NAME = "Magento 2 WEBAPI File";
21+
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 webapi.xml file";
22+
23+
/**
24+
* New routes.xml file generation action constructor.
25+
*/
26+
public NewWebapiXmlAction() {
27+
super(ACTION_NAME, ACTION_DESCRIPTION, new ModuleWebApiXmlFile());
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+
return targetDirectory.getName().equals(Package.moduleBaseAreaDir)
37+
&& moduleData.getType().equals(ComponentType.module);
38+
}
39+
40+
@Override
41+
protected AttributesDefaults getProperties(
42+
final @NotNull AttributesDefaults defaults,
43+
final @NotNull GetMagentoModuleUtil.MagentoModuleData moduleData,
44+
final PsiDirectory targetDirectory,
45+
final PsiFile targetFile
46+
) {
47+
return defaults;
48+
}
49+
}

0 commit comments

Comments
 (0)