From 1e17dbdd488fbedd9adb623c9ce6258891f10c0e Mon Sep 17 00:00:00 2001 From: eparovyshnaya Date: Mon, 28 Nov 2022 21:07:41 +0300 Subject: [PATCH] last page of a license issuing wizard is always empty #1148 fill personal license issuing wizard's info page --- .../restrictions/ExaminationExplained.java | 2 +- .../META-INF/MANIFEST.MF | 1 + .../licenses/model/i18n/Messages.java | 34 +++++++++++++ .../licenses/model/i18n/messages.properties | 28 ++++++++++ .../licenses/model/described/Described.java | 23 +++++++++ .../DescribedAuthenticationInstructions.java | 36 +++++++++++++ .../model/described/DescribedDate.java | 34 +++++++++++++ .../described/DescribedLicenseRequisites.java | 51 +++++++++++++++++++ .../DescribedPersonalFeatureGrant.java | 48 +++++++++++++++++ .../DescribedPersonalFeatureGrants.java | 38 ++++++++++++++ .../described/DescribedPersonalLicense.java | 35 +++++++++++++ .../described/DescribedValidityPeriod.java | 36 +++++++++++++ .../DescribedValidityPeriodClosed.java | 47 +++++++++++++++++ .../ui/wizards/IssueLicenseDetailsPage.java | 23 +++++++-- .../ui/wizards/IssueLicensePackPage.java | 6 +-- .../ui/wizards/IssueLicenseWizard.java | 6 +-- .../ui/wizards/TwoPhaseWizardPage.java | 30 +++++++++++ 17 files changed, 466 insertions(+), 12 deletions(-) create mode 100644 bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/model/i18n/Messages.java create mode 100644 bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/model/i18n/messages.properties create mode 100644 bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/Described.java create mode 100644 bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedAuthenticationInstructions.java create mode 100644 bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedDate.java create mode 100644 bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedLicenseRequisites.java create mode 100644 bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedPersonalFeatureGrant.java create mode 100644 bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedPersonalFeatureGrants.java create mode 100644 bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedPersonalLicense.java create mode 100644 bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedValidityPeriod.java create mode 100644 bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedValidityPeriodClosed.java create mode 100644 bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/TwoPhaseWizardPage.java diff --git a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/restrictions/ExaminationExplained.java b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/restrictions/ExaminationExplained.java index a077e787b..bab437cf6 100644 --- a/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/restrictions/ExaminationExplained.java +++ b/bundles/org.eclipse.passage.lic.base/src/org/eclipse/passage/lic/base/restrictions/ExaminationExplained.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2020, 2021 ArSysOp + * Copyright (c) 2020, 2022 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at diff --git a/bundles/org.eclipse.passage.lic.licenses.model/META-INF/MANIFEST.MF b/bundles/org.eclipse.passage.lic.licenses.model/META-INF/MANIFEST.MF index bdc3e2b7c..09fbb3c93 100644 --- a/bundles/org.eclipse.passage.lic.licenses.model/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.passage.lic.licenses.model/META-INF/MANIFEST.MF @@ -18,6 +18,7 @@ Export-Package: org.eclipse.passage.lic.internal.licenses.convert;x-friends:="or org.eclipse.passage.lic.internal.licenses.model;x-friends:="org.eclipse.passage.lic.licenses.migration,org.eclipse.passage.loc.dashboard.ui,org.eclipse.passage.loc.licenses.core", org.eclipse.passage.lic.internal.licenses.model.signature, org.eclipse.passage.lic.licenses.model.api, + org.eclipse.passage.lic.licenses.model.described;x-internal:=true, org.eclipse.passage.lic.licenses.model.impl;x-internal:=true, org.eclipse.passage.lic.licenses.model.meta, org.eclipse.passage.lic.licenses.model.transport, diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/model/i18n/Messages.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/model/i18n/Messages.java new file mode 100644 index 000000000..9841172eb --- /dev/null +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/model/i18n/Messages.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2022 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.lic.internal.licenses.model.i18n; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + + private static final String BUNDLE_NAME = Messages.class.getPackage().getName() + ".messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/model/i18n/messages.properties b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/model/i18n/messages.properties new file mode 100644 index 000000000..eb0261104 --- /dev/null +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/internal/licenses/model/i18n/messages.properties @@ -0,0 +1,28 @@ +############################################################################### +# Copyright (c) 2022 ArSysOp and others +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License 2.0 which is available at +# https://www.eclipse.org/legal/epl-2.0/. +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# ArSysOp - initial API and implementation +############################################################################### + +DescribedAuthenticationInstructions_environment=Authenticated by +DescribedAuthenticationInstructions_expression=with expression +DescribedLicenseRequisites_identifier=Identifier: +DescribedLicenseRequisites_issued=Issued: +DescribedLicenseRequisites_plan=Under licensing plan +DescribedLicenseRequisites_product=Product +DescribedLicenseRequisites_requisites=General requisites +DescribedLicenseRequisites_version=\ version +DescribedLicenseRequisites_agreements=\ agreements +DescribedPersonalFeatureGrant_capacity=Capacity: +DescribedPersonalFeatureGrant_feature=Grant for feature +DescribedPersonalFeatureGrant_version=version +DescribedPersonalFeatureGrant_rule = \ matching with rule +DescribedPersonalFeatureGrants_grants=\ grants +DescribedValidityPeriodClosed.template=Valid from %s until %s diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/Described.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/Described.java new file mode 100644 index 000000000..7b9caaeb4 --- /dev/null +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/Described.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2022 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.lic.licenses.model.described; + +import java.util.function.Supplier; + +abstract class Described implements Supplier { + + protected final String nl = "\r\n"; //$NON-NLS-1$ + protected final String tab = "\t"; //$NON-NLS-1$ + protected final String tabs = "\t\t"; //$NON-NLS-1$ + +} diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedAuthenticationInstructions.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedAuthenticationInstructions.java new file mode 100644 index 000000000..b2a06e65b --- /dev/null +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedAuthenticationInstructions.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2022 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.lic.licenses.model.described; + +import org.eclipse.passage.lic.internal.licenses.model.i18n.Messages; +import org.eclipse.passage.lic.licenses.EvaluationInstructionsDescriptor; + +public final class DescribedAuthenticationInstructions extends Described { + + private final EvaluationInstructionsDescriptor auth; + + public DescribedAuthenticationInstructions(EvaluationInstructionsDescriptor auth) { + this.auth = auth; + } + + @Override + public String get() { + StringBuilder out = new StringBuilder(); + out.append(tabs).append(Messages.getString("DescribedAuthenticationInstructions_environment")) //$NON-NLS-1$ + .append(auth.getType()).append(nl)// + .append(tabs).append(tabs).append(Messages.getString("DescribedAuthenticationInstructions_expression")) //$NON-NLS-1$ + .append(auth.getExpression()).append(nl); + return out.toString(); + } + +} diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedDate.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedDate.java new file mode 100644 index 000000000..040339261 --- /dev/null +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedDate.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2022 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.lic.licenses.model.described; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.function.Supplier; + +public final class DescribedDate implements Supplier { + + private final SimpleDateFormat format = new SimpleDateFormat("dd.MM.YYYY z"); //$NON-NLS-1$ + + private final Date date; + + public DescribedDate(Date date) { + this.date = date; + } + + @Override + public String get() { + return format.format(date); + } + +} diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedLicenseRequisites.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedLicenseRequisites.java new file mode 100644 index 000000000..314335b3e --- /dev/null +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedLicenseRequisites.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2022 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.lic.licenses.model.described; + +import org.eclipse.passage.lic.internal.licenses.model.i18n.Messages; +import org.eclipse.passage.lic.licenses.LicenseRequisitesDescriptor; + +public final class DescribedLicenseRequisites extends Described { + + private final LicenseRequisitesDescriptor license; + + public DescribedLicenseRequisites(LicenseRequisitesDescriptor license) { + this.license = license; + } + + @Override + public String get() { + StringBuilder out = new StringBuilder(); + out.append(Messages.getString("DescribedLicenseRequisites_requisites")).append(nl)// //$NON-NLS-1$ + .append(tab).append(Messages.getString("DescribedLicenseRequisites_product")) //$NON-NLS-1$ + .append(license.getProduct().getIdentifier())// + .append(Messages.getString("DescribedLicenseRequisites_version")) //$NON-NLS-1$ + .append(license.getProduct().getVersion()).append(nl)// + + .append(tab).append(Messages.getString("DescribedLicenseRequisites_identifier")) //$NON-NLS-1$ + .append(license.getIdentifier()).append(nl)// + + .append(tab).append(new DescribedValidityPeriod(license.getValid()).get()).append(nl) // + + .append(tab).append(Messages.getString("DescribedLicenseRequisites_issued")) //$NON-NLS-1$ + .append(new DescribedDate(license.getIssueDate()).get()).append(nl)// + + .append(tab).append(Messages.getString("DescribedLicenseRequisites_plan")).append(license.getPlan()) //$NON-NLS-1$ + .append(nl)// + + .append(tab).append(license.getAgreements().size()) + .append(Messages.getString("DescribedLicenseRequisites_agreements")).append(nl); //$NON-NLS-1$ + return out.toString(); + } + +} diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedPersonalFeatureGrant.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedPersonalFeatureGrant.java new file mode 100644 index 000000000..2d9e97cd2 --- /dev/null +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedPersonalFeatureGrant.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2022 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.lic.licenses.model.described; + +import org.eclipse.passage.lic.internal.licenses.model.i18n.Messages; +import org.eclipse.passage.lic.licenses.PersonalFeatureGrantDescriptor; + +public final class DescribedPersonalFeatureGrant extends Described { + + private PersonalFeatureGrantDescriptor grant; + + public DescribedPersonalFeatureGrant(PersonalFeatureGrantDescriptor grant) { + this.grant = grant; + } + + @Override + public String get() { + StringBuilder out = new StringBuilder(); + out.append(tab).append(Messages.getString("DescribedPersonalFeatureGrant_feature")) // //$NON-NLS-1$ + .append(grant.getFeature().getIdentifier()).append(nl)// + + .append(tabs).append(Messages.getString("DescribedPersonalFeatureGrant_version")) // //$NON-NLS-1$ + .append(grant.getFeature().getVersionMatch().getVersion())// + .append(Messages.getString("DescribedPersonalFeatureGrant_rule")) // //$NON-NLS-1$ + .append(grant.getFeature().getVersionMatch().getRule())// + .append(nl)// + + .append(tabs).append(new DescribedValidityPeriod(grant.getValid()).get()).append(nl)// + + .append(tabs).append(Messages.getString("DescribedPersonalFeatureGrant_capacity"))// //$NON-NLS-1$ + .append(grant.getCapacity()).append(nl)// + + .append(tabs).append(new DescribedAuthenticationInstructions(grant.getUserAuthentication()).get()) + .append(nl); + return out.toString(); + } + +} diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedPersonalFeatureGrants.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedPersonalFeatureGrants.java new file mode 100644 index 000000000..acd072b14 --- /dev/null +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedPersonalFeatureGrants.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2022 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.lic.licenses.model.described; + +import java.util.List; + +import org.eclipse.passage.lic.internal.licenses.model.i18n.Messages; +import org.eclipse.passage.lic.licenses.PersonalFeatureGrantDescriptor; + +public final class DescribedPersonalFeatureGrants extends Described { + + private final List grants; + + public DescribedPersonalFeatureGrants(List grants) { + this.grants = grants; + } + + @Override + public String get() { + StringBuilder out = new StringBuilder(); + out.append(grants.size()).append(Messages.getString("DescribedPersonalFeatureGrants_grants")).append(nl); //$NON-NLS-1$ + for (PersonalFeatureGrantDescriptor grant : grants) { + out.append(new DescribedPersonalFeatureGrant(grant).get()); + } + return out.toString(); + } + +} diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedPersonalLicense.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedPersonalLicense.java new file mode 100644 index 000000000..9c944112c --- /dev/null +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedPersonalLicense.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2022 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.lic.licenses.model.described; + +import java.util.function.Supplier; + +import org.eclipse.passage.lic.licenses.PersonalLicensePackDescriptor; + +public final class DescribedPersonalLicense implements Supplier { + + private final PersonalLicensePackDescriptor pack; + + public DescribedPersonalLicense(PersonalLicensePackDescriptor license) { + this.pack = license; + } + + @Override + public String get() { + StringBuilder out = new StringBuilder(); + out.append(new DescribedLicenseRequisites(pack.getLicense()).get()); + out.append(new DescribedPersonalFeatureGrants(pack.getGrants()).get()); + return out.toString(); + } + +} diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedValidityPeriod.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedValidityPeriod.java new file mode 100644 index 000000000..fa1fff250 --- /dev/null +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedValidityPeriod.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2022 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.lic.licenses.model.described; + +import java.util.function.Supplier; + +import org.eclipse.passage.lic.licenses.ValidityPeriodClosedDescriptor; +import org.eclipse.passage.lic.licenses.ValidityPeriodDescriptor; + +public final class DescribedValidityPeriod implements Supplier { + + private final ValidityPeriodDescriptor valid; + + public DescribedValidityPeriod(ValidityPeriodDescriptor valid) { + this.valid = valid; + } + + @Override + public String get() { + if (valid instanceof ValidityPeriodClosedDescriptor) { + return new DescribedValidityPeriodClosed(valid).get(); + } + throw new UnsupportedOperationException("Type of validity period is not supported"); //$NON-NLS-1$ + } + +} diff --git a/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedValidityPeriodClosed.java b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedValidityPeriodClosed.java new file mode 100644 index 000000000..46c132662 --- /dev/null +++ b/bundles/org.eclipse.passage.lic.licenses.model/src/org/eclipse/passage/lic/licenses/model/described/DescribedValidityPeriodClosed.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2022 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.lic.licenses.model.described; + +import java.util.Date; +import java.util.function.Supplier; + +import org.eclipse.passage.lic.internal.licenses.model.i18n.Messages; +import org.eclipse.passage.lic.licenses.ValidityPeriodClosedDescriptor; +import org.eclipse.passage.lic.licenses.ValidityPeriodDescriptor; + +public final class DescribedValidityPeriodClosed implements Supplier { + + private final ValidityPeriodClosedDescriptor valid; + + public DescribedValidityPeriodClosed(ValidityPeriodClosedDescriptor valid) { + this.valid = valid; + } + + public DescribedValidityPeriodClosed(ValidityPeriodDescriptor valid) { + this((ValidityPeriodClosedDescriptor) valid); + } + + @Override + public String get() { + return String.format(// + Messages.getString("DescribedValidityPeriodClosed.template"), //$NON-NLS-1$ + date(valid.getFrom()), // + date(valid.getUntil())// + ); + } + + private String date(Date date) { + return new DescribedDate(date).get(); + } + +} diff --git a/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/IssueLicenseDetailsPage.java b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/IssueLicenseDetailsPage.java index 84517e1ca..5a58ac297 100644 --- a/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/IssueLicenseDetailsPage.java +++ b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/IssueLicenseDetailsPage.java @@ -12,9 +12,12 @@ *******************************************************************************/ package org.eclipse.passage.loc.dashboard.ui.wizards; +import java.util.function.Supplier; + import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.layout.GridDataFactory; -import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.passage.lic.licenses.PersonalLicensePackDescriptor; +import org.eclipse.passage.lic.licenses.model.described.DescribedPersonalLicense; import org.eclipse.passage.loc.internal.dashboard.ui.i18n.IssueLicensePageMessages; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -22,24 +25,34 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; -//TODO: looks empty, fill or kill -public final class IssueLicenseDetailsPage extends WizardPage { +@SuppressWarnings("restriction") +public final class IssueLicenseDetailsPage extends TwoPhaseWizardPage { + + private final Supplier pack; + private Text info; - protected IssueLicenseDetailsPage(String name) { + protected IssueLicenseDetailsPage(String name, Supplier pack) { super(name); + this.pack = pack; setTitle(IssueLicensePageMessages.IssueLicenseDetailsPage_page_title); setDescription(IssueLicensePageMessages.IssueLicenseDetailsPage_page_description); } + // TODO: into to Tab; + one Tab for each agreement @Override public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); composite.setLayout(new GridLayout()); - Text info = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.WRAP); + this.info = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.WRAP); info.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); setControl(composite); Dialog.applyDialogFont(composite); } + @Override + void init() { + info.setText(new DescribedPersonalLicense(pack.get()).get()); + } + } diff --git a/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/IssueLicensePackPage.java b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/IssueLicensePackPage.java index d6b141d66..e6f5ab5f4 100644 --- a/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/IssueLicensePackPage.java +++ b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/IssueLicensePackPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2021 ArSysOp + * Copyright (c) 2019, 2022 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -27,7 +27,6 @@ import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; -import org.eclipse.jface.wizard.WizardPage; import org.eclipse.passage.lic.emf.validation.ErrorMessages; import org.eclipse.passage.lic.licenses.PersonalLicensePackDescriptor; import org.eclipse.passage.lic.licenses.model.api.PersonalFeatureGrant; @@ -42,7 +41,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -class IssueLicensePackPage extends WizardPage { +class IssueLicensePackPage extends TwoPhaseWizardPage { private final IEclipseContext context; private final Supplier data; @@ -60,6 +59,7 @@ protected IssueLicensePackPage(String name, Supplier dat setDescription(IssueLicensePageMessages.IssueLicensePackPage_page_description); } + @Override void init() { PersonalLicenseRequest request = data.get(); if (license != null) { diff --git a/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/IssueLicenseWizard.java b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/IssueLicenseWizard.java index 8206662a4..fb84be825 100644 --- a/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/IssueLicenseWizard.java +++ b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/IssueLicenseWizard.java @@ -48,15 +48,15 @@ public void addPages() { addPage(request.get()); pack = new IssueLicensePackPage(IssueLicensePackPage.class.getName(), request::request, context); addPage(pack); - info = new IssueLicenseDetailsPage(IssueLicenseDetailsPage.class.getName()); + info = new IssueLicenseDetailsPage(IssueLicenseDetailsPage.class.getName(), pack::pack); addPage(info); } @Override public IWizardPage getNextPage(IWizardPage page) { IWizardPage next = super.getNextPage(page); - if (pack.equals(next)) { - pack.init(); + if (next instanceof TwoPhaseWizardPage) { + ((TwoPhaseWizardPage) next).init(); } return next; } diff --git a/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/TwoPhaseWizardPage.java b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/TwoPhaseWizardPage.java new file mode 100644 index 000000000..57c0e7ddd --- /dev/null +++ b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/TwoPhaseWizardPage.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2022 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.passage.loc.dashboard.ui.wizards; + +import org.eclipse.jface.wizard.WizardPage; + +/** + * Except for the control construction phase, that WizardPage protocol demands, + * this type of pages has initialization phase, where actual data can be read + * and reflected in controls. + */ +abstract class TwoPhaseWizardPage extends WizardPage { + + protected TwoPhaseWizardPage(String name) { + super(name); + } + + abstract void init(); + +}