-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #971 from doninAtwix/968-generation-webapi-xml
968: Added a new context dependent Action for the webapi.xml file generation
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/com/magento/idea/magento2plugin/actions/context/xml/NewWebapiXmlAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |