Skip to content

Commit 711100a

Browse files
author
makzef
committed
1141: Add code include, don't show generation action if readme exists
1 parent 5b96139 commit 711100a

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!---
2+
You can describe your module here.
3+
We recommend that you add the following information:
4+
- implementation details: why and how to use the module, preferably with some example scenarios
5+
- any dependencies (usually other modules but could be any important dependencies, libraries, etc)
6+
- extension points, APIs, plug-ins, etc
7+
- any introduced events
8+
-->
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<html>
2+
<body>
3+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse; border-color:#111111">
4+
<tr>
5+
<td colspan="3"><font face="verdana" size="-1">This is a template is used to describe the MD file. It contains a code fragment that can be included into file templates
6+
(<b>Templates</b> tab) with the help of the <b>#parse</b> directive.<br>
7+
The template is editable. Along with the static text, code and comments.</font><br>
8+
</td>
9+
</tr>
10+
</table>
11+
</body>
12+
</html>
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
# ${PACKAGE}_${MODULE_NAME} module
22

3-
<!---
4-
You can describe your module here.
5-
We recommend that you add the following information:
6-
- implementation details: why and how to use the module, preferably with some example scenarios
7-
- any dependencies (usually other modules but could be any important dependencies, libraries, etc)
8-
- extension points, APIs, plug-ins, etc
9-
- any introduced events
10-
-->
3+
#parse("MD File Description.md")

src/com/magento/idea/magento2plugin/actions/context/md/NewReadmeMdAction.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.intellij.ide.fileTemplates.actions.AttributesDefaults;
99
import com.intellij.psi.PsiDirectory;
1010
import com.intellij.psi.PsiFile;
11+
import com.intellij.util.IncorrectOperationException;
1112
import com.magento.idea.magento2plugin.actions.context.AbstractContextAction;
1213
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
1314
import com.magento.idea.magento2plugin.magento.files.ModuleReadmeMdFile;
@@ -41,7 +42,8 @@ protected boolean isVisible(
4142
.split(Package.vendorModuleNameSeparator)[1];
4243

4344
return targetDirectory.getName().equals(magentoModuleName)
44-
&& targetDirectory.equals(moduleDirectory);
45+
&& targetDirectory.equals(moduleDirectory)
46+
&& this.isFileCanBeCreated(moduleDirectory);
4547
}
4648

4749
@Override
@@ -57,4 +59,16 @@ protected AttributesDefaults getProperties(
5759

5860
return defaults;
5961
}
62+
63+
private @NotNull Boolean isFileCanBeCreated(
64+
final @NotNull PsiDirectory moduleDirectory
65+
) {
66+
try {
67+
moduleDirectory.checkCreateFile(ModuleReadmeMdFile.FILE_NAME);
68+
} catch (IncorrectOperationException exception) {
69+
return false;
70+
}
71+
72+
return true;
73+
}
6074
}

0 commit comments

Comments
 (0)