Blame · Line-by-line history
GluecronPlugin.kt
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 0377886 | 1 | package com.gluecron |
| 2 | ||
| 3 | import com.gluecron.settings.GluecronSettingsState | |
| 4 | import com.intellij.notification.NotificationGroupManager | |
| 5 | import com.intellij.notification.NotificationType | |
| 6 | import com.intellij.openapi.project.Project | |
| 7 | import com.intellij.openapi.startup.StartupActivity | |
| 8 | ||
| 9 | /** | |
| 10 | * Post-startup activity for the Gluecron plugin. | |
| 11 | * | |
| 12 | * Runs once per project open, after the IDE has fully initialized. | |
| 13 | * Responsibilities: | |
| 14 | * 1. Seed settings from environment variables if not already configured | |
| 15 | * (GLUECRON_HOST → host, GLUECRON_TOKEN → token). | |
| 16 | * 2. Emit a notification if the host is still at the default localhost | |
| 17 | * value so new users know to configure the plugin. | |
| 18 | */ | |
| 19 | class GluecronPlugin : StartupActivity { | |
| 20 | ||
| 21 | override fun runActivity(project: Project) { | |
| 22 | val settings = GluecronSettingsState.getInstance() | |
| 23 | ||
| 24 | // Seed from environment variables on first run | |
| 25 | val envHost = System.getenv("GLUECRON_HOST") | |
| 26 | if (!envHost.isNullOrBlank() && settings.host == "http://localhost:3000") { | |
| 27 | settings.host = envHost | |
| 28 | } | |
| 29 | ||
| 30 | val envToken = System.getenv("GLUECRON_TOKEN") | |
| 31 | if (!envToken.isNullOrBlank() && settings.token.isBlank()) { | |
| 32 | settings.token = envToken | |
| 33 | } | |
| 34 | ||
| 35 | // Warn if still using the default localhost address | |
| 36 | if (settings.host == "http://localhost:3000" && settings.token.isBlank()) { | |
| 37 | NotificationGroupManager.getInstance() | |
| 38 | .getNotificationGroup("Gluecron Notifications") | |
| 39 | .createNotification( | |
| 40 | "Gluecron", | |
| 41 | "Configure your Gluecron server URL and access token in " + | |
| 42 | "<b>Settings → Tools → Gluecron</b>.", | |
| 43 | NotificationType.INFORMATION | |
| 44 | ) | |
| 45 | .notify(project) | |
| 46 | } | |
| 47 | } | |
| 48 | } |