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

[#1313] Base loc rendering service should have flexible priority #1314

Merged
merged 1 commit into from
Mar 14, 2024
Merged
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) 2018, 2020 ArSysOp
* Copyright (c) 2018, 2024 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 @@ -9,10 +9,10 @@
*
* Contributors:
* ArSysOp - initial API and implementation
* ArSysOp - further support
*******************************************************************************/
package org.eclipse.passage.loc.workbench.emfforms.renderers;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

Expand All @@ -28,37 +28,33 @@
import org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer;
import org.eclipse.emfforms.spi.swt.core.di.EMFFormsDIRendererService;

public class StructuredFeatureRendererService implements EMFFormsDIRendererService<VControl> {
public abstract class StructuredFeatureRendererService implements EMFFormsDIRendererService<VControl> {

private final Class<? extends AbstractSWTRenderer<VControl>> renderer;
private final Iterable<EStructuralFeature> features;
private final double priority;
private EMFFormsDatabinding databinding;
private ReportService report;

private double priority = 10;

private EMFFormsDatabinding databindingService;
private ReportService reportService;
protected StructuredFeatureRendererService(Class<? extends AbstractSWTRenderer<VControl>> renderer, double priority,
EStructuralFeature... features) {
this(renderer, priority, Arrays.asList(features));
}

Check warning on line 42 in bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java#L41-L42

Added lines #L41 - L42 were not covered by tests

protected StructuredFeatureRendererService(Class<? extends AbstractSWTRenderer<VControl>> renderer,
EStructuralFeature... features) {
this.renderer = renderer;
this.features = Arrays.asList(features);
this(renderer, 10, features);

Check warning on line 46 in bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java#L46

Added line #L46 was not covered by tests
}

/**
*
* @param renderer
* @param features
*
* @since 0.5.0
*/
protected StructuredFeatureRendererService(Class<? extends AbstractSWTRenderer<VControl>> renderer,
protected StructuredFeatureRendererService(Class<? extends AbstractSWTRenderer<VControl>> renderer, double priority,

Check warning on line 49 in bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java#L49

Added line #L49 was not covered by tests
Collection<EStructuralFeature> features) {
this.renderer = renderer;
this.features = new ArrayList<EStructuralFeature>(features);
this.priority = priority;
this.features = features;

Check warning on line 53 in bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java#L52-L53

Added lines #L52 - L53 were not covered by tests
}

@Override
public double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
public final double isApplicable(VElement vElement, ViewModelContext viewModelContext) {
if (!VControl.class.isInstance(vElement)) {
return NOT_APPLICABLE;
}
Expand All @@ -69,10 +65,10 @@
@SuppressWarnings("rawtypes")
IValueProperty valueProperty;
try {
valueProperty = databindingService.getValueProperty(control.getDomainModelReference(),
valueProperty = databinding.getValueProperty(control.getDomainModelReference(),

Check warning on line 68 in bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java#L68

Added line #L68 was not covered by tests
viewModelContext.getDomainModel());
} catch (final DatabindingFailedException ex) {
reportService.report(new DatabindingFailedReport(ex));
report.report(new DatabindingFailedReport(ex));

Check warning on line 71 in bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java#L71

Added line #L71 was not covered by tests
return NOT_APPLICABLE;
}
Object valueType = valueProperty.getValueType();
Expand All @@ -88,27 +84,27 @@
}

@Override
public Class<? extends AbstractSWTRenderer<VControl>> getRendererClass() {
public final Class<? extends AbstractSWTRenderer<VControl>> getRendererClass() {
return renderer;
}

protected void bindEMFFormsDatabinding(EMFFormsDatabinding service) {
this.databindingService = service;
this.databinding = service;

Check warning on line 92 in bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java#L92

Added line #L92 was not covered by tests
}

protected void unbindEMFFormsDatabinding(EMFFormsDatabinding service) {
if (this.databindingService == service) {
this.databindingService = null;
if (this.databinding == service) {
this.databinding = null;

Check warning on line 97 in bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java#L97

Added line #L97 was not covered by tests
}
}

protected void bindReportService(ReportService service) {
this.reportService = service;
this.report = service;

Check warning on line 102 in bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java#L102

Added line #L102 was not covered by tests
}

protected void unbindReportService(ReportService service) {
if (this.reportService == service) {
this.reportService = null;
if (this.report == service) {
this.report = null;

Check warning on line 107 in bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java

View check run for this annotation

Codecov / codecov/patch

bundles/org.eclipse.passage.loc.workbench.emfforms/src/org/eclipse/passage/loc/workbench/emfforms/renderers/StructuredFeatureRendererService.java#L107

Added line #L107 was not covered by tests
}
}

Expand Down
Loading