Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 571526 open license folder after issuing #727

Merged
merged 2 commits into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
ruspl-afed marked this conversation as resolved.
Show resolved Hide resolved
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);
}

}