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

[#1326] Operator: extend Agreements service with context #1348

Merged
merged 1 commit into from
Apr 10, 2024
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
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.passage.loc.agreements.emfforms.renderers;

import java.io.File;
import java.nio.file.Files;
import java.util.Optional;

import javax.inject.Inject;
Expand All @@ -24,7 +25,9 @@
import org.eclipse.emfforms.spi.common.report.ReportService;
import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
import org.eclipse.emfforms.spi.core.services.label.EMFFormsLabelProvider;
import org.eclipse.passage.loc.internal.equinox.AgreementsService;

@SuppressWarnings("restriction")
public final class AgreementFileRenderer extends BaseAgreementFileRenderer {

@Inject
Expand All @@ -38,4 +41,12 @@ protected Optional<File> locatedAgreementFile() {
return new LocatedAgreementFile().get();
}

@Override
protected String residentAgreementResource(File file) throws Exception {
String name = file.getName();
new AgreementsService().get().located(name, getViewModelContext().getDomainModel())
.write(Files.readAllBytes(file.toPath()));
return name;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package org.eclipse.passage.loc.agreements.emfforms.renderers;

import java.io.File;
import java.nio.file.Files;
import java.util.Optional;

import org.eclipse.core.databinding.observable.IDecoratingObservable;
Expand All @@ -31,14 +30,12 @@
import org.eclipse.emfforms.spi.core.services.databinding.EMFFormsDatabinding;
import org.eclipse.emfforms.spi.core.services.label.EMFFormsLabelProvider;
import org.eclipse.passage.lic.agreements.model.api.Agreement;
import org.eclipse.passage.loc.internal.equinox.AgreementsService;
import org.eclipse.passage.loc.workbench.emfforms.renderers.TextWithButtonRenderer;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

@SuppressWarnings("restriction")
/**
* <pre>
* TODO:
Expand Down Expand Up @@ -80,20 +77,15 @@ protected final void locateAgreementContentFile() {
return;
}
try {
reflect(reside(file.get()));
reflect(residentAgreementResource(file.get()));
} catch (Exception e) {
getReportService().report(new RenderingFailedReport(e));
}
}

protected abstract Optional<File> locatedAgreementFile();

private String reside(File file) throws Exception {
String name = file.getName();
new AgreementsService().get().located(name, getViewModelContext().getDomainModel())
.write(Files.readAllBytes(file.toPath()));
return name;
}
protected abstract String residentAgreementResource(File file) throws Exception;

private void reflect(String name) {
if (definedName().orElse("").equals(name)) { //$NON-NLS-1$
Expand Down
Loading