Perform auto-check initial and checks after switching channels (KT-23980)
#KT-23980 Fixed
This commit is contained in:
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.idea.PluginUpdateStatus
|
|||||||
import org.jetbrains.kotlin.idea.configuration.ui.ConfigurePluginUpdatesForm
|
import org.jetbrains.kotlin.idea.configuration.ui.ConfigurePluginUpdatesForm
|
||||||
import javax.swing.JComponent
|
import javax.swing.JComponent
|
||||||
|
|
||||||
class KotlinUpdatesSettingsConfigurable() : SearchableConfigurable, Configurable.NoScroll {
|
class KotlinUpdatesSettingsConfigurable : SearchableConfigurable, Configurable.NoScroll {
|
||||||
companion object {
|
companion object {
|
||||||
const val ID = "preferences.language.Kotlin"
|
const val ID = "preferences.language.Kotlin"
|
||||||
|
|
||||||
@@ -43,46 +43,22 @@ class KotlinUpdatesSettingsConfigurable() : SearchableConfigurable, Configurable
|
|||||||
private val form = ConfigurePluginUpdatesForm()
|
private val form = ConfigurePluginUpdatesForm()
|
||||||
private var update: PluginUpdateStatus.Update? = null
|
private var update: PluginUpdateStatus.Update? = null
|
||||||
|
|
||||||
private var savedChannel: Int = EAPChannels.EAP_1_3.indexIfAvailable() ?: EAPChannels.EAP_1_2.indexIfAvailable() ?: 0
|
|
||||||
|
|
||||||
override fun getId(): String = ID
|
override fun getId(): String = ID
|
||||||
|
|
||||||
override fun getDisplayName(): String = "Kotlin Updates"
|
override fun getDisplayName(): String = "Kotlin Updates"
|
||||||
|
|
||||||
override fun isModified(): Boolean {
|
override fun isModified() = false
|
||||||
return savedChannel != form.channelCombo.selectedIndex
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun apply() {
|
override fun apply() {
|
||||||
saveSettings()
|
// Selected channel is now saved automatically
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createComponent(): JComponent? {
|
override fun createComponent(): JComponent? {
|
||||||
form.updateCheckProgressIcon.suspend()
|
form.updateCheckProgressIcon.suspend()
|
||||||
form.updateCheckProgressIcon.setPaintPassiveIcon(false)
|
form.updateCheckProgressIcon.setPaintPassiveIcon(false)
|
||||||
|
|
||||||
form.checkForUpdatesNowButton.addActionListener {
|
form.reCheckButton.addActionListener {
|
||||||
saveSettings()
|
checkForUpdates()
|
||||||
form.updateCheckProgressIcon.resume()
|
|
||||||
form.resetUpdateStatus()
|
|
||||||
KotlinPluginUpdater.getInstance().runUpdateCheck{ pluginUpdateStatus ->
|
|
||||||
form.updateCheckProgressIcon.suspend()
|
|
||||||
when (pluginUpdateStatus) {
|
|
||||||
PluginUpdateStatus.LatestVersionInstalled ->
|
|
||||||
form.updateStatusLabel.text = "You have the latest version of the plugin (${KotlinPluginUtil.getPluginVersion()}) installed."
|
|
||||||
|
|
||||||
is PluginUpdateStatus.Update -> {
|
|
||||||
update = pluginUpdateStatus
|
|
||||||
form.installButton.isVisible = true
|
|
||||||
form.updateStatusLabel.text = "A new version ${pluginUpdateStatus.pluginDescriptor.version} is available"
|
|
||||||
}
|
|
||||||
|
|
||||||
is PluginUpdateStatus.CheckFailed ->
|
|
||||||
form.updateStatusLabel.text = "Update check failed: ${pluginUpdateStatus.message}"
|
|
||||||
}
|
|
||||||
|
|
||||||
false // do not auto-retry update check
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
form.installButton.isVisible = false
|
form.installButton.isVisible = false
|
||||||
@@ -92,18 +68,50 @@ class KotlinUpdatesSettingsConfigurable() : SearchableConfigurable, Configurable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val savedChannel: Int = EAPChannels.EAP_1_3.indexIfAvailable() ?: EAPChannels.EAP_1_2.indexIfAvailable() ?: 0
|
||||||
|
form.channelCombo.selectedIndex = savedChannel
|
||||||
|
|
||||||
form.channelCombo.addActionListener {
|
form.channelCombo.addActionListener {
|
||||||
form.resetUpdateStatus()
|
checkForUpdates()
|
||||||
}
|
}
|
||||||
|
|
||||||
form.channelCombo.selectedIndex = savedChannel
|
checkForUpdates()
|
||||||
|
|
||||||
return form.mainPanel
|
return form.mainPanel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkForUpdates() {
|
||||||
|
saveSettings()
|
||||||
|
form.updateCheckProgressIcon.resume()
|
||||||
|
form.resetUpdateStatus()
|
||||||
|
KotlinPluginUpdater.getInstance().runUpdateCheck{ pluginUpdateStatus ->
|
||||||
|
// Need this to show something is happening when check is very fast
|
||||||
|
Thread.sleep(30)
|
||||||
|
form.updateCheckProgressIcon.suspend()
|
||||||
|
|
||||||
|
when (pluginUpdateStatus) {
|
||||||
|
PluginUpdateStatus.LatestVersionInstalled -> {
|
||||||
|
form.setUpdateStatus(
|
||||||
|
"You have the latest version of the plugin (${KotlinPluginUtil.getPluginVersion()}) installed.",
|
||||||
|
false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
is PluginUpdateStatus.Update -> {
|
||||||
|
update = pluginUpdateStatus
|
||||||
|
form.setUpdateStatus("A new version ${pluginUpdateStatus.pluginDescriptor.version} is available", true)
|
||||||
|
}
|
||||||
|
|
||||||
|
is PluginUpdateStatus.CheckFailed ->
|
||||||
|
form.setUpdateStatus("Update check failed: ${pluginUpdateStatus.message}", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
false // do not auto-retry update check
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun saveSettings() {
|
private fun saveSettings() {
|
||||||
savedChannel = form.channelCombo.selectedIndex
|
saveSelectedChannel(form.channelCombo.selectedIndex)
|
||||||
saveSelectedChannel(savedChannel)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+45
-38
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.kotlin.idea.configuration.ui.ConfigurePluginUpdatesForm">
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.kotlin.idea.configuration.ui.ConfigurePluginUpdatesForm">
|
||||||
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<xy x="20" y="20" width="500" height="400"/>
|
<xy x="20" y="20" width="500" height="400"/>
|
||||||
@@ -22,41 +22,10 @@
|
|||||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</vspacer>
|
</vspacer>
|
||||||
<component id="ca1a9" class="javax.swing.JComboBox" binding="channelCombo">
|
<grid id="2505b" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<constraints>
|
|
||||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<model>
|
|
||||||
<item value="Stable"/>
|
|
||||||
<item value="Early Access Preview 1.2.x"/>
|
|
||||||
<item value="Early Access Preview 1.3"/>
|
|
||||||
</model>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<grid id="b171" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
|
||||||
<constraints>
|
|
||||||
<grid row="1" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
<border type="none"/>
|
|
||||||
<children>
|
|
||||||
<component id="c7546" class="javax.swing.JButton" binding="checkForUpdatesNowButton" default-binding="true">
|
|
||||||
<constraints/>
|
|
||||||
<properties>
|
|
||||||
<text value="Check for updates &now"/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<component id="3b585" class="com.intellij.util.ui.AsyncProcessIcon" binding="updateCheckProgressIcon" custom-create="true">
|
|
||||||
<constraints/>
|
|
||||||
<properties/>
|
|
||||||
</component>
|
|
||||||
</children>
|
|
||||||
</grid>
|
|
||||||
<grid id="2505b" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
@@ -69,17 +38,55 @@
|
|||||||
<text value=" "/>
|
<text value=" "/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
<grid id="b171" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="0">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
<component id="65662" class="javax.swing.JButton" binding="installButton" default-binding="true">
|
<component id="65662" class="javax.swing.JButton" binding="installButton" default-binding="true">
|
||||||
<constraints>
|
<constraints/>
|
||||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
<properties>
|
||||||
<text value="&Install"/>
|
<actionCommand value="Install"/>
|
||||||
|
<label value="Install..."/>
|
||||||
|
<text value="&Install..."/>
|
||||||
<visible value="true"/>
|
<visible value="true"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
|
<grid id="209b0" layout-manager="FlowLayout" hgap="5" vgap="0" flow-align="0">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="ca1a9" class="javax.swing.JComboBox" binding="channelCombo">
|
||||||
|
<constraints/>
|
||||||
|
<properties>
|
||||||
|
<model>
|
||||||
|
<item value="Stable"/>
|
||||||
|
<item value="Early Access Preview 1.2.x"/>
|
||||||
|
<item value="Early Access Preview 1.3"/>
|
||||||
|
</model>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="c7546" class="javax.swing.JButton" binding="reCheckButton">
|
||||||
|
<constraints/>
|
||||||
|
<properties>
|
||||||
|
<text value="&Recheck now"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="3b585" class="com.intellij.util.ui.AsyncProcessIcon" binding="updateCheckProgressIcon" custom-create="true">
|
||||||
|
<constraints/>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import javax.swing.*;
|
|||||||
|
|
||||||
public class ConfigurePluginUpdatesForm {
|
public class ConfigurePluginUpdatesForm {
|
||||||
public JComboBox<String> channelCombo;
|
public JComboBox<String> channelCombo;
|
||||||
public JButton checkForUpdatesNowButton;
|
public JButton reCheckButton;
|
||||||
public JPanel mainPanel;
|
public JPanel mainPanel;
|
||||||
public AsyncProcessIcon updateCheckProgressIcon;
|
public AsyncProcessIcon updateCheckProgressIcon;
|
||||||
public JLabel updateStatusLabel;
|
public JLabel updateStatusLabel;
|
||||||
@@ -37,4 +37,9 @@ public class ConfigurePluginUpdatesForm {
|
|||||||
updateStatusLabel.setText(" ");
|
updateStatusLabel.setText(" ");
|
||||||
installButton.setVisible(false);
|
installButton.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUpdateStatus(String message, boolean showInstallButton) {
|
||||||
|
installButton.setVisible(showInstallButton);
|
||||||
|
updateStatusLabel.setText(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user