new channel dialog

This commit is contained in:
Dmitry Jemerov
2011-03-04 19:35:24 +01:00
parent 164aa994a6
commit 1ccc98cb20
3 changed files with 74 additions and 1 deletions
@@ -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("<html><b>").append(myChannel.getName()).append("</b><br>");
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();
}
}
@@ -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) {
@@ -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<String> getLicenseRestrictionsMessages();
public abstract boolean isEvaluationLicense();
@Nullable
public abstract Boolean isPaidUpgrade(int majorVersion, Date releaseDate);
}