mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
refactor LicensingFacade and UltimateVerifier so that they do not reference LicenseManager and delegate directly to it
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -100,26 +100,26 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
|
||||
}
|
||||
|
||||
private static Pair<String, Color> 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);
|
||||
}
|
||||
|
||||
@@ -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<String> 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<String> getLicenseRestrictionsMessages() {
|
||||
return restrictions == null? Collections.emptyList() : Collections.unmodifiableList(restrictions);
|
||||
}
|
||||
|
||||
public abstract List<String> 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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user