From 084727c991ea46b0fa5a1e7e9b86c695a1553c10 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 18 Nov 2015 15:26:30 +0100 Subject: [PATCH] action to invoke a manual update check for the Kotlin plugin --- idea/src/META-INF/plugin.xml | 6 +++++ .../kotlin/idea/KotlinPluginUpdater.kt | 15 ++++++++--- .../idea/actions/CheckPluginUpdatesAction.kt | 27 +++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 idea/src/org/jetbrains/kotlin/idea/actions/CheckPluginUpdatesAction.kt diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 03c1dd857ce..33f9bedc22a 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -91,6 +91,12 @@ + + + + diff --git a/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt b/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt index 262dffafb97..4ad402d388e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt +++ b/idea/src/org/jetbrains/kotlin/idea/KotlinPluginUpdater.kt @@ -58,18 +58,18 @@ class KotlinPluginUpdater(val propertiesComponent: PropertiesComponent) : Dispos } } - private fun queueUpdateCheck() { + fun queueUpdateCheck(reportNoUpdates: Boolean = false) { if (ApplicationManager.getApplication().isUnitTestMode) return ApplicationManager.getApplication().assertIsDispatchThread() if (!checkQueued) { checkQueued = true - alarm.addRequest({ updateCheck() }, updateDelay) + alarm.addRequest({ updateCheck(reportNoUpdates) }, updateDelay) updateDelay *= 2 // exponential backoff } } - private fun updateCheck() { + private fun updateCheck(reportNoUpdates: Boolean) { try { var (mainRepoUpdateSuccess, latestVersionInRepository) = getPluginVersionFromMainRepository() var descriptorToInstall: IdeaPluginDescriptor? = null @@ -101,6 +101,15 @@ class KotlinPluginUpdater(val propertiesComponent: PropertiesComponent) : Dispos notifyPluginUpdateAvailable(latestVersionInRepository!!, descriptorToInstall, hostToInstallFrom) } } + else if (reportNoUpdates) { + ApplicationManager.getApplication().invokeLater { + val notification = notificationGroup.createNotification( + "Kotlin", + "You have the latest version of the Kotlin plugin", + NotificationType.INFORMATION, null) + notification.notify(null) + } + } } else { ApplicationManager.getApplication().invokeLater { queueUpdateCheck() } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/CheckPluginUpdatesAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/CheckPluginUpdatesAction.kt new file mode 100644 index 00000000000..0591804a853 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/actions/CheckPluginUpdatesAction.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.actions + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import org.jetbrains.kotlin.idea.KotlinPluginUpdater + +class CheckPluginUpdatesAction : AnAction() { + override fun actionPerformed(e: AnActionEvent) { + KotlinPluginUpdater.getInstance().queueUpdateCheck(true) + } +} \ No newline at end of file