Skip to content

Commit

Permalink
[3763] Update the Selection Dialog to display its content using a Tre…
Browse files Browse the repository at this point in the history
…eView

Bug: #3763
Signed-off-by: Florian Barbin <[email protected]>
  • Loading branch information
florianbarbin authored and sbegaudeau committed Sep 17, 2024
1 parent bcef547 commit 2394698
Show file tree
Hide file tree
Showing 56 changed files with 2,032 additions and 1,456 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
- https://github.com/eclipse-sirius/sirius-web/issues/3875[#3875] [sirius-web] The `ExplorerView` component has been moved from `sirius-components-trees` to `sirius-web-application` module
- https://github.com/eclipse-sirius/sirius-web/issues/3155[#3155] [core] All the paths in the code involving the modification of some data (project, semantic data, representation data, etc.) will now require a new parameter `ICause cause` which is the cause of this change.
Both `IInput` and `IDomainEvent` implement `ICause` and will thus be used to indicate which action has triggered the change.
- https://github.com/eclipse-sirius/sirius-web/issues/3763[#3763] [core] updates some services behavior:
** The `org.eclipse.sirius.components.emf.services.DefaultIdentityService#getId(Object object)` Can now provides the Id if the Object is of type `org.eclipse.emf.ecore.resource.Resource`. Before this change, it would have returned null.
** The `org.eclipse.sirius.components.emf.services.DefaultLabelService` Can now provides the label if the Object is of type `org.eclipse.emf.ecore.resource.Resource`. Before this change, it would have returned an empty string.
** The `org.eclipse.sirius.components.emf.services.DefaultContentService#getContents(Object)` Can now provides the content if the Object is of type `org.eclipse.emf.ecore.resource.Resource`. Before this change, it would have returned an empty list.


=== Dependency update

Expand All @@ -39,6 +44,8 @@ Both `IInput` and `IDomainEvent` implement `ICause` and will thus be used to ind

=== New Features

- https://github.com/eclipse-sirius/sirius-web/issues/3763[#3763] [diagram] Make it possible to display semantic candidates in the selection dialog using a tree


=== Improvements

Expand All @@ -51,7 +58,6 @@ Both `IInput` and `IDomainEvent` implement `ICause` and will thus be used to ind
The interfaces `IInput` and `IDomainEvent` are now both extending `ICause` which let us capture the causes of a domain event recursively.
An event may have been caused by another event or caused by an input received from the frontend for example.


== v2024.9.0

=== Shapes
Expand Down Expand Up @@ -186,6 +192,7 @@ A migration participant has been added to automatically keep compatible all diag
- https://github.com/eclipse-sirius/sirius-web/issues/3951[#3951] [sirius-web] Provide an error page to redirect users in case of error
- https://github.com/eclipse-sirius/sirius-web/issues/3974[#3974] [diagram] Add support for `<` and `>` to trigger direct edit


== v2024.7.0

=== Shapes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@
*******************************************************************************/
package org.eclipse.sirius.components.compatibility.diagrams;

import java.util.List;
import java.util.Objects;

import org.eclipse.sirius.components.compatibility.api.IAQLInterpreterFactory;
import org.eclipse.sirius.components.compatibility.api.IIdentifierProvider;
import org.eclipse.sirius.components.compatibility.services.selection.api.ISelectModelElementVariableConverter;
import org.eclipse.sirius.components.core.api.IObjectService;
import org.eclipse.sirius.components.interpreter.AQLInterpreter;
import org.eclipse.sirius.components.interpreter.Result;
import org.eclipse.sirius.components.representations.VariableManager;
import org.eclipse.sirius.components.selection.Selection;
import org.eclipse.sirius.components.selection.description.SelectionDescription;
import org.eclipse.sirius.viewpoint.description.tool.SelectModelElementVariable;
import org.springframework.stereotype.Service;
Expand All @@ -41,36 +36,25 @@ public class SelectModelElementVariableConverter implements ISelectModelElementV

private final IIdentifierProvider identifierProvider;

private final IAQLInterpreterFactory interpreterFactory;

public SelectModelElementVariableConverter(IObjectService objectService, IIdentifierProvider identifierProvider, IAQLInterpreterFactory interpreterFactory) {
public SelectModelElementVariableConverter(IObjectService objectService, IIdentifierProvider identifierProvider) {
this.objectService = Objects.requireNonNull(objectService);
this.identifierProvider = Objects.requireNonNull(identifierProvider);
this.interpreterFactory = Objects.requireNonNull(interpreterFactory);
}

@Override
public SelectionDescription convert(SelectModelElementVariable selectModelElementVariable, org.eclipse.sirius.diagram.description.DiagramDescription diagramDescription) {
AQLInterpreter interpreter = this.interpreterFactory.create(diagramDescription);
return SelectionDescription.newSelectionDescription(this.identifierProvider.getIdentifier(selectModelElementVariable))
.objectsProvider(variableManager -> {
Result result = interpreter.evaluateExpression(variableManager.getVariables(), selectModelElementVariable.getCandidatesExpression());
return result.asObjects().orElse(List.of()).stream()
.filter(Objects::nonNull)
.toList();
})
.messageProvider(variableManager -> {
String message = selectModelElementVariable.getMessage();
if (message == null) {
message = "";
}
return message;
})
.idProvider(variableManager -> Selection.PREFIX)
.idProvider(variableManager -> "selection://")
.labelProvider(variableManager -> variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getLabel).orElse(null))
.iconURLProvider(variableManager -> variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getImagePath).orElse(List.of()))
.targetObjectIdProvider(variableManager -> variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getId).orElse(null))
.selectionObjectsIdProvider(variableManager -> variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getId).orElse(null))
.label("Selection Description")
.canCreatePredicate(variableManager -> false)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
*******************************************************************************/
package org.eclipse.sirius.components.emf.services;

import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.sirius.components.core.api.IDefaultContentService;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.springframework.stereotype.Service;

/**
* Default implementation of {@link IDefaultContentService}.
Expand All @@ -48,6 +48,10 @@ public List<Object> getContents(Object object) {
contents.addAll(eObject.eContents());
}
}
else if (object instanceof Resource resource) {
// The object may be a document
contents.addAll(resource.getContents());
}
return contents;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public String getId(Object object) {
id = representation.getId();
} else if (object instanceof IEditingContext editingContext) {
id = editingContext.getId();
} else if (object instanceof Resource resource) {
id = resource.getURI().path().substring(1);
}
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedImage;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.ReflectiveItemProvider;
import org.eclipse.sirius.components.collaborative.api.IRepresentationImageProvider;
import org.eclipse.sirius.components.core.api.IDefaultLabelService;
import org.eclipse.sirius.components.core.api.labels.StyledString;
import org.eclipse.sirius.components.emf.ResourceMetadataAdapter;
import org.eclipse.sirius.components.representations.IRepresentation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -45,23 +47,29 @@
public class DefaultLabelService implements IDefaultLabelService {

public static final String DEFAULT_ICON_PATH = "/icons/svg/Default.svg";

private static final String DEFAULT_LABEL_FEATURE = "name";

private final LabelFeatureProviderRegistry labelFeatureProviderRegistry;

private final ComposedAdapterFactory composedAdapterFactory;

private final List<IRepresentationImageProvider> representationImageProviders;

private final Logger logger = LoggerFactory.getLogger(LabelFeatureProviderRegistry.class);

public DefaultLabelService(LabelFeatureProviderRegistry labelFeatureProviderRegistry, ComposedAdapterFactory composedAdapterFactory, List<IRepresentationImageProvider> representationImageProviders) {
this.labelFeatureProviderRegistry = Objects.requireNonNull(labelFeatureProviderRegistry);
this.composedAdapterFactory = Objects.requireNonNull(composedAdapterFactory);
this.representationImageProviders = Objects.requireNonNull(representationImageProviders);
}

@Override
public String getLabel(Object object) {
return this.getStyledLabel(object).toString();
}

@Override
public StyledString getStyledLabel(Object object) {
String label = "";
if (object instanceof EObject eObject) {
Expand All @@ -71,11 +79,21 @@ public StyledString getStyledLabel(Object object) {
.orElse("");
} else if (object instanceof IRepresentation representation) {
label = representation.getLabel();
} else if (object instanceof Resource resource) {
label = this.getResourceLabel(resource);
}

return StyledString.of(label);
}

private String getResourceLabel(Resource resource) {
return resource.eAdapters().stream()
.filter(ResourceMetadataAdapter.class::isInstance)
.map(ResourceMetadataAdapter.class::cast).findFirst()
.map(ResourceMetadataAdapter::getName)
.orElse(resource.getURI().lastSegment());
}

@Override
public String getFullLabel(Object object) {
String fullLabel = "";
Expand All @@ -87,6 +105,8 @@ public String getFullLabel(Object object) {
}
} else if (object instanceof IRepresentation representation) {
fullLabel = representation.getLabel();
} else if (object instanceof Resource resource) {
fullLabel = this.getResourceLabel(resource);
} else {
fullLabel = this.getLabel(object);
}
Expand Down Expand Up @@ -143,6 +163,8 @@ public List<String> getImagePath(Object object) {
.map(provider -> provider.getImageURL(representation.getKind()))
.flatMap(Optional::stream)
.toList();
} else if (object instanceof Resource) {
result = List.of("/icons/Resource.svg");
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@Service
public class EMFImagePathService implements IImagePathService {

private static final List<String> IMAGES_PATHS = List.of("/icons/full/obj16", "/icons/full/ovr16");
private static final List<String> IMAGES_PATHS = List.of("/icons/full/obj16", "/icons/full/ovr16", "/icons");

@Override
public List<String> getPaths() {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.sirius</groupId>
<artifactId>sirius-components-collaborative-trees</artifactId>
<version>2024.9.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Loading

0 comments on commit 2394698

Please sign in to comment.