diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettings.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettings.java index 0ca13cfa223f..715fb90615ef 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettings.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettings.java @@ -53,6 +53,7 @@ public class UpdateSettings implements PersistentStateComponent, UserUp public long LAST_TIME_CHECKED = 0; public String LAST_BUILD_CHECKED = ""; public String UPDATE_CHANNEL_TYPE = ChannelStatus.RELEASE_CODE; + public boolean SECURE_CONNECTION = false; public static UpdateSettings getInstance() { return ServiceManager.getService(UpdateSettings.class); @@ -128,7 +129,7 @@ public class UpdateSettings implements PersistentStateComponent, UserUp public List getPluginHosts() { List hosts = new ArrayList(myPluginHosts); - final String pluginHosts = System.getProperty("idea.plugin.hosts"); + String pluginHosts = System.getProperty("idea.plugin.hosts"); if (pluginHosts != null) { ContainerUtil.addAll(hosts, pluginHosts.split(";")); } @@ -141,7 +142,6 @@ public class UpdateSettings implements PersistentStateComponent, UserUp public void saveLastCheckedInfo() { LAST_TIME_CHECKED = System.currentTimeMillis(); - ApplicationInfo appInfo = ApplicationInfo.getInstance(); - LAST_BUILD_CHECKED = appInfo.getBuild().asString(); + LAST_BUILD_CHECKED = ApplicationInfo.getInstance().getBuild().asString(); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java index 87a6f52eeb80..ce040eb8543b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateSettingsConfigurable.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -41,28 +41,45 @@ public class UpdateSettingsConfigurable extends BaseConfigurable implements Sear private UpdatesSettingsPanel myUpdatesSettingsPanel; private boolean myCheckNowEnabled = true; - public JComponent createComponent() { - myUpdatesSettingsPanel = new UpdatesSettingsPanel(); - return myUpdatesSettingsPanel.myPanel; - } - - public String getDisplayName() { - return IdeBundle.message("updates.settings.title"); - } - - public String getHelpTopic() { - return "preferences.updates"; - } - public void setCheckNowEnabled(boolean enabled) { myCheckNowEnabled = enabled; } + @Override + public JComponent createComponent() { + myUpdatesSettingsPanel = new UpdatesSettingsPanel(); + myUpdatesSettingsPanel.myCheckNow.setEnabled(myCheckNowEnabled); + return myUpdatesSettingsPanel.myPanel; + } + + @Override + public String getDisplayName() { + return IdeBundle.message("updates.settings.title"); + } + + @NotNull + @Override + public String getHelpTopic() { + return "preferences.updates"; + } + + @NotNull + public String getId() { + return getHelpTopic(); + } + + @Nullable + @Override + public Runnable enableSearch(String option) { + return null; + } + + @Override public void apply() throws ConfigurationException { UpdateSettings settings = UpdateSettings.getInstance(); boolean wasEnabled = settings.CHECK_NEEDED; - settings.CHECK_NEEDED = myUpdatesSettingsPanel.myCbCheckForUpdates.isSelected(); + settings.CHECK_NEEDED = myUpdatesSettingsPanel.myCheckForUpdates.isSelected(); if (wasEnabled != settings.CHECK_NEEDED) { UpdateCheckerComponent checker = ApplicationManager.getApplication().getComponent(UpdateCheckerComponent.class); if (checker != null) { @@ -76,35 +93,42 @@ public class UpdateSettingsConfigurable extends BaseConfigurable implements Sear } settings.UPDATE_CHANNEL_TYPE = myUpdatesSettingsPanel.getSelectedChannelType().getCode(); + settings.SECURE_CONNECTION = myUpdatesSettingsPanel.myUseSecureConnection.isSelected(); } + @Override public void reset() { UpdateSettings settings = UpdateSettings.getInstance(); - myUpdatesSettingsPanel.myCbCheckForUpdates.setSelected(settings.CHECK_NEEDED); + myUpdatesSettingsPanel.myCheckForUpdates.setSelected(settings.CHECK_NEEDED); + myUpdatesSettingsPanel.myUseSecureConnection.setSelected(settings.SECURE_CONNECTION); myUpdatesSettingsPanel.updateLastCheckedLabel(); myUpdatesSettingsPanel.setSelectedChannelType(ChannelStatus.fromCode(settings.UPDATE_CHANNEL_TYPE)); } + @Override public boolean isModified() { if (myUpdatesSettingsPanel == null) return false; UpdateSettings settings = UpdateSettings.getInstance(); - if (settings.CHECK_NEEDED != myUpdatesSettingsPanel.myCbCheckForUpdates.isSelected()) return true; - final JComboBox channelsBox = myUpdatesSettingsPanel.myUpdateChannelsBox; - return (channelsBox.getSelectedItem() != null && !channelsBox.getSelectedItem().equals(ChannelStatus.fromCode(settings.UPDATE_CHANNEL_TYPE))); + if (settings.CHECK_NEEDED != myUpdatesSettingsPanel.myCheckForUpdates.isSelected()) return true; + if (settings.SECURE_CONNECTION != myUpdatesSettingsPanel.myUseSecureConnection.isSelected()) return true; + Object channel = myUpdatesSettingsPanel.myUpdateChannels.getSelectedItem(); + return channel != null && !channel.equals(ChannelStatus.fromCode(settings.UPDATE_CHANNEL_TYPE)); } + @Override public void disposeUIResources() { myUpdatesSettingsPanel = null; } - private class UpdatesSettingsPanel { + private static class UpdatesSettingsPanel { private JPanel myPanel; - private JButton myBtnCheckNow; - private JCheckBox myCbCheckForUpdates; + private JButton myCheckNow; + private JCheckBox myCheckForUpdates; private JLabel myBuildNumber; private JLabel myVersionNumber; private JLabel myLastCheckedDate; - private JComboBox myUpdateChannelsBox; + private JComboBox myUpdateChannels; + private JCheckBox myUseSecureConnection; public UpdatesSettingsPanel() { final ApplicationInfo appInfo = ApplicationInfo.getInstance(); @@ -122,22 +146,23 @@ public class UpdateSettingsConfigurable extends BaseConfigurable implements Sear myVersionNumber.setText(appInfo.getVersionName() + " " + versionNumber); myBuildNumber.setText(appInfo.getBuild().asString()); - myBtnCheckNow.addActionListener(new ActionListener() { + myCheckNow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myBtnCheckNow)); + Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myCheckNow)); UpdateSettings settings = new UpdateSettings(); settings.loadState(UpdateSettings.getInstance().getState()); settings.UPDATE_CHANNEL_TYPE = getSelectedChannelType().getCode(); + settings.SECURE_CONNECTION = myUseSecureConnection.isSelected(); UpdateChecker.updateAndShowResult(project, true, settings); //todo load configured hosts on the fly updateLastCheckedLabel(); } }); - myBtnCheckNow.setEnabled(myCheckNowEnabled); LabelTextReplacingUtil.replaceText(myPanel); - final UpdateSettings settings = UpdateSettings.getInstance(); - myUpdateChannelsBox.setModel(new CollectionComboBoxModel(ChannelStatus.all(), ChannelStatus.fromCode(settings.UPDATE_CHANNEL_TYPE))); + UpdateSettings settings = UpdateSettings.getInstance(); + //noinspection unchecked + myUpdateChannels.setModel(new CollectionComboBoxModel(ChannelStatus.all(), ChannelStatus.fromCode(settings.UPDATE_CHANNEL_TYPE))); } private void updateLastCheckedLabel() { @@ -146,21 +171,11 @@ public class UpdateSettingsConfigurable extends BaseConfigurable implements Sear } public ChannelStatus getSelectedChannelType() { - return (ChannelStatus) myUpdateChannelsBox.getSelectedItem(); + return (ChannelStatus) myUpdateChannels.getSelectedItem(); } public void setSelectedChannelType(ChannelStatus channelType) { - myUpdateChannelsBox.setSelectedItem(channelType != null ? channelType : ChannelStatus.RELEASE); + myUpdateChannels.setSelectedItem(channelType != null ? channelType : ChannelStatus.RELEASE); } } - - @NotNull - public String getId() { - return getHelpTopic(); - } - - @Nullable - public Runnable enableSearch(String option) { - return null; - } } diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesSettingsPanel.form b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesSettingsPanel.form index dd37637ea671..0c6304b5b222 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesSettingsPanel.form +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdatesSettingsPanel.form @@ -8,7 +8,7 @@ - + @@ -16,7 +16,7 @@ - + @@ -25,7 +25,7 @@ - + @@ -33,12 +33,20 @@ - + + + + + + + + + diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index 53aa439998a3..000d578f5077 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -923,6 +923,7 @@ updates.settings.title=Updates updates.last.check.never=Never updates.settings.check.now.button=&Check Now updates.settings.checkbox=Automatically check updates for +updates.settings.secure=Use secure connection updates.settings.build.number=Build number: updates.settings.current.version=Current version: updates.settings.last.check=Last checked: