diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/NewChannelDialog.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/NewChannelDialog.java new file mode 100644 index 000000000000..0387dd824cb5 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/NewChannelDialog.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2011 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 com.intellij.openapi.updateSettings.impl; + +import com.intellij.openapi.application.ApplicationNamesInfo; +import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.ui.LicensingFacade; + +import javax.swing.*; + +/** + * @author yole + */ +public class NewChannelDialog extends DialogWrapper { + private final UpdateChannel myChannel; + private String myInformationText; + + public NewChannelDialog(UpdateChannel channel) { + super(true); + myChannel = channel; + setTitle("New " + ApplicationNamesInfo.getInstance().getFullProductName() + " Version Available"); + initInfo(); + init(); + } + + @Override + protected JComponent createCenterPanel() { + return new JLabel(myInformationText); + } + + private void initInfo() { + StringBuilder builder = new StringBuilder().append("").append(myChannel.getName()).append("
"); + LicensingFacade facade = LicensingFacade.getInstance(); + if (facade != null) { + if (!myChannel.getLicensing().equals(UpdateChannel.LICENSING_EAP)) { + Boolean paidUpgrade = facade.isPaidUpgrade(myChannel.getMajorVersion(), myChannel.getLatestBuild().getReleaseDate()); + if (paidUpgrade != null) { + if (paidUpgrade) { + builder.append("The new version requires upgrading your license key."); + } + else { + builder.append("The new version can be used with your existing license key."); + } + } + } + else { + builder.append("The new version has an expiration date and does not require a license key."); + } + } + myInformationText = builder.toString(); + } +} diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java index 01f3c1859ff8..d7e63580b51b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java @@ -312,7 +312,11 @@ public final class UpdateChecker { boolean showConfirmation, boolean enableLink, final boolean alwaysShowResults) { - if (checkForUpdateResult.hasNewBuildInSelectedChannel()) { + UpdateChannel channelToPropose = checkForUpdateResult.getChannelToPropose(); + if (channelToPropose != null && channelToPropose.getLatestBuild() != null) { + new NewChannelDialog(channelToPropose).show(); + } + else if (checkForUpdateResult.hasNewBuildInSelectedChannel()) { new UpdateInfoDialog(true, checkForUpdateResult.getUpdatedChannel(), updatedPlugins, enableLink).show(); } else if (updatedPlugins != null || alwaysShowResults) { diff --git a/platform/platform-impl/src/com/intellij/ui/LicensingFacade.java b/platform/platform-impl/src/com/intellij/ui/LicensingFacade.java index 6fd448db9b06..f6364f83506c 100644 --- a/platform/platform-impl/src/com/intellij/ui/LicensingFacade.java +++ b/platform/platform-impl/src/com/intellij/ui/LicensingFacade.java @@ -17,6 +17,7 @@ package com.intellij.ui; import org.jetbrains.annotations.Nullable; +import java.util.Date; import java.util.List; /** @@ -33,4 +34,7 @@ public abstract class LicensingFacade { public abstract String getLicensedToMessage(); public abstract List getLicenseRestrictionsMessages(); public abstract boolean isEvaluationLicense(); + + @Nullable + public abstract Boolean isPaidUpgrade(int majorVersion, Date releaseDate); }