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

572833 #741

Merged
merged 4 commits into from
Apr 17, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
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
@@ -1,5 +1,6 @@
/*******************************************************************************
* Copyright (c) 2021 ArSysOp
* Copyright (
eparovyshnaya marked this conversation as resolved.
Show resolved Hide resolved
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
Expand All @@ -12,6 +13,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 +27,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"