Backend Development 14 min read

Build a Health‑Boosting IntelliJ IDEA Plugin: Step‑by‑Step Guide to StopCoding

This article walks developers through creating the StopCoding IntelliJ IDEA plugin—a Java‑based extension that reminds you to rest, drink water, and pause coding—covering IDE fundamentals, Gradle project setup, plugin.xml configuration, action implementation, UI dialogs, and usage instructions.

JD Cloud Developers
JD Cloud Developers
JD Cloud Developers
Build a Health‑Boosting IntelliJ IDEA Plugin: Step‑by‑Step Guide to StopCoding

Why Prevent Coding Addiction?

After years of coding without breaks, the author realized that a healthy body is essential for sustainable development work and shares personal motivation for building a tool to remind developers to rest.

StopCoding IDEA Plugin Overview

The StopCoding plugin automatically pauses coding sessions, shows reminder dialogs, and forces a break when configured work and rest intervals are reached.

IntelliJ IDEA and Platform

IntelliJ IDEA (also called IDEA) is a Java development IDE from JetBrains that supports many languages and frameworks. The IntelliJ Platform is an open‑source foundation for building IDEs such as IDEA, WebStorm, DataGrip, and Android Studio, and IDEA plugins are built on this platform.

Development Environment Setup

Use IntelliJ IDEA (Community edition recommended for plugin development) and choose either Gradle or DevKit as the build system. Gradle requires minimal local configuration, while DevKit leverages the built‑in IntelliJ SDK.

Creating a Gradle Project

<code>my_gradle_plugin
├── build.gradle
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
    ├── main
    │   ├── java
    │   └── resources
    │       └── META-INF
    │           └── plugin.xml
    └── test
        ├── java
        └── resources</code>

Root build.gradle Configuration

<code>plugins {
    id 'java'
    id 'org.jetbrains.intellij' version '0.6.5'
}

group 'com.your.company'
version '1.0'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testImplementation group: 'junit', name: 'junit', version: '4.12'
}

intellij {
    version '2020.1'
}

patchPluginXml {
    changeNotes """Add change notes here.<br/><em>most HTML tags may be used</em>"""
}</code>

Running the Plugin (Gradle)

Execute the Gradle run task; the plugin launches in a sandboxed IDEA instance.

DevKit Development Mode

Enable the Plugin DevKit via Settings | Plugins, then configure the IntelliJ Platform Plugin SDK: add a JDK, set the IDEA home path, and select the SDK for the project.

Defining an Action

<code>public class PopupDialogAction extends AnAction {
    @Override
    public void actionPerformed(@NotNull AnActionEvent event) {
        Project currentProject = event.getProject();
        StringBuffer dlgMsg = new StringBuffer(event.getPresentation().getText() + " Selected!");
        String dlgTitle = event.getPresentation().getDescription();
        Navigatable nav = event.getData(CommonDataKeys.NAVIGATABLE);
        if (nav != null) {
            dlgMsg.append(String.format("\nSelected Element: %s", nav.toString()));
        }
        Messages.showMessageDialog(currentProject, dlgMsg.toString(), dlgTitle, Messages.getInformationIcon());
    }
}</code>

Registering the Action in plugin.xml

<code>&lt;idea-plugin&gt;
    &lt;id&gt;icu.jogeen.StopCoding.id&lt;/id&gt;
    &lt;name&gt;StopCoding&lt;/name&gt;
    &lt;version&gt;1.2.1&lt;/version&gt;
    &lt;vendor email="[email protected]" url="https://github.com/jogeen/StopCoding"&gt;jogeen&lt;/vendor&gt;
    &lt;description&gt;<![CDATA[
        <p>This is a work timer. It can set working periods to remind you to rest, drink water, and exercise.</p>
        <ol>
            <li>Open StopCoding from the Tools menu.</li>
            <li>Set working and rest times, then save.</li>
            <li>When the time is up, a pop‑up blocks IDE interaction until you rest.</li>
        </ol>
    ]]&gt;&lt;/description&gt;
    &lt;idea-version since-build="173.0"/&gt;
    &lt;depends&gt;com.intellij.modules.lang&lt;/depends&gt;
    &lt;actions&gt;
        &lt;action id="StopCoding_setting_id" class="icu.jogeen.stopcoding.StopCodingSettingAction" text="StopCoding" description="setting"&gt;
            &lt;add-to-group group-id="ToolsMenu" anchor="first"/&gt;
            &lt;keyboard-shortcut keymap="$default" first-keystroke="ctrl S" second-keystroke="C"/&gt;
        &lt;/action&gt;
    &lt;/actions&gt;
&lt;/idea-plugin&gt;</code>

Plugin UI Dialogs

<code>public class StopCodingSettingAction extends AnAction {
    @Override
    public void actionPerformed(AnActionEvent e) {
        SettingDialog settingDialog = new SettingDialog();
        settingDialog.setVisible(true);
    }
}

// SettingDialog (Swing) binds OK/Cancel buttons, schedule/cancel tasks, and updates UI state.
</code>

Project Structure Overview

<code>.
├── image
│   ├── step1.png
│   ├── step2.png
│   ├── step3.png
│   └── step.gif
├── LICENSE
├── readme.md
├── readme_ZH.md
├── resources
│   └── img
│       └── stop.png
│   └── META-INF
│       ├── pluginIcon_dark.svg
│       ├── pluginIcon.svg
│       └── plugin.xml
├── src
│   └── icu
│       └── jogeen
│           └── stopcoding
│               ├── data
│               │   ├── DataCenter.java
│               │   └── SettingData.java
│               ├── service
│               │   └── TimerService.java
│               ├── task
│               │   ├── RestTask.java
│               │   └── WorkTask.java
│               └── ui
│                   ├── SettingDialog.form
│                   ├── SettingDialog.java
│                   ├── TipsDialog.form
│                   └── TipsDialog.java
└── StopCoding.iml</code>

Usage Instructions

Install the plugin from the JetBrains Marketplace, open Tools → StopCoding , configure work and break intervals, and start coding. When the timer expires, a non‑dismissable dialog forces a short break; after sufficient rest the dialog closes automatically.

Conclusion

By following this guide, developers can create a simple yet effective IDEA plugin that promotes healthier coding habits, demonstrating that software engineers should balance code logic with physical well‑being.

javaGradleIntelliJ IDEAplugin developmentIDE extensions
JD Cloud Developers
Written by

JD Cloud Developers

JD Cloud Developers (Developer of JD Technology) is a JD Technology Group platform offering technical sharing and communication for AI, cloud computing, IoT and related developers. It publishes JD product technical information, industry content, and tech event news. Embrace technology and partner with developers to envision the future.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.