diff --git a/platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java b/platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java index 3d838334573b..469bdf395479 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/AboutPopup.java @@ -169,11 +169,11 @@ public class AboutPopup { myLines.add(new AboutBoxLine("")); - LicensingFacade provider = LicensingFacade.getInstance(); - if (provider != null) { - myLines.add(new AboutBoxLine(provider.getLicensedToMessage(), true)); + LicensingFacade la = LicensingFacade.getInstance(); + if (la != null) { + myLines.add(new AboutBoxLine(la.getLicensedToMessage(), true)); appendLast(); - for (String message : provider.getLicenseRestrictionsMessages()) { + for (String message : la.getLicenseRestrictionsMessages()) { myLines.add(new AboutBoxLine(message)); appendLast(); } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java b/platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java index 139af3024abb..17dd324f3f2e 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/SendFeedbackAction.java @@ -95,7 +95,7 @@ public class SendFeedbackAction extends AnAction implements DumbAware { } private static boolean isEvaluationLicense() { - final LicensingFacade provider = LicensingFacade.getInstance(); - return provider != null && provider.isEvaluationLicense(); + final LicensingFacade la = LicensingFacade.getInstance(); + return la != null && la.isEvaluationLicense(); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java index 5e8c5f1cd7eb..70ac4cdcf4dd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateInfoDialog.java @@ -100,26 +100,26 @@ class UpdateInfoDialog extends AbstractUpdateDialog { } private static Pair initLicensingInfo(UpdateChannel channel, BuildInfo build) { - LicensingFacade facade = LicensingFacade.getInstance(); - if (facade == null) return null; + final LicensingFacade la = LicensingFacade.getInstance(); + if (la == null) return null; if (channel.getLicensing().equals(UpdateChannel.LICENSING_EAP)) { return pair(IdeBundle.message("updates.channel.bundled.key"), null); } Date releaseDate = build.getReleaseDate(); - Boolean applicable = releaseDate == null ? null : facade.isApplicableForProduct(releaseDate); - if (applicable == null) { + if (releaseDate == null) { return null; } - if (applicable == Boolean.FALSE) { + + if (!la.isApplicableForProduct(releaseDate)) { return pair(IdeBundle.message("updates.paid.upgrade", channel.getEvalDays()), JBColor.RED); } - if (facade.isPerpetualForProduct(releaseDate) == Boolean.TRUE) { + if (la.isPerpetualForProduct(releaseDate)) { return pair(IdeBundle.message("updates.fallback.build"), null); } - Date expiration = facade.getLicenseExpirationDate(); + Date expiration = la.getLicenseExpirationDate(); if (expiration != null) { return pair(IdeBundle.message("updates.interim.build", DateFormatUtil.formatAboutDialogDate(expiration)), null); } diff --git a/platform/platform-impl/src/com/intellij/ui/LicensingFacade.java b/platform/platform-impl/src/com/intellij/ui/LicensingFacade.java index c9f4e29f8ed1..3f17fc51b390 100644 --- a/platform/platform-impl/src/com/intellij/ui/LicensingFacade.java +++ b/platform/platform-impl/src/com/intellij/ui/LicensingFacade.java @@ -1,49 +1,51 @@ -/* - * Copyright 2000-2016 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ui; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Collections; import java.util.Date; import java.util.List; -/** - * @author yole - */ -public abstract class LicensingFacade { - public static LicensingFacade ourInstance; +public final class LicensingFacade { + public String licensedTo; + public List restrictions; + public boolean isEvaluation; + public Date expirationDate; + public Date perpetualFallbackDate; + + public volatile static LicensingFacade INSTANCE; @Nullable public static LicensingFacade getInstance() { - return ourInstance; + return INSTANCE; } - public abstract String getLicensedToMessage(); + @Nullable + public String getLicensedToMessage() { + return licensedTo; + } + + @NotNull + public List getLicenseRestrictionsMessages() { + return restrictions == null? Collections.emptyList() : Collections.unmodifiableList(restrictions); + } - public abstract List getLicenseRestrictionsMessages(); + public boolean isEvaluationLicense() { + return isEvaluation; + } - public abstract boolean isEvaluationLicense(); + public boolean isApplicableForProduct(@NotNull Date releaseDate) { + return isPerpetualForProduct(releaseDate) || (expirationDate == null || releaseDate.before(expirationDate)); + } + + public boolean isPerpetualForProduct(@NotNull Date releaseDate) { + return perpetualFallbackDate != null && releaseDate.before(perpetualFallbackDate); + } @Nullable - public abstract Boolean isApplicableForProduct(@NotNull Date productBuildDate); - - @Nullable - public abstract Boolean isPerpetualForProduct(@NotNull Date productBuildDate); - - @Nullable - public abstract Date getLicenseExpirationDate(); + public Date getLicenseExpirationDate() { + return expirationDate; + } } \ No newline at end of file diff --git a/python/ide/src/com/jetbrains/python/ReportProblemAction.java b/python/ide/src/com/jetbrains/python/ReportProblemAction.java index 04868782c256..0314b811dfa3 100644 --- a/python/ide/src/com/jetbrains/python/ReportProblemAction.java +++ b/python/ide/src/com/jetbrains/python/ReportProblemAction.java @@ -50,7 +50,7 @@ public class ReportProblemAction extends AnAction implements DumbAware { } private static boolean isEvaluationLicense() { - final LicensingFacade provider = LicensingFacade.getInstance(); - return provider != null && provider.isEvaluationLicense(); + final LicensingFacade la = LicensingFacade.getInstance(); + return la != null && la.isEvaluationLicense(); } }