IDEA-77640 Warn if the current subscription license will not work with the new versio...
authorVassiliy <vassiliy.kudryashov@jetbrains.com>
Mon, 2 Jun 2014 06:45:10 +0000 (10:45 +0400)
committerVassiliy <vassiliy.kudryashov@jetbrains.com>
Mon, 2 Jun 2014 06:45:10 +0000 (10:45 +0400)
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/AbstractUpdateDialog.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/NewChannelDialog.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoPanel.form
platform/platform-impl/src/com/intellij/ui/LicensingFacade.java

index 00804fb8aa0f9d98a9826ed532bcb21a92f41250..9fba509bf356a797d1ec36800f62fc816e8a606b 100644 (file)
@@ -23,6 +23,7 @@ import com.intellij.openapi.options.ShowSettingsUtil;
 import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.ui.ColorUtil;
 import com.intellij.ui.IdeBorderFactory;
+import com.intellij.ui.LicensingFacade;
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -37,6 +38,9 @@ import java.awt.*;
  */
 public abstract class AbstractUpdateDialog extends DialogWrapper {
   private final boolean myEnableLink;
+  protected String myLicenseInfo = null;
+  protected boolean myPaidUpgrade;
+  protected boolean mySubscribtionLicense = false;
 
   public AbstractUpdateDialog(boolean enableLink) {
     super(true);
@@ -76,6 +80,27 @@ public abstract class AbstractUpdateDialog extends DialogWrapper {
     });
   }
 
+  protected void initLicensingInfo(@NotNull UpdateChannel channel, @NotNull BuildInfo build) {
+    LicensingFacade facade = LicensingFacade.getInstance();
+    if (facade != null) {
+      mySubscribtionLicense = facade.isSubscriptionLicense();
+      if (!channel.getLicensing().equals(UpdateChannel.LICENSING_EAP)) {
+        Boolean paidUpgrade = facade.isPaidUpgrade(channel.getMajorVersion(), build.getReleaseDate());
+        if (paidUpgrade == Boolean.TRUE) {
+          myPaidUpgrade = true;
+          myLicenseInfo = IdeBundle.message("updates.channel.key.needed", channel.getEvalDays());
+        }
+        else if (paidUpgrade == Boolean.FALSE) {
+          myLicenseInfo = IdeBundle.message("updates.channel.existing.key");
+        }
+      }
+      else {
+        myLicenseInfo = IdeBundle.message("updates.channel.bundled.key");
+      }
+    }
+  }
+
+
   protected void configureMessageArea(@NotNull JEditorPane area) {
     configureMessageArea(area, IdeBundle.message("updates.configure.label", ShowSettingsUtil.getSettingsMenuName()), null, null);
   }
index 65cdf2826723b35b39f18266504fb153e3cd548a..52b07e6c3922f5f041a4586b1b970ea17cf97c4f 100644 (file)
@@ -32,8 +32,6 @@ import java.util.List;
 class NewChannelDialog extends AbstractUpdateDialog {
   private final UpdateChannel myChannel;
   private final BuildInfo myLatestBuild;
-  private boolean myShowUpgradeButton = false;
-  private String myLicenseInfo = null;
 
   public NewChannelDialog(@NotNull UpdateChannel channel) {
     super(false);
@@ -41,22 +39,7 @@ class NewChannelDialog extends AbstractUpdateDialog {
     myLatestBuild = channel.getLatestBuild();
     assert myLatestBuild != null;
 
-    LicensingFacade facade = LicensingFacade.getInstance();
-    if (facade != null) {
-      if (!myChannel.getLicensing().equals(UpdateChannel.LICENSING_EAP)) {
-        Boolean paidUpgrade = facade.isPaidUpgrade(myChannel.getMajorVersion(), myLatestBuild.getReleaseDate());
-        if (paidUpgrade == Boolean.TRUE) {
-          myShowUpgradeButton = true;
-          myLicenseInfo = IdeBundle.message("updates.channel.key.needed", myChannel.getEvalDays());
-        }
-        else if (paidUpgrade == Boolean.FALSE) {
-          myLicenseInfo = IdeBundle.message("updates.channel.existing.key");
-        }
-      }
-      else {
-        myLicenseInfo = IdeBundle.message("updates.channel.bundled.key");
-      }
-    }
+    initLicensingInfo(myChannel, myLatestBuild);
 
     init();
   }
@@ -71,7 +54,7 @@ class NewChannelDialog extends AbstractUpdateDialog {
   protected Action[] createActions() {
     List<Action> actions = ContainerUtil.newArrayList(getOKAction());
 
-    if (myShowUpgradeButton) {
+    if (myPaidUpgrade) {
       actions.add(new AbstractAction(IdeBundle.message("updates.buy.online.button")) {
         @Override
         public void actionPerformed(ActionEvent e) {
index 4ea707ee08ce5f30a5fffdaf25436e8689c7514e..910c77a8345745e8320f4d1ccbe8c935e90a8212 100644 (file)
@@ -57,6 +57,9 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
     myPatch = myLatestBuild != null ? myLatestBuild.findPatchForCurrentBuild() : null;
     myWriteProtected = myPatch != null && !new File(PathManager.getHomePath()).canWrite();
     getCancelAction().putValue(DEFAULT_ACTION, Boolean.TRUE);
+    if (myLatestBuild != null) {
+      initLicensingInfo(myUpdatedChannel, myLatestBuild);
+    }
     init();
 
     if (incompatiblePlugins != null && !incompatiblePlugins.isEmpty()) {
@@ -184,6 +187,7 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
     private JBLabel myPatchLabel;
     private JBLabel myPatchInfo;
     private JEditorPane myMessageArea;
+    private JEditorPane myLicenseArea;
 
     public UpdateInfoPanel() {
       ApplicationInfo appInfo = ApplicationInfo.getInstance();
@@ -213,6 +217,10 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
       else {
         configureMessageArea(myMessageArea);
       }
+
+      if (mySubscribtionLicense && myLicenseInfo != null) {
+        configureMessageArea(myLicenseArea, myLicenseInfo, myPaidUpgrade ? JBColor.RED : null, null);
+      }
     }
 
     private String formatVersion(String version, String build) {
index 27b7eb2d91dbd4ac4d418dfabbb2922a6fe361c3..2ea89f6a87d3315a91f72b17473d1beadf496ade 100644 (file)
@@ -2,10 +2,12 @@
 <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.openapi.updateSettings.impl.UpdateInfoDialog.UpdateInfoPanel">
   <grid id="27dc6" binding="myPanel" layout-manager="GridBagLayout">
     <constraints>
-      <xy x="20" y="20" width="500" height="140"/>
+      <xy x="20" y="20" width="500" height="172"/>
     </constraints>
     <properties/>
-    <border type="none"/>
+    <border type="empty">
+      <size top="0" left="5" bottom="0" right="5"/>
+    </border>
     <children>
       <component id="f7184" class="javax.swing.JEditorPane" binding="myUpdateMessage">
         <constraints>
         </constraints>
         <properties>
           <contentType value="text/html"/>
+          <margin top="0" left="0" bottom="0" right="0"/>
         </properties>
       </component>
       <grid id="d6625" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
-        <margin top="10" left="5" bottom="10" right="5"/>
+        <margin top="10" left="0" bottom="10" right="0"/>
         <constraints>
           <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
           <gridbag weightx="1.0" weighty="0.0"/>
       </component>
       <vspacer id="c963e">
         <constraints>
-          <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="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
           <gridbag weightx="0.0" weighty="0.0"/>
         </constraints>
       </vspacer>
+      <vspacer id="d89a6">
+        <constraints>
+          <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"/>
+          <gridbag top="5" left="0" bottom="0" right="0" weightx="0.0" weighty="0.0"/>
+        </constraints>
+      </vspacer>
+      <component id="f5ccc" class="javax.swing.JEditorPane" binding="myLicenseArea">
+        <constraints>
+          <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
+            <preferred-size width="150" height="50"/>
+          </grid>
+          <gridbag weightx="0.0" weighty="0.0"/>
+        </constraints>
+        <properties>
+          <contentType value="text/html"/>
+          <editable value="false"/>
+          <opaque value="false"/>
+        </properties>
+      </component>
     </children>
   </grid>
 </form>
index a7ed2c4a9a561da9cba8516367b6848b83e5e65f..9df936acdfbfbef149a5ff5eb4e3679cb8949364 100644 (file)
@@ -34,6 +34,7 @@ public abstract class LicensingFacade {
   public abstract String getLicensedToMessage();
   public abstract List<String> getLicenseRestrictionsMessages();
   public abstract boolean isEvaluationLicense();
+  public abstract boolean isSubscriptionLicense();
 
   @Nullable
   public abstract Boolean isPaidUpgrade(int majorVersion, Date releaseDate);