跨境派

跨境派

跨境派,专注跨境行业新闻资讯、跨境电商知识分享!

当前位置:首页 > 综合服务 > 培训机构 > 【idea插件开发】idea插件访问浏览器web地址

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

时间:2024-04-01 16:40:30 来源:网络cs 作者:胡椒 栏目:培训机构 阅读:

标签: 地址  访问  浏览 

背景

以往在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、运行插件

本文链接:https://www.kjpai.cn/news/2024-04-01/152171.html,文章来源:网络cs,作者:胡椒,版权归作者所有,如需转载请注明来源和作者,否则将追究法律责任!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。

文章评论