【idea插件开发】idea插件访问浏览器web地址

背景

以往在eclipse上面开发插件,有兴致想尝试Idea上玩一下插件开发。想要在idea上面访问web地址

概要

记录在idea上面访问web地址

正文

1、点击File->New->Project… 选择IntelliJ Platform Plugin

2、点击下一步后,输入Project Name,然后点击完成

3、新建Factory

package com.demo.view;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentManager;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

/**
 * @author twilight
 * @since V1.0
 */
public class MyToolWindowFactory implements ToolWindowFactory {
    @Override
    public void createToolWindowContent(
            @NotNull Project project,
            @NotNull ToolWindow toolWindow) {
        ContentManager contentManager = toolWindow.getContentManager();

        JFXPanel jfxPanel = new JFXPanel();
        jfxPanel.setBounds(0,0,100,200);

        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                WebView webView = new WebView();
                jfxPanel.setScene(new Scene(webView));
                webView.getEngine().load("https://m.runoob.com/maven/");
            }
        });

        Content labelContent =
                contentManager.getFactory()
                        .createContent(
                                jfxPanel,
                                "",
                                false
                        );

        contentManager.addContent(labelContent);
    }
}

4、修改plugin.xml

<idea-plugin>
  <id>com.demo.view.plugin.id</id>
  <name>com.jcef.company</name>
  <version>1.0</version>
  <vendor email="support1@yourcompany.com" url="http://www.yourcomp1any.com">Your111Company</vendor>

  <description>com.demo.view.plugin.desc/com.demo.view.plugin.desc</description>

  <change-notes>com.demo.view.plugin.desccom.demo.view.plugin.desc
  </change-notes>

  <!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
  <idea-version since-build="173.0"/>

  <!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
       on how to target different products -->
  <!-- uncomment to enable plugin in all products
  <depends>com.intellij.modules.lang</depends>
  -->

  <!-- plugin.xml文件 -->
  <extensions defaultExtensionNs="com.intellij">
    <!-- Add your extensions here -->
    <!-- id是必须的属性,我们进行添加 -->
    <!-- anchor锚点非必须,但是为了像Gradle插件一样默认显示在右边,我们设置为right -->
    <toolWindow id="web browser"
                anchor="right"
                factoryClass="com.demo.view.MyToolWindowFactory"
    />
  </extensions>
</idea-plugin>

5、打包插件

Build->PreparePlugin Module "XXX" For Deployment 

6、安装插件

File->settings...->Plugins

Restart IDE

7、运行插件

相关推荐

  1. IDEA 宝贝

    2024-01-25 16:34:02       38 阅读
  2. IDEA

    2024-01-25 16:34:02       33 阅读
  3. idea 推荐

    2024-01-25 16:34:02       34 阅读
  4. 开发工具idea中推荐

    2024-01-25 16:34:02       56 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-25 16:34:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-25 16:34:02       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-25 16:34:02       87 阅读
  4. Python语言-面向对象

    2024-01-25 16:34:02       96 阅读

热门阅读

  1. 【技能---构建github中SSH密钥的流程】

    2024-01-25 16:34:02       50 阅读
  2. openssl3.2/test/certs - 033 - time stamping certificates

    2024-01-25 16:34:02       53 阅读
  3. 刷题07 字符串easy

    2024-01-25 16:34:02       58 阅读
  4. 大数据框架及其处理架构详析

    2024-01-25 16:34:02       52 阅读
  5. 【代码随想录】刷题笔记Day55

    2024-01-25 16:34:02       58 阅读
  6. 重学webpack

    2024-01-25 16:34:02       47 阅读