Skip to content

Software Development at Program Tom LTD

Place for coding, programming, development and software in general.

Menu
  • Blog
  • PDF Booklets
  • Dev Utils & Content
  • Java Spring Boot Or Web Apps
  • English
    • български
    • English
    • Español
    • Português
    • हिन्दी
    • Русский
    • Deutsch
    • Français
    • Italiano
    • العربية
  • About Us
Menu
Getting started code for Intellij Plugin that adds a view with two textareas and a button that calls an endpoint

Getting started code for Intellij Plugin View

Posted on September 2, 2024September 2, 2024 by Toma Velev

Here’s a basic example of how to create an IntelliJ plugin that adds a custom view.

Step 1: Create a new IntelliJ Plugin project

First, you need to create a new IntelliJ plugin project in IntelliJ IDEA Community. To do this:

  • Open IntelliJ IDEA
  • Go to File > New Project
  • In the “New Project” dialog box, select “IDE Plugin” under the “Generators” section.
  • Fill in the required information (e.g., plugin name, description, etc.)
  • Click on “Create”

Step 2: Register the plugin

We need to register our plugin with IntelliJ IDEA. To do this:

  • Open the plugin.xml file in the src/resources/META-INF
  • Add a new <toolWindow> element to the <extensions> section:
<extensions defaultExtensionNs="com.intellij">
<toolWindow id="GPT Chat"
            factoryClass="com.programtom.intellijgpt.GptWindowFactory"
            anchor="right"/>
</extensions>

Step 2: Create a new UI component

IntelliJ has moved to kotlin programming language – so live with it. Create new Kotlin class:

class GptWindowFactory : ToolWindowFactory {

    override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
        val myToolWindow = GPTChatWindow()
        val contentFactory = ContentFactory.getInstance()
        val content = contentFactory.createContent(myToolWindow.content, "", false)
        toolWindow.contentManager.addContent(content)
    }
}

and create a awt/swing UI for your view:

@Service(Service.Level.PROJECT)
class GPTChatWindow {
val content: JPanel
 init {
    this.content = JPanel().apply {
 //... your UI code here
}}}

Caveats

There are probably million and one items that you need to address. The IntelliJ SDK has virtual wrappers around all kinds of APIs

  • File API
  • Background Work API
  • UI Access/change API
  • etc

As minimal – I want to share how to execute some work and “push” it to the UI. You need to

  • Start a new thread like this:
    ApplicationManager.getApplication().executeOnPooledThread { ... }
  • Publish back to the UI with
    ApplicationManager.getApplication().runReadAction { ... } //runWriteAction

Step 3: Run the plugin

The project comes with run configuration of “gradle runIde”, that allows you to hit Run Plugin – and test your code.

Step 4: Deploy

There are some more steps in the way of trully publishing it to the world and getting it approved in the marketplace, but – they are for another article. To get an actual build – just add “gradle assemble” Run Configuration. It will create a zip in build/distribution that you could share for beta testing.

If you are interested, I’ve done some plugins for:

  • previous company that I’ve worked for – that bootstraps tests initial code – based on the existing business logic code
  • I’ve coded a Plugin for my App Builder https://programtom.com/dev/product/app-builder-code-generation-spring-micro-service-vaadin-app/. The code is on github https://github.com/tomavelev/app_builder_plugins. To be honest – I’ve paused the work on the plugin – as there is no interest – and the last time I’ve tried it – it didn’t work
  • The code in this article I’ve used in GPT IntelliJ: https://github.com/tomavelev/intellij-gpt as I’ve got interested in the AI space with several items build around it:
    • https://programtom.com/dev/product/own-your-chat-with-llm-gpt/
    • https://programtom.com/dev/product/gpt-chat-readme-md-to-html-fast-post-code/
    • https://programtom.com/dev/product/gpt-spring-boot-micro-service/
  • Feature Flags – Enable Functionality from the BackEnd
  • Integrating xAI Grok API with Spring Boot
  • How to Progresively Integrate AI
  • What is an AI Agent
  • Flutter image scaling

Categories

  • Apps (22)
  • ChatGPT (23)
  • Choosing a Framework (38)
  • Flutter (256)
  • Graphical User Interface (14)
  • Marketing (116)
  • Software Development (281)
  • Spring (44)
  • StartUp (22)
  • Uncategorized (14)
  • Uncategorized (4)
  • Vaadin (14)

Tags

Algorithms (9) crypto (29) flutterdev (39) General (86) Java (7) QR & Bar Codes (3) Software Dev Choices (33) Spring Boot (1) standards (1) Theme (3) User Authentication & Authorization (9) User Experience (10) Utilities (19) WordPress (11)

Product categories

  • All Technologies (84)
    • Flutter Apps (24)
    • GPT (4)
    • Java (38)
    • Native Android (3)
    • PHP (9)
    • Spring (Boot) / Quarkus (35)
    • Utils (15)
    • Vaadin 24+ (27)
    • Vaadin 8 (1)
  • Apps (18)
    • Employees DB (1)
    • Notes (6)
    • Personal Budget (1)
    • Recipes Book (1)
    • Stuff Organizer (1)
    • To-Do (2)
  • PDF Books (3)
  • Source Code Generators (8)

Recent Posts

  • Feature Flags – Enable Functionality from the BackEnd
  • Integrating xAI Grok API with Spring Boot
  • How to Progresively Integrate AI
  • What is an AI Agent
  • Flutter image scaling

Post Categories

  • Apps (22)
  • ChatGPT (23)
  • Choosing a Framework (38)
  • Flutter (256)
  • Graphical User Interface (14)
  • Marketing (116)
  • Software Development (281)
  • Spring (44)
  • StartUp (22)
  • Uncategorized (14)
  • Uncategorized (4)
  • Vaadin (14)