Skip to content

Commit

Permalink
Bug 571526 open license folder after issuing
Browse files Browse the repository at this point in the history
Add 'open folder' to the final notification dialog

Signed-off-by: eparovyshnaya <[email protected]>
  • Loading branch information
eparovyshnaya committed Apr 9, 2021
1 parent d61d18a commit 4dea1c2
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
}

}

0 comments on commit 4dea1c2

Please sign in to comment.