Skip to content

Commit

Permalink
Merge pull request #741 from eclipse-passage/572833
Browse files Browse the repository at this point in the history
572833
  • Loading branch information
eparovyshnaya authored Apr 17, 2021
2 parents bda8e2e + f8d9e25 commit af3c9e3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.passage.lic.internal.equinox;

import java.util.Optional;
import java.util.function.Consumer;

import org.eclipse.passage.lic.internal.api.ServiceInvocationResult;
import org.eclipse.passage.lic.internal.api.access.GrantLockAttempt;
Expand All @@ -21,10 +22,18 @@ public abstract class LicensedRunnable implements Runnable {

private final String feature;
private final Runnable action;
private final Consumer<ServiceInvocationResult<GrantLockAttempt>> fallback;

public LicensedRunnable(String feature, Runnable action) {
public LicensedRunnable(String feature, Runnable action,
Consumer<ServiceInvocationResult<GrantLockAttempt>> fallback) {
this.feature = feature;
this.action = action;
this.fallback = fallback;
}

public LicensedRunnable(String feature, Runnable action) {
this(feature, action, response -> {
});
}

@Override
Expand All @@ -34,6 +43,8 @@ public final void run() {
response = Optional.of(acquireLicense(feature));
if (grantAcquired(response)) {
action.run();
} else {
fallback.accept(response.get());
}
} finally {
response.flatMap(ServiceInvocationResult::data)//
Expand All @@ -57,6 +68,10 @@ public Default(String feature, Runnable action) {
super(feature, action);
}

public Default(String feature, Runnable action, Consumer<ServiceInvocationResult<GrantLockAttempt>> fallback) {
super(feature, action, fallback);
}

@Override
protected ServiceInvocationResult<GrantLockAttempt> acquireLicense(String feature) {
return new EquinoxPassage().acquireLicense(feature);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.passage.lic.internal.jface.actions;

import java.util.function.Consumer;
import java.util.function.Supplier;

import org.eclipse.passage.lic.internal.api.ServiceInvocationResult;
Expand All @@ -25,11 +26,17 @@ public final class LicensedRunnableUi extends LicensedRunnable {

private final Supplier<Shell> shell;

public LicensedRunnableUi(Supplier<Shell> shell, String feature, Runnable action) {
super(feature, action);
public LicensedRunnableUi(Supplier<Shell> shell, String feature, Runnable action,
Consumer<ServiceInvocationResult<GrantLockAttempt>> fallback) {
super(feature, action, fallback);
this.shell = shell;
}

public LicensedRunnableUi(Supplier<Shell> shell, String feature, Runnable action) {
this(shell, feature, action, response -> {
});
}

public LicensedRunnableUi(String feature, Runnable action) {
this(Display.getDefault()::getActiveShell, feature, action);
}
Expand Down
4 changes: 4 additions & 0 deletions bundles/org.eclipse.passage.loc.api/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ Require-Bundle: org.eclipse.e4.core.services;bundle-version="0.0.0",
org.eclipse.passage.lic.users.model;bundle-version="0.0.0",
org.eclipse.passage.lic.licenses.model;bundle-version="0.0.0"
Bundle-ActivationPolicy: lazy
Provide-Capability: licensing.feature;licensing.feature="org.eclipse.passage.loc.operator.issue.personal";version="2.0.0";name="Issue Personal License";level="warn";provider="Eclipse Passage",
licensing.feature;licensing.feature="org.eclipse.passage.loc.operator.issue.floating";version="2.0.0";name="Issue Floating License";level="warn";provider="Eclipse Passage",
licensing.feature;licensing.feature="org.eclipse.passage.loc.operator.issue.personal.full";version="2.0.0";name="Issue full functioning Personal License";level="error";provider="Eclipse Passage",
licensing.feature;licensing.feature="org.eclipse.passage.loc.operator.issue.floating.full";version="2.0.0";name="Issue full functioning Floating License";level="error";provider="Eclipse Passage"
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@SuppressWarnings("restriction")
public class DashboardIssueFloatingLicenseHandler {

private final String feature = "org.eclipse.passage.loc.operator.issuefloating"; //$NON-NLS-1$
private final String feature = "org.eclipse.passage.loc.operator.issue.floating"; //$NON-NLS-1$

@Execute
public void execute(IEclipseContext context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@SuppressWarnings("restriction")
public class DashboardIssueLicenseHandler {

private final String feature = "org.eclipse.passage.loc.operator.issuepersonal"; //$NON-NLS-1$
private final String feature = "org.eclipse.passage.loc.operator.issue.personal"; //$NON-NLS-1$

@Execute
public void execute(IEclipseContext context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="0.0.0",
org.eclipse.passage.loc.workbench;bundle-version="0.0.0",
org.eclipse.passage.lic.e4.ui;bundle-version="0.0.0"
Eclipse-BundleShape: dir
Provide-Capability: licensing.feature;licensing.feature="org.eclipse.passage.loc.operator.product";name="Eclipse Passage Operator";version="2.0.0";provider="Eclispe Passage";level="warn",
licensing.feature;licensing.feature="org.eclipse.passage.loc.operator.issuepersonal";version="2.0.0";name="Issue Personal License";level="error";provider="Eclipse Passage",
licensing.feature;licensing.feature="org.eclipse.passage.loc.operator.issuefloating";version="2.0.0";name="Issue Floating License";level="warn";provider="Eclipse Passage"
Provide-Capability: licensing.feature;licensing.feature="org.eclipse.passage.loc.operator.product";name="Eclipse Passage Operator";version="2.0.0";provider="Eclispe Passage";level="warn"

0 comments on commit af3c9e3

Please sign in to comment.