Hello World developed by IntelliJ Plugin (2)

Learned the IntelliJ Plugin development environment configuration, and then follow the world conventions to come to a Hello World familiar environment.

1. Create a plug-in project

Open IDEA and select Create New Project on the startup interface. In the pop-up window, select IntelliJ Platform Plugin, the next step.

Set the project name and save the directory location. Continue to Finish to complete the creation.

After the project is created, the plugin.xml main configuration file is automatically opened by default, and some nodes report errors, and the content of the nodes needs to be changed.

As shown above. For the time being, you can modify the content according to your own understanding, and the content of the configuration file will be explained in detail later.

carry on.

Personal habit, create a package in the src directory,

Right-click on the package name, select New → Plugin Devkit → Action, create the menu entry Action class of the plugin,

Here comes the point, what are the meanings of the options in the above window? How to set it up?

Action ID: The id of the Action in the plug-in, which distinguishes other actions of the current plug-in from the actions of other plug-ins. The recommended setting is: plug-in package name + plug-in name + class name. (In the picture above, my package name seems to be wrong, a mistake)

Class Name: Class name

Name: The name displayed on the menu.

Description: When the mouse is hovering over the current menu, the content displayed in the status bar at the lower left corner of the IDEA interface, the description text of the current menu.

Add to group----------------------

Groups: The position where the current menu item is to be added (menu bar, toolbar, right-click menu).

Actions: Reference Actions for relative positions. The metaphor is near the copy and paste menu group.

Anchor: Relative context. The metaphor is behind the thick copy and paste menu.

Keyboard Shortcuts-------------

First: The preferred shortcut key.

Second: Optional shortcut key.

After filling in, click OK.

The above configuration means that the HelloAction menu is configured in the right-click menu of the Project and displayed below the copy and paste group.

 

Write the code in the HelloAction class:


/**
 * @ Author: duke
 * @ DateTime: 2019-01-06 14:19
 * @ Description:
 */
public class HelloAction extends AnAction {
 
    @Override
    public void actionPerformed(AnActionEvent e) {
        // TODO: insert action logic here
        Messages.showMessageDialog("hello world",
                "test",
                Messages.getInformationIcon());
    }
}

In the HelloAction class above, the code is very simple, that is, when the menu item is clicked, the Dialog pops up, and the content displays Hello World.

The Hello World project is created.

 

 

Guess you like

Origin blog.csdn.net/fesdgasdgasdg/article/details/85938208