use of org.eclipse.sirius.components.representations.IRepresentationDescription in project sirius-components by eclipse-sirius.
the class NodeResizeTests method createDiagramCreationService.
private TestDiagramCreationService createDiagramCreationService(Diagram diagram) {
IRepresentationDescriptionSearchService.NoOp representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp() {
@Override
public Optional<IRepresentationDescription> findById(IEditingContext editingContext, UUID representationDescriptionId) {
DiagramDescription diagramDescription = NodeResizeTests.this.defaultTestDiagramDescriptionProvider.getDefaultDiagramDescription(diagram);
return Optional.of(diagramDescription);
}
};
NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(new ImageSizeProvider());
IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider);
LayoutService layoutService = new LayoutService(new IELKDiagramConverter.NoOp(), new IncrementalLayoutDiagramConverter(), new LayoutConfiguratorRegistry(List.of()), new ELKLayoutedDiagramProvider(), new IncrementalLayoutedDiagramProvider(), representationDescriptionSearchService, incrementalLayoutEngine);
return new TestDiagramCreationService(this.objectService, representationDescriptionSearchService, layoutService);
}
use of org.eclipse.sirius.components.representations.IRepresentationDescription in project sirius-components by eclipse-sirius.
the class DiagramLayoutTest method createDiagramCreationService.
private TestDiagramCreationService createDiagramCreationService(Diagram diagram) {
IRepresentationDescriptionSearchService.NoOp representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp() {
@Override
public Optional<IRepresentationDescription> findById(IEditingContext editingContext, UUID representationDescriptionId) {
DiagramDescription diagramDescription = DiagramLayoutTest.this.defaultTestDiagramDescriptionProvider.getDefaultDiagramDescription(diagram);
return Optional.of(diagramDescription);
}
};
NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(new ImageSizeProvider());
IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider);
LayoutService layoutService = new LayoutService(new IELKDiagramConverter.NoOp(), new IncrementalLayoutDiagramConverter(), new LayoutConfiguratorRegistry(List.of()), new ELKLayoutedDiagramProvider(), new IncrementalLayoutedDiagramProvider(), representationDescriptionSearchService, incrementalLayoutEngine);
return new TestDiagramCreationService(this.objectService, representationDescriptionSearchService, layoutService);
}
use of org.eclipse.sirius.components.representations.IRepresentationDescription in project sirius-components by eclipse-sirius.
the class NodeCreationTests method createDiagramCreationService.
private TestDiagramCreationService createDiagramCreationService(Diagram diagram) {
IRepresentationDescriptionSearchService.NoOp representationDescriptionSearchService = new IRepresentationDescriptionSearchService.NoOp() {
@Override
public Optional<IRepresentationDescription> findById(IEditingContext editingContext, UUID representationDescriptionId) {
DiagramDescription diagramDescription = NodeCreationTests.this.defaultTestDiagramDescriptionProvider.getDefaultDiagramDescription(diagram);
return Optional.of(diagramDescription);
}
};
NodeSizeProvider nodeSizeProvider = new NodeSizeProvider(new ImageSizeProvider());
IncrementalLayoutEngine incrementalLayoutEngine = new IncrementalLayoutEngine(nodeSizeProvider);
LayoutService layoutService = new LayoutService(new IELKDiagramConverter.NoOp(), new IncrementalLayoutDiagramConverter(), new LayoutConfiguratorRegistry(List.of()), new ELKLayoutedDiagramProvider(), new IncrementalLayoutedDiagramProvider(), representationDescriptionSearchService, incrementalLayoutEngine);
return new TestDiagramCreationService(this.objectService, representationDescriptionSearchService, layoutService);
}
use of org.eclipse.sirius.components.representations.IRepresentationDescription in project sirius-components by eclipse-sirius.
the class EditingContextRepresentationDescriptionsEventHandler method findAllCompatibleRepresentationDescriptions.
private List<IRepresentationDescription> findAllCompatibleRepresentationDescriptions(IEditingContext editingContext, String kind) {
List<IRepresentationDescription> result = new ArrayList<>();
Optional<Object> optionalClazz = this.resolveKind(editingContext, kind);
if (optionalClazz.isPresent()) {
var allRepresentationDescriptions = this.representationDescriptionSearchService.findAll(editingContext);
for (IRepresentationDescription description : allRepresentationDescriptions.values()) {
VariableManager variableManager = new VariableManager();
variableManager.put(IRepresentationDescription.CLASS, optionalClazz.get());
Predicate<VariableManager> canCreatePredicate = description.getCanCreatePredicate();
boolean canCreate = canCreatePredicate.test(variableManager);
if (canCreate) {
result.add(description);
}
}
}
return result;
}
use of org.eclipse.sirius.components.representations.IRepresentationDescription in project sirius-web by eclipse-sirius.
the class DynamicRepresentationDescriptionService method findDynamicRepresentationDescriptions.
@Override
public List<IRepresentationDescription> findDynamicRepresentationDescriptions(IEditingContext editingContext) {
List<IRepresentationDescription> dynamicRepresentationDescriptions = new ArrayList<>();
if (this.isStudioDefinitionEnabled) {
List<EPackage> accessibleEPackages = this.getAccessibleEPackages(editingContext);
this.documentRepository.findAllByType(ViewPackage.eNAME, ViewPackage.eNS_URI).forEach(documentEntity -> {
Resource resource = this.loadDocumentAsEMF(documentEntity);
// @formatter:off
this.getViewDefinitions(resource).forEach(view -> this.viewConverter.convert(view, accessibleEPackages).stream().filter(Objects::nonNull).forEach(dynamicRepresentationDescriptions::add));
// @formatter:on
});
}
return dynamicRepresentationDescriptions;
}
Aggregations