Skip to content

Commit

Permalink
Merge pull request #727 from eclipse-passage/571526
Browse files Browse the repository at this point in the history
Bug 571526 open license folder after issuing
  • Loading branch information
eparovyshnaya authored Apr 10, 2021
2 parents b4c5cc4 + 5fc55b3 commit 1e3949e
Show file tree
Hide file tree
Showing 3 changed files with 71 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,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());
}
}

}
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 1e3949e

Please sign in to comment.