Skip to content
Open
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
11 changes: 11 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
= Changelog

== v2026.5.0

=== Dependency update

=== New features

=== Improvements

=== Bug fixes
- https://github.com/ObeoNetwork/pepper/issues/50[#50] Stop extending DefaultLabelService

== v2026.3.0

=== Dependency update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@

import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.sirius.components.collaborative.api.IRepresentationImageProvider;
import org.eclipse.sirius.components.core.CoreImageConstants;
import org.eclipse.sirius.components.core.api.ILabelServiceDelegate;
import org.eclipse.sirius.components.core.api.IObjectSearchService;
import org.eclipse.sirius.components.core.api.labels.StyledString;
import org.eclipse.sirius.components.emf.ResourceMetadataAdapter;
import org.eclipse.sirius.components.emf.services.api.IEMFLabelService;
import org.eclipse.sirius.web.application.object.services.DefaultLabelService;
import org.eclipse.sirius.ext.emf.edit.EditingDomainServices;
import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationIconURL;
import org.eclipse.sirius.web.domain.boundedcontexts.representationdata.RepresentationMetadata;
import org.springframework.stereotype.Service;

/**
Expand All @@ -31,12 +36,17 @@
* @author Laurent Fasani
*/
@Service
public class PepperMMLabelServiceDelegate extends DefaultLabelService implements ILabelServiceDelegate {
public class PepperMMLabelServiceDelegate implements ILabelServiceDelegate {

private final EditingDomainServices editingDomainServices = new EditingDomainServices();

public PepperMMLabelServiceDelegate(List<IRepresentationImageProvider> iRepresentationImageProviders, IEMFLabelService iemfLabelService) {
super(iRepresentationImageProviders, iemfLabelService);
private final List<IRepresentationImageProvider> representationImageProviders;

private final IEMFLabelService emfLabelService;

public PepperMMLabelServiceDelegate(IEMFLabelService iemfLabelService, List<IRepresentationImageProvider> representationImageProviders) {
this.representationImageProviders = representationImageProviders;
this.emfLabelService = iemfLabelService;
}

@Override
Expand All @@ -49,8 +59,41 @@ public StyledString getStyledLabel(Object object) {
if (object instanceof TaskTag tag) {
return StyledString.of(this.editingDomainServices.getLabelProviderText(tag));
} else {
return super.getStyledLabel(object);
StyledString label = StyledString.of("");
if (object instanceof RepresentationMetadata representationMetadata) {
label = StyledString.of(representationMetadata.getLabel());
} else if (object instanceof Resource resource) {
label = resource.eAdapters().stream()
.filter(ResourceMetadataAdapter.class::isInstance)
.map(ResourceMetadataAdapter.class::cast).findFirst()
.map(ResourceMetadataAdapter::getName)
.map(StyledString::of)
.orElse(StyledString.of(resource.getURI().lastSegment()));
} else if (object instanceof EObject eObject) {
label = this.emfLabelService.getStyledLabel(eObject);
}
return label;
}
}

@Override
public List<String> getImagePaths(Object self) {
List<String> imagePaths = List.of(CoreImageConstants.DEFAULT_SVG);
if (self instanceof RepresentationMetadata representationMetadata) {
if (!representationMetadata.getIconURLs().isEmpty()) {
imagePaths = representationMetadata.getIconURLs().stream()
.map(RepresentationIconURL::url)
.toList();
} else {
imagePaths = this.representationImageProviders.stream()
.flatMap(provider -> provider.getImageURL(representationMetadata.getKind()).stream())
.toList();
}
} else if (self instanceof Resource) {
imagePaths = List.of("/icons/Resource.svg");
} else if (self instanceof EObject eObject) {
imagePaths = this.emfLabelService.getImagePaths(eObject);
}
return imagePaths;
}
}
Loading