From 4dea1c23fe7fd369a1fc31b727d48ba906e76043 Mon Sep 17 00:00:00 2001 From: Elena Parovyshnaia Date: Fri, 9 Apr 2021 20:17:44 +0300 Subject: [PATCH 1/2] Bug 571526 open license folder after issuing Add 'open folder' to the final notification dialog Signed-off-by: eparovyshnaya --- .../ui/wizards/IssueLicenseWizard.java | 13 +--- .../ui/wizards/LicenseIssuedNotification.java | 72 +++++++++++++++++++ .../floating/IssueFloatingLicenseWizard.java | 14 +--- 3 files changed, 76 insertions(+), 23 deletions(-) create mode 100644 bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/LicenseIssuedNotification.java 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..f6808f5f6 --- /dev/null +++ b/bundles/org.eclipse.passage.loc.dashboard.ui/src/org/eclipse/passage/loc/dashboard/ui/wizards/LicenseIssuedNotification.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * 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.awt.Desktop; +import java.io.IOException; +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.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) { + try { + Desktop.getDesktop().open(residence.toFile()); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + +} 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); - } - } From 5fc55b33c48ee373115d20220232a1a57468d7bc Mon Sep 17 00:00:00 2001 From: Elena Parovyshnaia Date: Fri, 9 Apr 2021 20:38:06 +0300 Subject: [PATCH 2/2] Bug 571526 open license folder after issuing Use eclipse.swt.Program facility instead of java.awt.Desktop to open a folder. Signed-off-by: eparovyshnaya --- .../dashboard/ui/wizards/LicenseIssuedNotification.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) 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 index f6808f5f6..43117a26c 100644 --- 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 @@ -12,8 +12,6 @@ *******************************************************************************/ package org.eclipse.passage.loc.dashboard.ui.wizards; -import java.awt.Desktop; -import java.io.IOException; import java.nio.file.Path; import org.eclipse.jface.dialogs.MessageDialog; @@ -21,6 +19,7 @@ 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 { @@ -61,11 +60,7 @@ private void show(String title, String description, Path residence) { }, 0); int result = dialog.open(); if (result == 1) { - try { - Desktop.getDesktop().open(residence.toFile()); - } catch (IOException e) { - e.printStackTrace(); - } + Program.launch(residence.toAbsolutePath().toString()); } }