My Java plugin for WebStorm
This is my plugin for WebStorm https://github.com/AAlex-11/WebStorm-Plugin-Java, time on time I make various plugin for WebStorm, this plugin need me for one my project, in this project I need create a lot of files with rules - XXXX.js file and related XXXX.txt file in current directory. At common this is possible in command line, something by this:
# type nul > xxxx.js # type nul > xxxx.txt
But, of course, I already forget creating *.txt file after create *.js file, or made a mistakes in names. If you need to create 10 files, this is not a problem, but if you need to create a thousands files, this is impossible to create files correctly, without mistake. This is reason why I created this plugin for WebStrom and assign key shortcut to perform this plugin.


To create plugin for WebStrom there are 3 trick to avoid license restriction, because WebStorm not allow to create plugin. Therefore first step is install clear IntelliJ IDEA Community Edition IDE - https://www.jetbrains.com/idea/download/?section=windows. This cleas intellij IDE allow to create any JAVA plugin, you just need to install IDE Plugin project:


Second trick and step is clear IntelliJ IDEA Community Edition IDE don't allow create plugin clearly. Therefore build plugin need to create in command line.


And third trick is extract JAR from unclear ZIP file in distribution. Need to unzip this archive and one of JAR is exactly plugin.

Next step is import plugin (JAR) to WebStrom or Android studio. Close clear IntelliJ IDEA IDE and open WebStorm and do it:



Next step is assign shortcut to plugin.



And voila:


So, this is my workable manifest:
1: <idea-plugin>
2: <id>com.example.filecreatorplugin</id>
3: <name>FileCreatorPlugin</name>
4: <version>1.0</version>
5: <vendor>YourName</vendor>
6:
7: <actions>
8: <action id="CreateFilesAction" class="com.example.CreateFilesAction" text="Create Files" description="Create JS and TXT files">
9: <add-to-group group-id="ToolsMenu" anchor="first"/>
10: </action>
11: </actions>
12: </idea-plugin>
And this is my workable JAVA code:
1: package com.example;
2:
3: import com.intellij.openapi.actionSystem.AnAction;
4: import com.intellij.openapi.actionSystem.AnActionEvent;
5: import com.intellij.openapi.actionSystem.CommonDataKeys;
6: import com.intellij.openapi.command.WriteCommandAction;
7: import com.intellij.openapi.ui.Messages;
8: import com.intellij.openapi.vfs.VirtualFile;
9: import org.jetbrains.annotations.NotNull;
10:
11: import java.io.IOException;
12:
13: public class CreateFilesAction extends AnAction {
14: @Override
15: public void actionPerformed(@NotNull AnActionEvent e) {
16: // Get the selected directory from the project structure
17: VirtualFile selectedDir = e.getData(CommonDataKeys.VIRTUAL_FILE);
18:
19: if (selectedDir == null || !selectedDir.isDirectory()) {
20: Messages.showErrorDialog("Please select a valid directory in the project structure.", "Error");
21: return;
22: }
23:
24: // Prompt user for input
25: String input = Messages.showInputDialog("Enter a string (e.g., AA01):", "File Creator Plugin", Messages.getQuestionIcon());
26:
27: if (input != null && !input.isEmpty()) {
28: WriteCommandAction.runWriteCommandAction(e.getProject(), () -> {
29: try {
30: // Create .js file in the selected directory
31: VirtualFile jsFile = selectedDir.createChildData(this, input + ".js");
32: jsFile.setBinaryContent(("// " + input + ".js\n").getBytes());
33:
34: // Create .txt file in the selected directory
35: VirtualFile txtFile = selectedDir.createChildData(this, input + ".txt");
36: txtFile.setBinaryContent(("This is " + input + ".txt\n").getBytes());
37:
38: Messages.showInfoMessage("Files created in: " + selectedDir.getPath(), "Success");
39: } catch (IOException ex) {
40: Messages.showErrorDialog("Failed to create files: " + ex.getMessage(), "Error");
41: }
42: });
43: } else {
44: Messages.showErrorDialog("Input cannot be empty.", "Error");
45: }
46: }
47: }
Happy programming!
Java context:
- (2025) Android mosaic #AndroidMosaic #Java
- (2025) My Java plugin for WebStorm #Java
- (2024) My Android Java Voip Messenger #Java #Android
- (2024) My Android Java apps for SelfTesting JS skills #Java #Android
- (2021) Retrofit test with interceptor, clear communication and show data to TextView #Android #Java #DevEnvironment
- (2016) Java useful links #Java
- (2016) Java Datatypes #Java
- (2016) Java OOP, idiotic C# #Java
- (2016) Java Generic, Constraints, Narrowing and Widening conversions #Java
- (2016) Java control flow #Java
- (2016) Java syntax #Java
- (2016) Java arrow functions, delegates #Java
- (2016) Java string manipulation #Java
- (2016) Java Array #Java
- (2016) Java Async programming #Java
- (2016) Java Null #Java
- (2016) Java This #Java
- (2016) Java List, Map, Set #Java
- (2016) Java Yield #Java
- (2015) Wowza missing FAQ. #Video #Java #Servers
- (2012) Подготовка к работе Eclipse. #Java
- (2012) JAVA-клиенты Windows Communication Foundation. #Java #WebServiceClient
- (2011) JAVA welcome #Java
- (2011) Установка и настройка Tomcat. #Java

|