non-modal update dialogs; HTML styling of new channel dialog

This commit is contained in:
Dmitry Jemerov
2011-03-04 19:36:02 +01:00
parent 7a822a4d04
commit 0a4f2f54c7
3 changed files with 29 additions and 6 deletions
@@ -18,7 +18,10 @@ package com.intellij.openapi.updateSettings.impl;
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.ui.BrowserHyperlinkListener;
import com.intellij.ui.LicensingFacade;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import java.awt.event.ActionEvent;
@@ -52,7 +55,7 @@ public class NewChannelDialog extends DialogWrapper {
}
};
if (myShowUpgradeButton) {
Action upgrade = new AbstractAction("Upgrade Online") {
Action upgrade = new AbstractAction("Buy Upgrade Online") {
@Override
public void actionPerformed(ActionEvent e) {
LicensingFacade facade = LicensingFacade.getInstance();
@@ -68,18 +71,26 @@ public class NewChannelDialog extends DialogWrapper {
@Override
protected JComponent createCenterPanel() {
return new JLabel(myInformationText);
JEditorPane pane = new JEditorPane("text/html", myInformationText);
pane.addHyperlinkListener(new BrowserHyperlinkListener());
pane.setEditable(false);
return new JBScrollPane(pane);
}
private void initInfo() {
StringBuilder builder = new StringBuilder().append("<html><b>").append(myChannel.getName()).append("</b><br>");
StringBuilder builder = new StringBuilder().append("<html>");
builder.append("<head>").append(UIUtil.getCssFontDeclaration(UIUtil.getLabelFont())).append("</head><body>");
builder.append("<b>").append(myChannel.getName()).append("</b><br>");
builder.append(myChannel.getLatestBuild().getMessage()).append("<br><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.");
builder.append("You can evaluate the new version for ")
.append(myChannel.getEvalDays())
.append(" days or buy a license key or an upgrade online.");
myShowUpgradeButton = true;
}
else {
@@ -34,6 +34,7 @@ public class UpdateChannel {
private final String myHomePageUrl;
private final String myFeedbackUrl;
private final List<BuildInfo> myBuilds;
private final int myEvalDays;
public static final String LICENSING_EAP = "eap";
public static final String LICENSING_PRODUCTION = "production";
@@ -48,6 +49,9 @@ public class UpdateChannel {
String majorVersion = node.getAttributeValue("majorVersion");
myMajorVersion = majorVersion != null ? Integer.parseInt(majorVersion) : -1;
String evalDays = node.getAttributeValue("evalDays");
myEvalDays = evalDays != null ? Integer.parseInt(evalDays) : 30;
myHomePageUrl = node.getAttributeValue("url");
myFeedbackUrl = node.getAttributeValue("feedback");
@@ -96,4 +100,8 @@ public class UpdateChannel {
public String getLicensing() {
return myLicensing;
}
public int getEvalDays() {
return myEvalDays;
}
}
@@ -314,10 +314,14 @@ public final class UpdateChecker {
final boolean alwaysShowResults) {
UpdateChannel channelToPropose = checkForUpdateResult.getChannelToPropose();
if (channelToPropose != null && channelToPropose.getLatestBuild() != null) {
new NewChannelDialog(channelToPropose).show();
NewChannelDialog dialog = new NewChannelDialog(channelToPropose);
dialog.setModal(alwaysShowResults);
dialog.show();
}
else if (checkForUpdateResult.hasNewBuildInSelectedChannel()) {
new UpdateInfoDialog(true, checkForUpdateResult.getUpdatedChannel(), updatedPlugins, enableLink).show();
UpdateInfoDialog dialog = new UpdateInfoDialog(true, checkForUpdateResult.getUpdatedChannel(), updatedPlugins, enableLink);
dialog.setModal(alwaysShowResults);
dialog.show();
}
else if (updatedPlugins != null || alwaysShowResults) {
NoUpdatesDialog dialog = new NoUpdatesDialog(true, updatedPlugins, enableLink);