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 9151d22c7..0d2aeddc0 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2019, 2020 ArSysOp + * Copyright (c) 2019, 2021 ArSysOp * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -23,7 +23,6 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.passage.lic.email.Mailing; import org.eclipse.passage.lic.internal.api.ServiceInvocationResult; -import org.eclipse.passage.lic.internal.base.diagnostic.NoErrors; import org.eclipse.passage.lic.internal.base.diagnostic.NoSevereErrors; import org.eclipse.passage.lic.internal.jface.dialogs.licensing.DiagnosticDialog; import org.eclipse.passage.lic.licenses.LicensePackDescriptor; @@ -33,10 +32,8 @@ import org.eclipse.passage.loc.internal.api.OperatorLicenseService; import org.eclipse.passage.loc.internal.dashboard.ui.i18n.IssueLicensePageMessages; import org.eclipse.passage.loc.internal.licenses.core.EmailTemplate; -import org.eclipse.passage.loc.internal.licenses.ui.i18n.LicensesUiMessages; import org.eclipse.passage.loc.users.ui.UsersUi; import org.eclipse.passage.loc.workbench.LocWokbench; -import org.eclipse.swt.SWT; import org.eclipse.swt.program.Program; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; @@ -85,13 +82,7 @@ public boolean performFinish() { return false; } else { new WizardInfoBar(this).wipe(); - int kind = new NoErrors().test(result.diagnostic()) ? MessageDialog.INFORMATION : MessageDialog.WARNING; - MessageDialog.open(kind, getShell(), // - IssueLicensePageMessages.IssueLicenseWizard_ok_licensed_title, - String.format(LicensesUiMessages.LicenseExportHandler_success_description, // - result.data().get().encrypted().toAbsolutePath().toString(), // - result.data().get().decrypted().toAbsolutePath().toString()), - SWT.NONE); + new LicenseIssuedNotification(getShell()).showPersonal(result.data().get()); String mailFrom = info.mailFrom(); if (!mailFrom.isEmpty()) { processingMail(mailFrom, licensePack, result.data().get()); diff --git a/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/LicenseIssuedNotification.java b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/LicenseIssuedNotification.java new file mode 100644 index 000000000..43117a26c --- /dev/null +++ b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/LicenseIssuedNotification.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2021 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 java.nio.file.Path; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.passage.loc.internal.api.IssuedFloatingLicense; +import org.eclipse.passage.loc.internal.api.IssuedLicense; +import org.eclipse.passage.loc.internal.dashboard.ui.i18n.IssueLicensePageMessages; +import org.eclipse.passage.loc.internal.licenses.ui.i18n.LicensesUiMessages; +import org.eclipse.swt.program.Program; +import org.eclipse.swt.widgets.Shell; + +public final class LicenseIssuedNotification { + + private final Shell shell; + + public LicenseIssuedNotification(Shell shell) { + this.shell = shell; + } + + public void showPersonal(IssuedLicense license) { + show(// + IssueLicensePageMessages.IssueLicenseWizard_ok_licensed_title, // + String.format(LicensesUiMessages.LicenseExportHandler_success_description, // + license.encrypted().toAbsolutePath().toString(), // + license.decrypted().toAbsolutePath().toString()), // + license.encrypted().getParent()); + } + + public void showFloating(IssuedFloatingLicense license) { + show(// + IssueLicensePageMessages.IssueFloatingLicenseWizard_success, // + String.format(IssueLicensePageMessages.IssueFloatingLicenseWizard_success_description, + license.residence().toAbsolutePath()), // + license.residence()); + } + + private void show(String title, String description, Path residence) { + MessageDialog dialog = new MessageDialog(// + shell, // + title, // + null, // + description, // + MessageDialog.INFORMATION, // + new String[] { // + "OK", //$NON-NLS-1$ + "Open &Folder" //$NON-NLS-1$ + }, 0); + int result = dialog.open(); + if (result == 1) { + Program.launch(residence.toAbsolutePath().toString()); + } + } + +} diff --git a/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/floating/IssueFloatingLicenseWizard.java b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/floating/IssueFloatingLicenseWizard.java index 2cead03a4..2de2bd6aa 100644 --- a/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/floating/IssueFloatingLicenseWizard.java +++ b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/floating/IssueFloatingLicenseWizard.java @@ -15,16 +15,15 @@ import java.util.function.Supplier; import org.eclipse.e4.core.contexts.IEclipseContext; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.wizard.Wizard; import org.eclipse.passage.lic.internal.api.ServiceInvocationResult; import org.eclipse.passage.lic.internal.base.diagnostic.NoSevereErrors; import org.eclipse.passage.lic.internal.jface.dialogs.licensing.DiagnosticDialog; import org.eclipse.passage.lic.licenses.model.api.FloatingLicensePack; +import org.eclipse.passage.loc.dashboard.ui.wizards.LicenseIssuedNotification; import org.eclipse.passage.loc.dashboard.ui.wizards.license.WizardInfoBar; import org.eclipse.passage.loc.internal.api.IssuedFloatingLicense; import org.eclipse.passage.loc.internal.dashboard.ui.i18n.IssueLicensePageMessages; -import org.eclipse.swt.SWT; public final class IssueFloatingLicenseWizard extends Wizard { @@ -61,17 +60,8 @@ public boolean performFinish() { return false; } new WizardInfoBar(this).wipe(); - reportSuccess(result.data().get()); + new LicenseIssuedNotification(getShell()).showFloating(result.data().get()); return true; } - private void reportSuccess(IssuedFloatingLicense data) { - MessageDialog.open(MessageDialog.INFORMATION, // - getShell(), // - IssueLicensePageMessages.IssueFloatingLicenseWizard_success, - String.format(IssueLicensePageMessages.IssueFloatingLicenseWizard_success_description, - data.residence().toAbsolutePath()), - SWT.NONE); - } - }